[HLSL] Passing data between Shader passes

Started by
3 comments, last by karwosts 13 years, 1 month ago
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
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.
Why do you think render targets cannot apply? You can always add an additional render target in addition to whatever else you're rendering.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
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
Well like Eric said, unfortunately it's your only option :(
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

This topic is closed to new replies.

Advertisement