Sign in to follow this  
danromeo

Pixel Shader 3.0 unexpected results

Recommended Posts

danromeo    238
Just when I think I understand shaders they throw me a curveball every time.

This seems SO simple. I have a Vector 3:
pos=new Vector3(1024,1024,1024);
and a shader constant float3 EyePosition
I assign my Vector3 to my shader constant just before the draw call:
[font="Consolas"][size="2"][font="Consolas"][size="2"]Effect.Parameters[[/size][/font][/size][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"EyePosition"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]].SetValue(pos);[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]This variable is not used or altered anyplace else, in either the program or in the shader.[/size][/font][/size][/font]
[font="Consolas"][size="2"][font="Consolas"][size="2"]BUT, when I debug the pixel shader in PIX it shows EyePosition= (414.855, 823.112, 1024.000, 0.000);[/size][/font][/size][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]Can somebody please explain to me WHY (tF!) my constant is getting changed? Is the interpolater being invoked for some reason? I hate asking dumb questions but I can't see any logical explanation for this whatsoever.[/size][/font][/size][/font]

[font="Consolas"][size="2"][font="Consolas"][size="2"]Thanks[/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
Adam_42    3629
It is possible the compiler has optimized away the constant if you don't use it anywhere.

If you're still seeing the same results when it gets used and affects that shader output, it might be best to post a complete compilable shader so other people can try it for themselves.

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