Jump to content
  • Advertisement
Sign in to follow this  
steg

Lighting

This topic is 5455 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, I was wondering, if you have a game with various objects such as spaceships, planets, space stations would each of these objects have its own lighting ? I take it we are limited to a maximum number of lights which I believe to be around 8. If for instance I had a directional light on the planets and say a point light on spaceship would I need to call the SetLight method each frame or just the once for each light, for example :
pDevice->SetLight( 0, &light1 );
pDevice->SetLight( 1, &light2 );
pDevice->LightEnable( 0, true );
pDevice->LightEnable( 1, true );

Could I just do the above on initialisation of the game ? Any help is much appreciated. Steve

Share this post


Link to post
Share on other sites
Advertisement
If you write the rendering code and are guarenteed that no lights will ever be disabled, then you can just initialize the lights and leave them I believe. I don't think that is a state that has to be re-established each frame, but I'm not sure. It's no matter though. DirectX will cache the states. If you turned the light on and it's already on, it will know that and ignore your request to turn it on again.

To answer your first question, when you call DrawPrimitive or DrawSubset or however you get your vertices to the video card, whatever light is enabled right then will be used to light the vertices being committed to the video card. So, if you want a spotlight on a spaceship only, then you'll need to enable it before drawing the spaceship and disable it after. You could batch lighting calls, but I don't think their state changes are significant enough to warrant that. Anyone know?

Also don't forget these meshes require a material and normals for lighting to work.

Good luck,
Chris

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!