Jump to content
  • Advertisement
Sign in to follow this  
muhkuh

fx effect files question (scripting?)

This topic is 5022 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!