# Multiple lighting passes in a shader

This topic is 3827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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
{
}
}

technique TwoLight
{
pass pass0
{
}

pass pass1
{
AlphaBlendEnable = true;
SrcBlend=srcalpha;
DestBlend=invsrcColor;

}
}



##### Share on other sites
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 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 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 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 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
{
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

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 on other sites
I still have no idea how to do this, does anyone know how?

##### 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 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?

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633665
• Total Posts
3013245
×