• Advertisement
Sign in to follow this  

about Lights.

This topic is 4928 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.. the source below is from famous site 32bits.co.uk // Set up the level of ambient light in the scene g_pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255,255,255)); // Uncomment this for specular highlights g_pDevice->SetRenderState(D3DRS_SPECULARENABLE, TRUE); // Set up our light D3DLIGHT9 Light; ZeroMemory(&Light, sizeof(D3DLIGHT9)); // Create a white, single direction light Light.Type=D3DLIGHT_DIRECTIONAL; Light.Diffuse.r=1.0f; Light.Diffuse.g=0.0f; Light.Diffuse.b=0.0f; Light.Position=D3DXVECTOR3( 3.0f, 2.0f, -3.0f); Light.Direction=D3DXVECTOR3(-0.5f,-1.0f, 1.0f); .... One thing weired is an Ambient color. I thought I was supposed to set it through vars in Light9 class, but the writer's using D3DRS_AMBIENT... in renderstate function. are there any difference between setting ambient lights in ligt VAR or renderstate function? What if there are lots of lights with differen ambient color? They are just mixed up? Now I guess it make sense to use renderstate for ambient color.... how come one light source has different types of light?? I'm totally lost... can anyone help me?

Share this post


Link to post
Share on other sites
Advertisement
based on my experiments..

They are mixed up... my bad ;>

...however

How come the directional light has a Diffuse color? Isn't it supposed to lit every where?

Direct x is smoking me... !

Share this post


Link to post
Share on other sites
Let's say you want to light your entire world, but you don't want to use lights for whatever reason. The Render State D3DRS_AMBIENT will only adjust the ambient "light" present in the entire scene. It's not really a light and doesn't use any lighting calculations. It's just the tone and brightness of the scene.

Now let's say you want to put a light in a room, toward the bottom, and you are 5 stories high in the dark looking down into the room. The light will not make it all the way up to where you are (because you've created it that way). You tell it to emit light of a red diffuse color and you tell it to emit light of a gray ambient color. The room's ambient color will be gray. Objects with red in them will look mostly red. Objects with no red in them will still be lit by a small amount because of the ambient light. However, the things around you 5 stories up will be unseen (because the RenderState D3DRS_AMBIENT value is 0 (I forgot to mention you set that before rendering)).

Hope this helps!

Chris

Share this post


Link to post
Share on other sites
hm.. OK. by setting renderstate with ambient I set the tone of the scene..

but When you saying about 5 stories building example , you mentioned that the ambient of light source won't reach the bottom. right? I think it's a point light.

cause directional light isn't get any effect by Range val in Light which means it won't die... it will reach the bottom.

Consequently there's no difference between ambient lighting by renderstate and ambient directional light...

and It is~!! I've just finished some experiment ;>
if that light is directional. no matter how long the ambient light is located from the object, the object will lit, and also the direction doensn't even matter.

well, it's still confusing that 'Directional light' reaches somewhere that light 'Can't Directly'


SDK.. frankly speaking I getting lazy.. you got the point thanks. SDK is programmers' friend. :>

Share this post


Link to post
Share on other sites
Yes, I assumed a point light. In the example, I kind of meant it as a light bulb in the room, which can only be realistically represented by a point light. Sorry for being unclear about that.

Directional light is not affected by range. That's correct. It's an infinite light source from infinitely far away that penetrates everything. :) It's a pretty cool little light if ya think about it!

It would be difficult to model a directional light inside a closed room, because of several reasons. It doesn't make sense for one. Secondly, if the direction of the light was not straight down, where would you define the plane that the light originates from? Also, anything above the light would be dark anyway, so why not just not draw any of it? Needless to say, directional lights are only really useful for outdoor scenes or if you have a skylight for a ceiling. Directional light is supposed to model a lightsource really far away.

You're right. As far as ambient goes, it doesn't matter which one you use. Ambient light is non-directional by nature. The direction that you specify for a directional light is used with the diffuse, specular, and emissive colors. You could ignore ambient with the directional light and set the ambient render state. That's up to you. You can't do that with a point light or spot light. You need to think about what you really want to do with them.

Chris

Share this post


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

  • Advertisement