开发者

HLSL : multi pass shader?

I'm writing a shader that make a blur effect on a texture rendered form the scene. I need to do that in 2 passe, so with the pass P0 i make a horizontal blur, and in pass P1 the vertical one.

The problem is:

  • How i can get the output from the PS on pass P0 and send as input on the PS on pass P1 ?

If i write it on single pa开发者_StackOverflowss i obtain the expected result, but i really need to do in 2 passes.

Can anyone help me please?

Is my first approach toe HLSL.

Thank to everyone!

FOX_ITA


You usually do that outside of the shader code in your application logic.

  • Get a render target/renderable texture large enough to hold the result of P0
  • Enable the target, enable P0, run the first pass
  • Get another render target to hold the result of P1. If you're doing a fullscreen blur and no further postprocessing is needed, this will typically be the backbuffer.
  • Enable the new render target
  • Bind the first render target to a texture index/slot accessible to P1
  • Do the second pass

(of course you don't re-create the render targets once per frame. I'd rather use a central pool of render targets to serve all postprocessing needs).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