Sign in to follow this  

Sharing state between HLSL techniques

This topic is 2666 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 re-writing my lighting pass to take multiple lights per pass, but I need it to work on ps_2 without dynamic branching. So I was thinking pass in an int at compile time, and create a bunch of techniques for one light, two lights, etc.

The problem I have with this approach is that it quickly becomes unwieldy to manage 8 techniques that are identical apart from a single int parameter. This could be alleviated to some degree by being able to share the render state blocks easily. Does anyone know how to do this? Or maybe other ideas on how to implement this?

I did try using a run-time int parameter to the shader but got a compile error related to running out of shader registers. I guess it unrolled the loop too far.


Technique PointLight_1
{
pass Pass0
{
// only write pixel if it passes the test
StencilEnable = true;
StencilMask = 0x1;
StencilRef = 0x1;
StencilPass = KEEP;
StencilFunc = EQUAL;

AlphaBlendEnable = TRUE;
BlendOp = ADD;
SrcBlend = ONE;
DestBlend = ONE;

VertexShader = compile vs_2_0 vs_light();
PixelShader = compile ps_2_0 ps_light( 1 );
}
}
Technique PointLight_2
{
pass Pass0
{
// only write pixel if it passes the test
StencilEnable = true;
StencilMask = 0x1;
StencilRef = 0x1;
StencilPass = KEEP;
StencilFunc = EQUAL;

AlphaBlendEnable = TRUE;
BlendOp = ADD;
SrcBlend = ONE;
DestBlend = ONE;

VertexShader = compile vs_2_0 vs_light();
PixelShader = compile ps_2_0 ps_light( 2 );
}
}
// etc etc

Share this post


Link to post
Share on other sites

This topic is 2666 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this