Jump to content
  • Advertisement
Sign in to follow this  
hl1202

[HLSL] Passing data between Shader passes

This topic is 2839 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 all, again we meet!

I have a problem right now about Passing data between pixels Shaders

I have:

- float4 X1
- 1 technique with 2 passes
- In pass 1, the Pixel Shader make some change to X1. For example X1 = X1 + float4(0,1,0,1);
- I have pass 2, which needs to use the NEW value of X1

I simply declare X1 as a Global Variable and then apply the change in pass 1. Then in pass 2, i just call X1 again with expectation of getting the new value. However, it doesn't seem to give out the correct result.

So, is there other ways?

Ps:
- I know about render target. In pass 1, render new X1 to a texture. And then in pass 2, read from this texture
- Render target cannot apply to what i'm doing now. So, i need another method

Share this post


Link to post
Share on other sites
Advertisement
There is no other method, pixel shaders write to render targets.
You can use compute shaders if you have shader model 5.0. Maybe you can do the same in pixel shaders with unordered access views, but still requires shader model 5.0, but it's basically the same thing, you always write to a target or some type, not to global variables. The pixel shaders execute in parallel, so you would need one global per pixel anyway, which is exactly a render target.

Share this post


Link to post
Share on other sites
Why do you think render targets cannot apply? You can always add an additional render target in addition to whatever else you're rendering.

Share this post


Link to post
Share on other sites
Actually my work is too heavy now to afford more tasks like Render Target. That's why i need another method.

Need more research or else there's no option

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!