Jump to content
  • Advertisement
Sign in to follow this  
JohnnyCode

write to an uniform variable in shader

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

hello,

I have a question wheather it is posible to write to an HLSL uniform variable, or they are only readonly. I am using dx9 and pixel shader target 3.0. Thanks

Share this post


Link to post
Share on other sites
Advertisement
No it is not possible. if you want to pass a variable from vertex shader to the pixel shader store in the vertex shader output and read it in the pixel shader input

Share this post


Link to post
Share on other sites
Thanks. My intention is to detect wheather the pixel function has been run, and I do not want to lock the render target. Is there no way to output from pixel function somewhere else but render target? Maybe if I declared the uniform with some different semantic...

Share this post


Link to post
Share on other sites
No, in ps_3_0 your only output is the render target. For more options you would need ps_5_0 + DX11.

Share this post


Link to post
Share on other sites
Uniforms are named as such because they're constant values over all the vertices and pixels that are being processed when you make a draw call, so the name very much implies the meaning. Another way to think about it is, a pixel shader can run for hundreds and thousands of times...how can each of those write data to a single variable in a meaningful way? That's what render targets are for!

I don't know what sort of problem you're trying to solve, but if you're drawing something to a texture and want to make sure its working, why not run PIX? You can view resources and the results of draw calls to ensure things are working.

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!