Lighting question...ambient and directional light
by Gareth Fouche · in Torque Game Engine Advanced · 02/08/2008 (1:16 am) · 0 replies
Hi,
I was wondering if anyone could help me with this. I'm trying to get a firmer grip on how TGEAs lighting works.
The issue I'm having is best illustrated with a picture :

I have setup the lights as follows :
Directional light : 1 1 1 1
Ambient light : 1 0 0 1
So in theory if a face is directly facing the sun it should be lit by pure white light, if it is facing away it is lit by pure red light. You can see that effect on the interior in the background.
But you can see that isn't happening on the model (head). I've traced into the code, what seems to be happening is it is pulling lightmap data from the interior the model is standing on, then setting the directional light and ambient light to half this value.
But this creates 2 issues. First, it thinks the directional light is red since the interiors lightmap is red under the model. Secondly, if I remove the ambient component of sunlight completely, it still looks a little funny since the model faces which are facing directly away from the sun aren't black. They are half the lightmap colour, ie, greyish.

Now, if I understand correctly this is a method to simulate standing in the shadow of interiors, right? The key thing I want to know here is if I am understanding correctly and the issues I'm seeing are related to a "hack" to simulate real shadows, or if I've just gone horribly wrong with my shaders somehow. If it's just a result of the trick used to simulate shadows, cool, I understand that there will be situations where the illusion falls apart. But when I thought it was because my shaders were boned....I was pulling my hair out last night trying to "fix" it. I'd make a shader which just used directional light for my model and yet when I adjusted the ambient my model would change colour!
I was wondering if anyone could help me with this. I'm trying to get a firmer grip on how TGEAs lighting works.
The issue I'm having is best illustrated with a picture :

I have setup the lights as follows :
Directional light : 1 1 1 1
Ambient light : 1 0 0 1
So in theory if a face is directly facing the sun it should be lit by pure white light, if it is facing away it is lit by pure red light. You can see that effect on the interior in the background.
But you can see that isn't happening on the model (head). I've traced into the code, what seems to be happening is it is pulling lightmap data from the interior the model is standing on, then setting the directional light and ambient light to half this value.
But this creates 2 issues. First, it thinks the directional light is red since the interiors lightmap is red under the model. Secondly, if I remove the ambient component of sunlight completely, it still looks a little funny since the model faces which are facing directly away from the sun aren't black. They are half the lightmap colour, ie, greyish.

Now, if I understand correctly this is a method to simulate standing in the shadow of interiors, right? The key thing I want to know here is if I am understanding correctly and the issues I'm seeing are related to a "hack" to simulate real shadows, or if I've just gone horribly wrong with my shaders somehow. If it's just a result of the trick used to simulate shadows, cool, I understand that there will be situations where the illusion falls apart. But when I thought it was because my shaders were boned....I was pulling my hair out last night trying to "fix" it. I'd make a shader which just used directional light for my model and yet when I adjusted the ambient my model would change colour!