Jump to content
  • Advertisement
Sign in to follow this  
compiler

Ambient lighting

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im trying to get a deeper knowledge about lighting in d3d. from the SDK Documentation i know, that ambient lighting is computed by the following formula: Ambient Lighting = Ca*[Ga + sum(Atti*Spoti*Lai)] with Ca = Material ambient color Ga = E Global ambient color Atteni = Light attenuation of the ith light. Spoti = Spotlight factor of the ith light. Lai = Light ambient color of the ith light while im understanding Ca and Ga i dont understand excatly the sum. i will now write what I THINK about the last 3 variables. please correct me if im wrong or tell me if im right. 1) i think the sum is like a for-loop which iterates through all lights (spot, directional and point) in the scene. is this correct? 2) Atteni descripes the "power" of the light. if the vertex is out of the light range Atteni will be 0 for this light. this value is only used by spot and point lights. but what if ive got a directional light (the sun) in my scene? lets say that my third light is a directional light. does d3d then set Atten2 = 1? 3) Spoti is the "power" of the spotlight. this value is only used by spotlight. but again a similar question: what if light 2 is a point light? does d3d set Spoti = 1 for all non-spot lights? thanks for all answers!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by compiler
1) i think the sum is like a for-loop which iterates through all lights (spot, directional and point) in the scene. is this correct?

Yes, you are correct here. The "sum" is basically a 'for' loop that goes through all of your lights. Remember that if you have no lights at all, this value will be 0. Ambient lighting will still give you some kind of color even if you have 0 lights because the Ca and Ga terms do not depend on any lights at all.
Quote:
Original post by compiler
2) Atteni descripes the "power" of the light. if the vertex is out of the light range Atteni will be 0 for this light. this value is only used by spot and point lights. but what if ive got a directional light (the sun) in my scene? lets say that my third light is a directional light. does d3d then set Atten2 = 1?

Close. Attenuation describes the rate at which light diminishes as you get further away from the light source. It's not really the "power" of the light; its more like the "range" of the light. This value is used by positional lights, so that includes point and spot lights because those types of light have specific positions.
Quote:
Original post by compiler
3) Spoti is the "power" of the spotlight. this value is only used by spotlight. but again a similar question: what if light 2 is a point light? does d3d set Spoti = 1 for all non-spot lights?

The spot light factor is a term that determines if a point is within the circle of the spot light. Think of a flashlight and how it casts a cone shaped light onto a wall. The spot light factor is what determines if a point falls within that cone of light. If a point is on the outer edges of that cone, it might get less light than if it was right in the middle of the cone. The docs will tell you that for non-spotlights, this value is always 1.

Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites
thank your for your answer neneboricua19.
now i got it (at least most of it;)
just one last question: is it true that atteni is always 1 for directional light since they have no real range at all?

Share this post


Link to post
Share on other sites
Quote:
Original post by compiler
just one last question: is it true that atteni is always 1 for directional light since they have no real range at all?

Yes. Look at the section in the docs titled "Attenuation and Spotlight Factor" and it will tell you all of these details.

neneboricua

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!