Game Development Community

Terrain lighting mirrored

by Sander Van Rossen · in Artist Corner · 02/05/2003 (12:37 am) · 14 replies

I've got this weird thing happening when i light my terrain in torque..
The shadows to be mirrored around one axis for the entire terrain..
But not for the shadows from the objects on the terrain..

anyone got any idea how this is possible?
I'm assuming now that it isn't the engine itself
(coz then more people would have that problem, right?)

I've checked my scale stuff etc. and it's all 1 1 1
so it's not some scale thing
Even then, if it was something like this, then why is only the lighting mirrored?

any help would be really appriciated..

#1
02/05/2003 (12:54 am)
not sure what your problem exactly is, if you can take a screen shot sometimes that will give people a better indicator on what happened.

do you have 2 suns ?
#2
02/05/2003 (1:12 am)
i don't have two suns, so that's not the problem
as a sanity check i removed my only sun to see what would happen, and not suprisingly i had no lighting left at all

here's a screenshot
http://mentalvortex.com/lotoh/lighting.jpg

as you can see the shadows don't make any sense at all
when i look at the terrain, the shadows *would* make sense
if the one of the axi would be mirrored..
#3
02/05/2003 (1:21 am)
I suck at matrix math. Any chance the sun could be under the terrain?

-Eric
#4
02/05/2003 (2:49 am)
no, the sun doesn't use it's position to calculate the lighting (and even then it's position is above the terrain)
it uses a lighting vector instead.
and if i invert the up/down orientation of the vector the world goes completely dark
so i'm quite sure that has nothing to do with it...
#5
02/05/2003 (3:31 am)
Check the Resources. There's a couple of tools to help figure out the vector. Desmond Fletcher would be one developer who's worked on one.

I've done plenty of work with the terrain lighting, but it was all trial & error. From what I've seen, it wouldn't surprise me in the least o find it could be under the terrain.

Like I said: check the resources. Either that, or it's trial-and-error for you, too. ;-)

Good luck!

-Eric Forhan, MRT
#6
02/05/2003 (6:41 am)
The same thing happens occasionally in T2. Just try fooling with the direction values a bit, and the lighting will quickly pop into place. I believe the engine somehow gets "confused" and stops properly reading the position values, so changing them at all just gets it back on its feet.
#7
02/06/2003 (12:19 am)
I've messed around with the values..
and it -seems- to happen when y > x or -y < -x
weird huh?

edit: switched x and y around doh
#8
02/07/2003 (4:00 am)
The sun's direction parameter sets the light direction vector. As Eric asked, what are the values for that vector?
#9
02/07/2003 (4:08 am)
I am well aware that the direction vector is used for the lighting
I was refering to the x & y elements of that 3d (xyz) vector
#10
02/07/2003 (11:46 am)
Desmond, these are from his screenshot: "0.0 0.0995037 -0.995037"

Sander, have an open mind and listen. This is Desmond's territory and you might even learn something. =)

-Eric
#11
02/07/2003 (11:58 am)
One thing I noticed looking at your screenshot. The problem area is next to basically a perpandicular wall of terrain. I'd bet that if you elimenated that the shadowing would fall into place without any tweaking to the sun vectors
#12
02/07/2003 (2:00 pm)
The lighting code _ought_ to work regardless of the perpendicularity of the terrain. There shouldn't be any substantial difference between a hill and a "sheer" cliff, except in degree and distance of shadow.
#13
02/07/2003 (2:11 pm)
Labrat:

I had a lot of experience with this problem in T2. It really doesn't matter what the heck the terrain looks like -- if the shadow gets screwed up, it stays screwed up. I generated at least 10 terrains, each using completely different combinations of fractal primitives, and all exibited the same problem. I finally came up with an unambiguous demonstration of the problem: a smooth, soft canyon going East-West across the map, and its shadow going perfectly North-South, intersecting right at the center. Nothing fixes it except changing the sun direction to a non-glitchy value.
#14
02/09/2003 (8:59 am)
sorry, i merely ment that i'm quite sure that the vector isn't below the terrain.
I messed around with the vector and when the vector is below the terrain everything is simply dark.

as for the terrain,
if you move the camera way up and look straight down
it looks like the whole terrain lightmap is mirrored around one axis
(not sure which axis)