Sign in to follow this  
wswqwps

How to share parameters between shaders

Recommended Posts

You mean you want to pass data to the shader using just a few variable that you will continually re-use. Or you want to pass data from one shader to another? Or are you trying to make things easier to read in your code without having a bunch of different named variables?

Share this post


Link to post
Share on other sites
Quote:
Original post by david w
You mean you want to pass data to the shader using just a few variable that you will continually re-use. Or you want to pass data from one shader to another? Or are you trying to make things easier to read in your code without having a bunch of different named variables?


The shader is like this:

//------------
//Shader.fx
//------------
int var_1 = 1;

float4 PS_main_1( ... )
{
some_calc( var_1 );
}

float4 PS_main_2( ... )
{
another_calc( var_1 );
}


I know the variable var_1 will be treated as two vars just have the same name and each pixel shader will have its own copy. Now I want to share var_1 between the two pixel shaders, for example, I can set the var_1 to 1 when used in PS_main_1 and then change it to 2 and use in PS_main_2. Thanks.

Share this post


Link to post
Share on other sites

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