- Home /
Why does my lighting create square boxes at sharp angles?
See image below. Not using anything fancy; just a basic terrain with a directional and point light.
I've spent weeks on this problem and can't find any information on the internet or anyone else with the same problem, but it happens to every light that I use close to a flat surface.
I just want a normal light and shadow effect.
I've experimented with camera clipping planes and moving the camera. Also note the Camera Preview is different to the game window.
Here are 3 images with the same settings, I've just moved the camera closer for each one:
(this is probably related to shadow distance, with shadows not drawn far away from the camera; thus this problem seems to relate to shadows rather than to the light itself)
Took me a bit to understand what I'm looking at here. So this is a terrain mesh (viewed from above) with random thin mountains and red light in the middle, right?
Can you provide some sense of scale? What are the dimensions here? 100m? 10km? How close is the light to the ground plane?
Also, what are the coordinates of the center? Is this object near the world origin (0,0,0)?
This only happens with deferred lighting. Changing the camera's near and far clipping planes makes the problem worse, but doesn't eli$$anonymous$$ate it.
0,0 is the top left corner of the terrain.
Yes it is looking down at the terrain from the sky, but I get the same effect with a vertical plane and a camera looking sideways.
Scale of everything is the default: 1,1,1, except for the cube which I made into a small wall.
$$anonymous$$oving the point light further from the terrain reduces the problem, but also means that I need to make everything taller to give off shadows.
The problem only happens at sharp angles so of course moving the light away from the plane would increase the range of non-sharp angles surrounding the light.
I don't know if it's related to z-fighting or not, but it seems like such a simple thing that I shouldn't need to waste time on.
I've tried changing the shadow bias and it has no effect.
Answer by Cereal_Killa · Jan 31, 2015 at 08:08 AM
As a temporary fix/hack I have created a plane 0.2 in front of the flat area of the terrain and turned off shadow casting for this plane.
Now the flat surface receives smooth light and smooth shadows from the terrain.
Unfortunately this creates a hard line where the plane meets the hills, but I guess this is unavoidable.