Lighting Clipped Along Horizontal Axis
Hello everyone! Before I start, I've been trying to figure this out for quite awhile now but have come to no solution. I am very new to Unity and Game Dev in general so keep that in mind.
I was following a video series by Sebastian Lague on Cave Generation and used his code in my project. I added player movement and turned the lighting down so that I could add a spotlight to the front of the player. It worked well, until I ran it and found that the spotlight was acting very weird -- it would cast light on the ground perfectly fine, as well as on the walls of the cave in the downward position. Anything above an "imaginary line" going along the horizontal axis of the screen was not being lit (other than the ground) As shown:
The top picture shows what I do not want, and the bottom picture shows what is correct.
The code for the cave generation is here.
I was hoping that there wasn't an issue with the code for the cave generation as there's a large portion of the code that I do not understand, however after messing with it for hours, I'm not super hopeful.
If there's somebody that can point me in the right direction as to what to do, I'd be very grateful.
Thank you!
Answer by baileysenger · Oct 14, 2021 at 05:04 AM
Hey everyone, I found the solution thanks to @OswaldP's post. At the end of the CreateWallMesh function, I needed to recalculate the normals using
mesh.RecalculateNormals();