#Render graph, blitter and stencil test

2 messages · Page 1 of 1 (latest)

hearty willow
#

I'm writing some Custom Render Passes. I want to use Blitter with source color texture, depth+stencil texture to write into destination color texture with a material that has custom shader. Custom shader has stencil test and because of that writes only to some pixels.

The most important thing is that because of the stencil test, only part of pixels on the destination color texture will be written, and so its important that other pixels from the original content of the destination, stay as they were. I tried to make it work for like literally several days, and it just wont.

I successfully write stencil values in one pass, I get the correct inputs in another, but I just cant make Blitter with material produce the correct output. Its either automatic clearing of the destination texture right before writing (with RasterPass), which loses pixels discarded by stencil test, or glitchy unexpected results like keeping values from previous frame in pixels discarded by stencil test, which at least leads to 'afterimage' glitch (with UnsafePass).

Has someone done this before or know working code example or can point the fundamental flaw in the idea or at least say ye that should be possible?

more info here:
https://discussions.unity.com/t/is-there-a-way-to-avoid-clearing-of-my-texture-on-blit-pass/1668413/6

radiant ginkgo
#

Some Blitter functions override the render target, which would unbind the depth-stencil buffer. Possibly only the BlitCameraTexture ones, while BlitTexture should work.
Alternatively could draw a triangle manually with cmd.DrawProcedural.
Also make sure the material used has the appropriate vertex shader (Vert from the Blit.hlsl include). e.g. https://www.cyanilux.com/faq/#fullscreen-shader