Jump to content
  • Advertisement
Sign in to follow this  
simotix

Multiple lighting passes in a shader

This topic is 3657 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 am trying to multiple lights through multipassing in a shader. I know my lighting is fine because when I do the first technique (OneLight) everything runs smoothly. For the second pass I thought all I had to do was enable blending and change the blending modes. Is this true? I also made sure my values in the second light was correct by sending in the index of on my first pass for the light. Here is what I do for my technique. Is this all that I need? (Well, I hope not because it just looks wrong with the blending).
technique OneLight
{
	pass pass0
	{
		VertexShader = compile vs_2_0 VS(0);
		PixelShader = compile ps_2_0 PS(0);
	}
}

technique TwoLight
{
	pass pass0
	{
		VertexShader = compile vs_2_0 VS(0);
		PixelShader = compile ps_2_0 PS(0);
	}
    
  	pass pass1
	{
        	AlphaBlendEnable = true;
		SrcBlend=srcalpha;
		DestBlend=invsrcColor;

		VertexShader = compile vs_2_0 VS(1);
		PixelShader = compile ps_2_0 PS(1);
	}
}

Share this post


Link to post
Share on other sites
Advertisement
You want additive blending, not alpha-based blending. Also, do you update your second pass's lighting parameters with the second light's data?

Share this post


Link to post
Share on other sites
I do set the second lights parameters correctly. How do I do additive blending? I do not see a render state to set. I have checked all the msdn hlsl docs

Share this post


Link to post
Share on other sites
I have tried doing what you said and I still get undesired results. I have tried it with AlphaBlendEnable = true and with it not on. Is this what you expect the code to be?


technique TwoLight
{
pass pass0
{
VertexShader = compile vs_2_0 VS(0);
PixelShader = compile ps_2_0 PS(0);
}

pass pass1
{
//AlphaBlendEnable = true;
SrcBlend=ONE;
DestBlend=ONE;
BlendOp = ADD;

VertexShader = compile vs_2_0 VS(1);
PixelShader = compile ps_2_0 PS(1);
}
}

Share this post


Link to post
Share on other sites
Well, posting a screen shot of what 1 light looks like as well as what 2 lights look like would help out, because right now "it doesn't look right" doesn't really ring a bell in anyone's head [grin]

Share this post


Link to post
Share on other sites
For some reason the light pass doesn't render the effect on the last plane. I render everything in this order.
- Set Technique For TwoLight
for(number of quads)
{
Set Matrix, ect information
for(number of passes)
{
BeginPass
Render
EndPass
}
}

That is how it is suppose to be right?

First Light:
http://www.4freeimagehost.com/show.php?i=6c427c1835da.jpg

Second Light:
http://www.4freeimagehost.com/show.php?i=af14fd6b470e.jpg

With The TwoLight Shader
http://www.4freeimagehost.com/show.php?i=9b68af08b84d.jpg


technique TwoLight
{
pass pass0
{
VertexShader = compile vs_2_0 VS(0);
PixelShader = compile ps_2_0 PS(0);
}

pass pass1
{
AlphaBlendEnable = true;
SrcBlend= ONE;
DestBlend=ONE;
BlendOp = ADD;

VertexShader = compile vs_2_0 VS(1);
PixelShader = compile ps_2_0 PS(1);
}
}

Share this post


Link to post
Share on other sites
Have you done anything weird with the ZFUNC? It should be LESSEQUAL on the first pass, and EQUAL on subsequent passes. I doubt a problem there would lead to those bizarre screenshots, tho.

Share this post


Link to post
Share on other sites
Well the first two screen shots are fine, it is when I mix them that I have a problem.

I did not do anything with ZFUNC and I did not know I had to change anything for blending on the first pass? Do I have to?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!