From what I can see the render feature passes are drawn in addition to the regular camera rendering pass of any layers that pass the filter on the render feature. Is there any way to disable the original render pass?
Essentially I’m trying to overwrite the stencil settings of most things that are drawn on the screen to do some stencil masking. The actual masking pass is fine, it’s just mask objects that draw with ColorMask 0 and ZWrite Off, writing a certain value to the stencil buffer. Then I want to render other objects with certain stencil ref values to have them only appear inside masked areas.
In the frame debugger this works fine, except all the objects are drawn a second time with their regular material and stencil settings and just overwrite whatever happened before.
I may not be understanding correctly but in the original render pass in the filtering for opaque layer mask and transparent layer mask just set the layers to nothing.
@Bosozuki
big edit: Oh, you were talking about the separate settings of the custom renderer. Thanks, I’ll play around with that.
It seems to be almost working mostly except in the final blit that happens when I look at the frame debugger, the correctly rendered stuff disappears.
Here, I’m drawing a small quad as the stencil mask and then there’s a white plane behind which is correctly only drawn where the stencil mask was rendered.
But shortly before the frame ends there seems to be some blit pass or another draw of some sort that doesn’t transfer the results to the framebuffer that eventually ends up on screen, or draws on top of it:
It looks correct in the little preview window of the camera itself, and also in the game window before I press play. Turns blank (only skybox visible) on play though.
edit: This seems to be VR related, the shader that’s used in that GL draw that seems to delete everything is Hidden/VR/BlitTexArraySlice. I randomly copied the project folder and tried it out in the latest stable unity release (2020.something something) but there absolutely nothing gets rendered instead, even in the frame debugger entries for the render objects passes
hmm…
three things
First, I never trust the preview window or the scene view with render feature passes. Sometimes the render passes work in those windows other times they do not but playmode and a build of the game always works.
Second and more important bit and one caveat
The caveat in the overrides, I have not experimented with the stencil buffer as much, I use the depth for all of our effects.
For giggles I would try setting the depth buffer, along with the option that appears write to depth and maybe play with those less than equal settings. I use those setting a lot for setting the render order to be correct. Usually if I need ordering I have two render passes for instance
OpaqueFirst
Layer = to what ever you want render
Depth = true
Wirte = true
Depth test = Greater Equal
OpaqueSecond
Layer = to what ever you want render
Depth = true
Wirte = true
Depth test = Less Equal
Also I will have two more render passes for transparent objects with the same settings.
Even though you are writing to the frame buffer already and should not have to do that but may be worth a try.
Third, the real problem is that render passes are still experimental and not documented as well AND they work differently between unity, package versions (this bit me), and hardware platforms. Personally I think they are a great feature and under used.
After working on this some more, this just seems to be a generic VR bug (possibly because of the SteamVR plugin version I’m using) with stencil and depth buffers (I’m using Unity 2019.4.9f1, but it’s the same in the latest available stable release, 2021.something).
I implemented the alternative where I actually went through existing materials and shaders and added stencil support. But even that method doesn’t work, once again it works up until the last render which then undoes everything.
Same with simple depth masking - doesn’t show up / is ignored in VR.
I suspect there’s a setting somewhere to add proper depth and stencil format to VR but I can’t access it with the XR Management OpenVR/Steam Plugin.
edit: Also doesn’t work in latest SteamVR plugin version