I want to create an effect where an opaque mesh blocking the camera will slowly fade from view. I want to make it automatic and never involve changing materials to transparent. Custom pass seems to be the way to go, but I have two problems:
- When I render opaque objects into a custom render target with their normal Lit opaque shader, they are rendered with weird seams, which seems to be due to lighting systems I do not fully understand.
Scene before custom pass:
Rendering objects (invisible to the camera due to them being on a non-renderable layer) into a custom render target:
(Arrows indicate seams-glitches, one can easily see the googles’ shape on the helmet even though the helmet is in front of the googles this whole time).
Here I must say that I’ve set up everything carefuly: I have a depth buffer connected to my color texture and models are rendered with ZTest set to LEqual. I also tried fiddling with rendererConfiguration flag group of RendererListDesc struct but it did not yield anything useful.
This problem can be solved by changing the material types of both objects to Transparent, but this is unacceptable to me as I don’t know how to make such a change at runtime and I don’t want to render every hideable mesh as a transparent object when they are not blocking the camera.
- The second issue is the fact that post processing somewhy does not apply to my models, when I subsequently blend them into the scene with a standard alpha-blend:
Meshes drawn normaly:
Now below, meshes never get rendered in a standard way but instead are alpha-blended into the scene from a custom render target:
even if we ignore the seams, which are quite noticeable in this screenshot, the colors of the objects do not match. My analysis of the frame with the Frame Debugger show that this is due to Post Processing not being applied to the meshes that are alphablended in.