Archived

This topic is now archived and is closed to further replies.

Merick

Vertex Shaders / D3D Lighting confusion

Recommended Posts

Maybe im not understanding some things, but i''ve seen alot of code for vertex shaders and i see a line in their code that looks like this. // Turn off D3D Lighting, since we are providing our own vertex shader lighting m_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); I''m a bit confused, isn''t D3D Lighting done as part of the fixed function pipeline that vertexs go through?? Which means that if we replace the fixed function pipeline doesn''t that replace the lighting calculations too? So why do we need to turn anything off if it wont be used anyways? If lighting isn''t appart of the fixed function pipeline ... does that mean i could use all the SetLight(...) and EnableLight(...) functions with a vertex shader which doesn''t provide its own lighting calcuations?

Share this post


Link to post
Share on other sites
quote:
Which means that if we replace the fixed function pipeline doesn''t that replace the lighting calculations too?


Correct.


quote:
So why do we need to turn anything off if it wont be used anyways?


Paranoia - some people don''t trust driver writers or MS

Completeness - it feels right to be explicit. I''d agree actually, it''s not going to hurt to turn the lighting off. And it''s a nice safety net just in case someone down the line between you and the graphics chip did happen to get it wrong.

The only thing I''d say you NEED to set from the fixed function pipe when using shaders would be the clipping renderstate, the projection matrix and the viewport. The world and view matrices and all lighting will indeed not be used when your shader is enabled.



quote:
If lighting isn''t appart of the fixed function pipeline ... does that mean i could use all the SetLight(...) and EnableLight(...) functions with a vertex shader which doesn''t provide its own lighting calcuations?


As should be clear from above. Nope.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites