Unity3D-BSP-Importer icon indicating copy to clipboard operation
Unity3D-BSP-Importer copied to clipboard

File could not be loaded

Open amuDev opened this issue 5 years ago • 13 comments

Screen shots Settings being used - https://gyazo.com/4caf6ec18ffd84a66e7725238bbce4d9 Error being produced - https://gyazo.com/d5eb3a28b4103875aa5cefcbceb599a2 Inside /BSPTextures/dev/ - https://gyazo.com/bf7d7bf4ed439363b695411b0cfdb239 I do not see any .mat files anywhere

https://github.com/wfowler1/Unity3D-BSP-Importer/issues/1 Not so useful thread... Do I need to decompile the vtf/vmt files? If so how?

amuDev avatar Jan 15 '20 04:01 amuDev

I unpacked the vtf files using vtf2tga, and still getting same error, no .mat files.

amuDev avatar Jan 15 '20 16:01 amuDev

Regardless of whether it can find usable texture files or not, it should always generate the necessary Unity material files. The issue is probably in the way you're specifying the path for materials. As the warning says, you must specify the path relative to the project's Assets folder (because that's how Unity's AssetDatabase API works). From the readme:

Materials path: The path within Assets to save generated Materials to or load from. If a material already exists at the same path, it will use it rather than generate a new one.

