Sign in to follow this  

fx effect files question (scripting?)

This topic is 4715 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

Hi, it seems to be allowed to do math on parameters passed to shaders like this:
float4 lightDir : Direction
<
	string Object = "DirectionalLight";
    string Space = "Wolrd";
> = {1.0f, -1.0f, 1.0f, 0.0f};

float4x4 worldInverse : WORLDINVERSE;

...

technique t1
{
    pass p0
    {
        VertexShader = compile vs_1_1 
         VS_test(normalize(mul(float4(-lightDir.xyz,0),worldInverse)));
    }
}
Is it somehow possible to define variables inside a pass oder a technique? I need to store temporary variables because I want to pass several parameters to the shader that are computed from each other. For example the 2nd parameter's calculation is based on the 1st that is computed from several global variables.

Share this post


Link to post
Share on other sites
Quote:
Original post by muhkuh
Is it somehow possible to define variables inside a pass oder a technique? I need to store temporary variables because I want to pass several parameters to the shader that are computed from each other. For example the 2nd parameter's calculation is based on the 1st that is computed from several global variables.

Could you perform these calculations in your "VS_test" function? You can pass to your function as many parameters as you want and perform your calculations there.

neneboricua

Share this post


Link to post
Share on other sites
Quote:
Original post by neneboricua19
Quote:
Original post by muhkuh
Is it somehow possible to define variables inside a pass oder a technique? I need to store temporary variables because I want to pass several parameters to the shader that are computed from each other. For example the 2nd parameter's calculation is based on the 1st that is computed from several global variables.

Could you perform these calculations in your "VS_test" function? You can pass to your function as many parameters as you want and perform your calculations there.

neneboricua


Of course I could but that is something I want to avoid. Why calculate something per vertex when it is constant per object?

Share this post


Link to post
Share on other sites
Quote:
Original post by muhkuh
Of course I could but that is something I want to avoid. Why calculate something per vertex when it is constant per object?

True. Got a little mixed up about what you were asking.

If the calculation is per object, then the best thing to do would be to have your application perform the calculation and pass this data to the vertex shader as a constant variable.

neneboricua

Share this post


Link to post
Share on other sites

This topic is 4715 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