Working on a project that shares the final image of the unity renderer via Spout as a transparent texture (with a seperate depth texture) into a different enviroment, where it gets used as an augmented reality layer on top of an image feed.
My current problem is, that i’m using a simple depth mask shader:
Shader "Custom/DepthOnly" {
SubShader {
Tags {
"Queue" = "Geometry-10"
}
Fog { Mode Off }
Pass {
Tags { "LightMode" = "Deferred" } // otherwise does not work in deferred path
Lighting Off
Cull Back
ZWrite On
ColorMask 0
}
}
}
that uses the depth buffer to cut hole for a real object (on the image feed). It nearly works but since that shader is at queue position 1990, unity defaults to write alpha 1 into the alpha buffer which results into a rendertexture that shows the clear color/skybox of the camera.
Does anyone here know a way to force that opaque shader to write or even overwrite the alpha buffer with zeros? Or maybe a different way by using a commandbuffer?
EDIT: also adding a fragment shader that writes 0 into the alpha channel does not seem to work. Seems like Unity defaults to fully opaque depending on the render queue position…