Jump to content
  • Advertisement
Sign in to follow this  
danromeo

Pixel Shader 3.0 unexpected results

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

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[[/font][/font][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"][font="Consolas"][size="2"][color="#a31515"]"EyePosition"[/font][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]].SetValue(pos);[/font][/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.[/font][/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);[/font][/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.[/font][/font]

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

Share this post


Link to post
Share on other sites
Advertisement
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
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!