Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HLSL : multi pass shader?

Tags:

shader

blur

hlsl

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 pass 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

like image 296
user714921 Avatar asked Feb 25 '23 11:02

user714921


1 Answers

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).

like image 92
Alexander Gessler Avatar answered Mar 02 '23 15:03

Alexander Gessler