Archived

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

Mark Duffill

Lighting Problems, Additive Dynamic Lights

Recommended Posts

Lighting Problems. What I require is the following:- RGB = (VertexRGB * GlobalAmbientRGB) + (MaterialDiffuseRGB * Lights[n]) A = (VertexA * MaterialDiffuseA); or RGB = (VertexRGB * GlobalAmbientRGB) + (1 * Lights[n]) A = (VertexA * MaterialDiffuseA); [Note: Texture RGBA are just modulated into this] So the vertex colour is modulated with the global ambient colour. Then the dynamic lights are added in on top. The Alpha component is modulated with either the MaterialDiffuse.Alpha or the TFactor.Alpha; The purpose is so you can have additive lights (which to my mind is the correct light model), example: Black poly with white texture will appear black until a dynamic light is effecting it. The closest I can get is the following:
      
	DXDisplay->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	DXDisplay->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE2X );
	DXDisplay->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

	DXDisplay->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	DXDisplay->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE  );
	DXDisplay->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

	DXDisplay->SetRenderState( D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR1 );
	DXDisplay->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL );
      
All works fine and dandy except the VertexA is lost due to the diffuse comming from the material, not the vertex. However if I do :- DXDisplay->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1 ); I get my VertexA, (= VertexA * TFactorA), but loose the additive lights.ie Black Poly with white texture remains black when a dynamic light affects it. Any ideas other than a vertex shader? Or simply can you have a vertex alpha which would be a bit pants! (Shame global alpha cant come from ambient material ;( [The views stated herein do not necessarily represent the view of the company Eurocom ] Eurocom Entertainment Software www.Eurocom.co.uk The Jackal [edited by - mark duffill on June 10, 2002 12:08:03 PM]

Share this post


Link to post
Share on other sites