#### Archived

This topic is now archived and is closed to further replies.

# [D3D9] Can ambient lighting affect normal lights

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

my understanding of Direct3D ambient lighting, is that the value stored under D3DRS_AMBIENT is a lowest value. as in, it''s the lowest colour value a vertex can assume. if I set it to be 0x00c0c0c0 all vertices will be AT LEAST rgb(192,192,192) in brightness. however, and this is where I''m getting really confused: the value of my ambient lighting is altering the colour that my directional light is giving the vertices in my terrain. my Dir-light is a strong Red color, if I set a light-grey ambient light it goes pink. if I set it to a dark-grey ambient light it goes a dark red. if i set the ambient light to 0 (black) then theres no light at all. this doesn''t make sense so me!! has anyone got any idea why this might be happening? cheers, Jack DirectX 4 VB: All you need for multimedia programming in Visual Basic Formula 1 Championship Manager, My Game Project.

##### Share on other sites
"if I set it to be 0x00c0c0c0 all vertices will be AT LEAST rgb(192,192,192) in brightness."

the above is not true. your ambient light will get multiplied on ambient component of mesh''s material (0-1) and as the result it will be AT MOST (192,192,192).

##### Share on other sites
hmm, okay - didn''t think it worked that way, but I''ll look into it.

Assuming that is the case, how would I go about creating a situation like I described:

• have lights (currently 1 directional) that aren''t affected by the ambient lighting value
• use the ambient lighting value as the "base" value, ie, if I set it as 64,64,64 then all vertices will be >=64 in colour.

I''m so very very sure thats how I had it working in a previous project

cheers,
Jack

DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.

##### Share on other sites
in fact the method I mentioned above is exactly what happens for the D3D9 SDK tutorial ''lights''.

does anyone have any ideas as to what i COULD have done to affect how the lights should work?

Jack

DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.

##### Share on other sites
- Ambient light is multiplied by the ambient componenet of the material, and then summed with the diffuse and sepecular components.

That is: FinalColor = CalculateAmbient + CalculatedDiffuse + CalculatedSpecular;

So:
//Assuming material.ambient is 1, and that the directional light is normal to the surfaceAmbient = (192,192,192)Directional = (255,0,0)FinalColor = Ambient + Directional = (255,192,192) // Pink

The strange part is the zero ambient one, since you should get red color for some vertices in that case. You''ve got to be doing something wrong here.

Cheers,