Jump to content
  • Advertisement
Sign in to follow this  
jujumbura

ambient light on a light source?!

This topic is 4846 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

Hullo hullo again good people! Today I have a question about lighting. I noticed that a D3DLight9 structure has an ambient color member. Now, to my understanding, ambient light is the light in the scene that has nothing to do with proximity or direction relative to a light source. It's the light that just always "exists". So then, why would you specify it in a light source? It certainly makes sense to have an ambient member in the materials structure, but why have it in the light source? Does the ambient value from the light source affect the ambient value in the material at all? Do they cancel out/add/limit one another? Thanks for any help with my latest conundrum. Mike

Share this post


Link to post
Share on other sites
Advertisement
Check the documentation page: DirectX Graphics -> Programming Guide -> Getting Started -> Lights and Materials -> Mathematics of Lighting -> Ambient Lighting.

Ambient Lighting = Ca*[Ga + sum(Atti*Spoti*Lai)]

Parameter Default value Type Description 
Ca (0,0,0,0) D3DCOLORVALUE Material ambient color
Ga (0,0,0,0) D3DCOLORVALUE Global ambient color
Atteni (0,0,0,0) D3DCOLORVALUE Light attenuation of the ith light. See Attenuation and Spotlight Factor.
Spoti (0,0,0,0) D3DVECTOR Spotlight factor of the ith light. See Attenuation and Spotlight Factor.
sum N/A N/A Sum of the ambient light
Lai (0,0,0,0) D3DVECTOR Light ambient color of the ith light

Share this post


Link to post
Share on other sites
They put it on a light so you can turn it on and off if you want and change its color -- just like any other type of light.

The ambient color in a material is different than an ambient light. Just like the diffuse and specular colors, it is combined with the color of the corresponding light component to get the displayed color. Generally, the ambient and diffuse material colors are the same, and specular material color is white, but it doesn't have to be that way.

Share this post


Link to post
Share on other sites
Quote:
Now, to my understanding, ambient light is the light in the scene that has nothing to do with proximity or direction relative to a light source. It's the light that just always "exists". So then, why would you specify it in a light source?


Ambient light simulates light that bounces around your scene, so it can come from any direction when it hits a surface, but its always originating from your lightsource. To understand why this is so just imagine a room with two colored lightsources with different intensities - Say a very bright yellow light and a dim blue light. The yellow light will have a higher ambient property and make more of a contribution to the lighting in the room.

Share this post


Link to post
Share on other sites
Nevermind, I found it. Didn't know you meant MSDN.

So I read through their terms and that formula. Here's what I don't get though:
"It lights all object vertices the same because it is not dependent on any other lighting factors such as vertex normals, light direction, light position, range, or attenuation. "

That's what they say about ambient light in the scene. Yet, the ambient light color value is getting multiplied by the attenuation factor and the spotlight factor. It sure sounds like being dependent on light range and attenuation to me. I understand that the global and material ambient coefficients are NOT affected by these parameters however.

Perhaps a better definition is: ambient light from a light source is like diffuse, but not dependent on the normal of the surface you are lighting. Would that be right?

Mike

Share this post


Link to post
Share on other sites
1. "The documentation" typically refers to the MSDN documentation, and you should have it as a CHM if you choose so during the SDK installation [smile]

2. I've never tried to use the ambient factor of D3DLIGHT9, but my guess is that the attenuation and spotlight factor part is a documentation bug.

Share this post


Link to post
Share on other sites
You know what, I bet it's not an error. I bet the error is lumping all ambient light in a "not dependent on range/attenuation" bucket.

Ambient light used in this way could give a really nice, eery effect. Say your scene has a pretty low global coefficient for ambient light. You're stumbling around in the dark, then you find this room with a weak, dangling light bulb. As a light source, this might have a very low diffuse component, a nonexistant specular component, but a medium ambient component in some gross color, painting everything near it.

I'm almost POSITIVE that exceeding the range of a light will still kill the ambient coefficient, otherwise it would effectively just add to the global ambient value. As for attenuation and spotlight, I'm GUESSING that they factor in as specified. You might be right, but I'll have to play around with it to be sure =)

Mike

Share this post


Link to post
Share on other sites
Quote:
Original post by Michael Kron
I'm almost POSITIVE that exceeding the range of a light will still kill the ambient coefficient, otherwise it would effectively just add to the global ambient value. As for attenuation and spotlight, I'm GUESSING that they factor in as specified. You might be right, but I'll have to play around with it to be sure =)

Cool, post your results when you do, eh? [smile]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!