Try using only "BSPMaterials" for the materials path and "BSPMesh" as the meshes path (don't specify the path from the root of the drive).

Please post back here with results! I'm going to leave this issue open regardless as a reminder to myself to do a bit of string processing to account for this in the future.

wfowler1 avatar Jan 15 '20 18:01 wfowler1

Updated import settings to - https://gyazo.com/2217e311f403294a0428eca7af96f57b Importing the bsp worked, and the map loaded, only issue is all the textures are black, in game preview and in compiled game - https://gyazo.com/0f5b8fea0d55854948d9be2338556297 Is this due to bad textures?

amuDev avatar Jan 15 '20 19:01 amuDev

It looks like it's using the shader I have it fall back to when it can't find the image. One complication with Source engine is the way it references textures. The BSP file actually references VMT files while this importer looks for the textures by name. If the image file (TGA) doesn't have the same name as the VMT then it won't be found. I'd have to put in some sort of VMT parsing to fix this. I'd like to do this but it's a far future goal and I'm not really sure if it falls within the scope of this project. It would also have the benefit of being able to convert some Source material properties into Unity's standard shader.

The other thing is the paths of the texture files need to remain consistent. For example, "TOOLS/TOOLSTRIGGER" would need to be in your BSPTextures folder at the same path ("BSPTextures/TOOLS/TOOLSTRIGGER.tga"). I don't know if vtf2tga maintains paths like this. I could add an option to look for the texture files at the root of the texture folder instead.

I hope this helps! You're really bringing up a lot of potential quality of life changes I could make, this is good feedback.

wfowler1 avatar Jan 15 '20 21:01 wfowler1

I don't know if vtf2tga maintains paths like this

vtf2tga is very basic and comes pre installed with csgo https://gyazo.com/32173d7d36fcd72cb317bfe9eff62817 But I went through the needed textures and unpacked them, and placed the tga file in the respective dir - https://gyazo.com/764d717e869da9509425fcab4a8f755f settings and errors - https://gyazo.com/f03ca9b8d4dcdf4f8d44fde590fdafee The only texture that is truly not there is /glass/glass01cull, I removed this file to see if there is a difference in errors, does the tga file need to match the error log exactly (make the name caps)? I was under assumption that the mat file was the only one in caps

Example of vtf2tga cmd - https://gyazo.com/77c94057a531d824fc0ac42f4e104ec3

Edit: I was adding shadows to a model and i noticed the textures are there and seem to be loading fine - https://gyazo.com/a492bd13bf896c76117d38dc862dbd69 What does the shaders option change? https://gyazo.com/6e614dabe067e96cf9a8dc891999cbe3 https://gyazo.com/de91777acdeb5fba0d7a2bc78a7bba8e https://gyazo.com/336125406241240e95b037d6a6d52432

amuDev avatar Jan 15 '20 23:01 amuDev

Filename capitalization shouldn't matter, especially on Windows. However, I did notice a couple things:

I'll have to look at that map and those materials specifically, but on displacement meshes especially it's likely the material name doesn't match a texture image name, but worse than that...

Looking into this, I've just realized that I'm not fixing the names of cubemap materials. Instead of using the proper material name, it's using something like "materialname_-157_-488_712". That's a pretty serious issue I'll have to fix as soon as possible. Since you're combine meshes per material, can you look in your Unity hierarchy to see if this is part of the issue you're having?

wfowler1 avatar Jan 16 '20 00:01 wfowler1

Inside my BSPMesh dir - https://gyazo.com/67a89bb99f23a01cfaa0c7bd38d5b86f All the files inside are similarly named "mesh_-numbers" i dont see anything in materials or textures that is similar to this, only seems like meshes. You can find the original bsp for the map I'm trying to port here - https://steamcommunity.com/sharedfiles/filedetails/?id=334008871

amuDev avatar Jan 16 '20 00:01 amuDev

It looks like it's using the shader I have it fall back to when it can't find the image.

Is there a way I can manually convert the tga to mat and apply the textures? The mat files it generated seem like it didnt work properly, https://gyazo.com/de91777acdeb5fba0d7a2bc78a7bba8e https://gyazo.com/336125406241240e95b037d6a6d52432

amuDev avatar Jan 16 '20 15:01 amuDev

The .mat isn't a texture in itself, it's a material, a chunk of data which tells the engine how to use a shader to define how a mesh should look. This is the same concept as Source's material files (the VMTs). What you could do is change the broken materials to use the Standard shader rather than the VR one I have it use, and you could set the appropriate TGA file as the Albedo.

The issue with that is since it couldn't find the texture image, the UVs on the meshes couldn't be set properly, so it's likely the textures won't be scaled properly.

The mesh filenames aren't important, I'm talking about the GameObjects in the Unity Hierarchy. This map seems to only use DEV materials so the cubemap issue isn't the problem here.

It looks like you've got your TGA files alongside the materials in the BSPMaterials folder. Put the dev TGAs in the BSPTextures/DEV folder instead, and make sure you delete the materials that have already been generated in BSPMaterials, otherwise it won't regenerate new ones when it finds the textures! I should probably add in some handling for that as well...

wfowler1 avatar Jan 16 '20 23:01 wfowler1

Moving the tga files to /BSPTextures/dev/ loaded the textures, there are 2 textures that didnt load and that is due to me not being able to convert to tga, one is a glass texture and there is no vtf file, only vmt (/glass/glass01cull.vmt) am I able to convert this to a tga or do I have to use a different method for this texture? The second texture in question is the skybox, it loads the default blue gridded texture, I would want it to just be open above the map and use the "skybox" texture in unity, when i try to select the section of the map that is the skybox texture it opens the /mapname/worldspawn which is the map outline, am I able to only remove the skybox part?

Thanks for helping through these issues I've had, great repo!

amuDev avatar Jan 17 '20 03:01 amuDev

One cool thing about VMTs is they are just text. You can open them in any text editor.

Looking at materials/glass/glass01cull.vmt, its main texture is materials/models\props_windows/window_uban_apt_glass.vtf. So convert it to a TGA and put that at BSPTextures/glass/glass01cull.tga

This is why I'd have to write a VMT parser to do this right.

wfowler1 avatar Jan 17 '20 05:01 wfowler1

Ok, thats a bit weird, but makes sense why its used. Last question is about the skybox, is there a way to either remove the texture or make it transparent?

amuDev avatar Jan 17 '20 06:01 amuDev

If you select the GameObject for the worldspawn, the mesh renderer on it will have many different materials. If you find the one for tools/toolsskybox you can go into the material and change the shader to something like "Skybox/6 Sided". That'll let Unity's skybox show through.

Alternatively, if you set the mesh combining option to "Per material" you can then select the mesh for the skybox and delete it. It'll create a few more GameObjects and save out a few more meshes, but in a map as simple as this it probably won't matter to you.

Which gives me another idea for an option: materials to ignore.

wfowler1 avatar Jan 17 '20 17:01 wfowler1