Archived

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

Multiple lights

This topic is 4943 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

I''m implementing some vertex shaders to light my scene (like a vs for directional light, one for point light and on for spot). I calculate which light lights which object and then, at render time I''ll do a pass for each light. The problem is that I should blend the various render passes, so I added this lines (which seem not to work): D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); Where''s the error? If I use this, I see only the last light... Thanks nICO

Share this post


Link to post
Share on other sites
1) Is the geometry identical for each of the render passes?

a. if so, is your depth buffer comparison function (D3DRS_ZFUNC) set to anything other than D3DCMP_LESSEQUAL, D3DCMP_EQUAL or D3DCMP_ALWAYS ?

b. my first guess (you didn''t really provide enough information to do anything other than make guesses) is that all passes after the first one are being rejected by the Z buffer test.

c. Try experimenting the comparison function - if each pass has a different shader, there is a chance that the resultant Z value for each pixel is ever so slightly different (floating point error etc).


2) Do you have any other pixel rejection tests such as alpha-test, stencil buffers or user clip planes enabled? If so double check their impact on multiple passes of the same geometry.


3) Just in case there''s a problem with one of the shaders, your pass logic or some other D3D state, it''s worth testing each pass separately to make sure each actually outputs something other than black!


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
quote:
Original post by S1CA
1) Is the geometry identical for each of the render passes?

a. if so, is your depth buffer comparison function (D3DRS_ZFUNC) set to anything other than D3DCMP_LESSEQUAL, D3DCMP_EQUAL or D3DCMP_ALWAYS ?

b. my first guess (you didn''t really provide enough information to do anything other than make guesses) is that all passes after the first one are being rejected by the Z buffer test.

c. Try experimenting the comparison function - if each pass has a different shader, there is a chance that the resultant Z value for each pixel is ever so slightly different (floating point error etc).


2) Do you have any other pixel rejection tests such as alpha-test, stencil buffers or user clip planes enabled? If so double check their impact on multiple passes of the same geometry.


3) Just in case there''s a problem with one of the shaders, your pass logic or some other D3D state, it''s worth testing each pass separately to make sure each actually outputs something other than black!


Simon O''Connor
Game Programmer &
Microsoft DirectX MVP


Dear Mr.O''Connor,

I want to contact you.
Could you tell me your email address?


Sungkwan Park
My Email : skpark@softweb.co.kr
My MSN Messenger : sungkwanpark@hotmail.com
My Phone : +82-11-256-9917

Share this post


Link to post
Share on other sites