Jump to content
  • Advertisement
  • entries
  • comments
  • views

Direct3D9 FFP Lighting

Sign in to follow this  


Today I finally managed to get the cockpit model into the game. I've decided to use the fixed function pipeline this time rather than shaders; it's probably a good idea to be experienced with both.

To use FFP (fixed function pipeline) lighting, you first need to fill in a D3DLIGHT9 structure. The elements are pretty straight-forward. I've found that you need values much greater than 1.0 for the light's color though; somewhere around 300 in R, G, and B for white lights is working well for the moment. After you have the structure filled out, pass it to IDirect3DDevice9::SetLight(). After setting the light information, you need to enable to light as well using IDirect3DDevice9::LightEnable().

To take full advantage of the lighting system, I recommend setting a material as well. To do this, fill out a D3DMATERIAL9 structure. The material describes what components of the incoming light are reflected, and by how much. It also describes how shiny a surface is with the Power element, and how much light the surface is emitting with the Emissive element. Note that the emissive element does not actually act as a D3D light; it only makes it seem like the material is glowing. After the material structure has been filled, pass it to IDirect3DDevice9::SetMaterial(). Now that the actual material is setup, we need to tell Direct3D that the diffuse and specular information is coming from the material and not the vertex buffer. To do this, set the D3DRS_DIFFUSEMATERIALSOURCE and D3DRS_SPECULARMATERIALSOURCE render states to D3DMCS_MATERIAL.

Reposted from http://invisiblegdev.blogspot.com/
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!