fx effect files question (scripting?)

Started by
2 comments, last by neneboricua19 19 years, 3 months ago
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.
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
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?
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

This topic is closed to new replies.

Advertisement