🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Direct3D9 FFP Lighting

posted in IfThen Software
Published June 07, 2011
Advertisement
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/
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement