Unity3D-BSP-Importer
Unity3D-BSP-Importer copied to clipboard
Potential normal or lighmap issue after importing in Unity?
I'm trying to debug a strange issue I see with lighting, a spotlight is added to an enclosed room built in Trenchbroom and compiled by qbsp and vis (works in Quake 1 engine). After importing the lower half of all the meshes do not receive light (suspect issue with bottom vertices, tangents or normals, but not sure). I have attached a screenshot and the Quake 1 map file as well as the imported BSP file. I have also added in Unity, meshes built from their own primitives and ProBuilder to see how light affects them, you can see the cylinder in the scene is lit as expected -- but not the imported meshes. I have also imported the same BSP file into Blender to check if there is an issue with the generated BSP file, but blender renders and lights it as expected.
Archive.zip
Note: I am using the latest importer as of yesterday and Unity LTS 2022 with Built-in Renderer. (I cannot attach the Unity project as it's too large)
Hmm, yeah this is a very strange issue. For some reason, generated meshes only seem to receive light from below. I'm really not sure what is causing this, or when the issue started happening. I have ruled out the mesh combining processes (starting at BSPLoader line 563). Calling Mesh.RecalculateNormals()
doesn't seem to have any impact on this, nor does Unwrapping.GenerateSecondaryUVSet(Mesh)
Directional light from above
Directional light from below
A point light next to the wall
Frankly I'm mystified by this. I'll try to find time to figure out when this issue started happening, or if it has always been an issue. I remember using directional lights before in a way that looked good in the past, so hopefully I can bisect this.
I spent around half an hour trying to figure out what was wrong. Never once did it cross my mind to try turning the directional light upside down lol. Glad to see it's a known bug now.
Thanks for releasing this. It's a fantastic tool! I've been playing with several BSP loaders for Unity, and yours is the most versatile.
I've noticed that Quake 3 maps seem to load fine, but Quake 1 maps appear to have a lightmap issue. When I compared the output mesh with the one produced by https://github.com/weeeBox/quake-one-in-unity, it seems to be missing a Realtime Lightmap. I'm new to Unity so I'm not sure if this would be an issue. Hopefully, this helps pinpoint what might be going on.
I'm importing without saving any assets to Unity, mesh combining set to "Per Material", curve detail 3 and scale 0.0254.
Keep up the great work!
Same issue here with Source 2 engine. Is there any update regarding this?
Actually, I called RecalculateNormals() at the end of BuildMesh() method and it seems working.
It was like this before modification:
Not sure if this is the correct solution, maybe it's needed to recalculate normals in other parts of the code!