Is anyone else seeing a lighting difference between models and GeoMip Terrain ?
I’m including two pictures, first one shows a model on a terrain (no texture) with directional light at azimuth 90 deg ( vector pointing from right to left ), the model looks like it is shaded correctly but my terrain is shaded on the opposite side. The second picture is for azimuth -90 ( vector pointing from left to right). Azimuth values of 0 and 180 look correct, it’s just that it appears that there are two light sources that will rotate in opposite directions as I change the azimuth of the light source. I’ve looked at different models and get the same results. wondering if I got flipped normals, but then culling looks good.
The model looks correct for the light source direction.
The camera is facing along positive Y direction (North) and the model is facing along negative Y direction (South), the directional light vector is set pointing -1. 0. 0. (shining from east to west). In the second picture I point the light in the opposite direction. It appears that the terrain is lit the wrong way. Also note that for light vectors of (0. 1. 0., pointing North) and (0. -1. 0., pointing South) both terrain and model are shaded correctly, but if you rotate that light vector then shading moves in opposite directions for the model and terrain, with the model being the correct shading for the given light direction.
I think I might be on to something. I was looking at the Panda GeoMipTerrain.cxx get_normal function and noticed that the x component calculation would give the opposite expected result.
In the equation above, if the next pixel to the right (px) has a z value that is less than the pixel to the left (nx) then the result x component would be negative, but in this situation you would want the x component to be positive, pointing in the positive x direction. So I changed my copy of the GeoMipTerrain.cxx
to do:
Heh I remember being confused about why my lighting seemed to be flipped over the x axis. I gave up trying to figure out what I was doing wrong and made the sun orbit around the x axis along the y so that the x normal stayed at 90 degrees.