Hi, I am moving a shader from the standard pipeline to LWRP and it is failing to work.
What the shader is supposed to do is render an invisible object in a render queue before all objects are rendered, but also write its depth to the buffer. This will make every object behind it invisible but will allow objects to render in front of it (from z testing).
Example of shader applied to cube (standard pipeline):
I don’t know what is happening here but if somebody with experience with ShaderLab and LWRP can explain why this is happening or how LWRP shader migrations are supposed to be handled, I would highly appreciate it.
For reference, here is the shader code I am using:
I’m not really sure how your shader would have worked before hand in the Game view. Since Unity 5.0 that should have only worked in the Scene view.
The scene view rendering works like this:
Skybox > Opaque Queues > Transparent Queues
The game view works like this:
Opaque Queues > Skybox > Transparent Queues
The skybox only renders where the depth buffer has not yet been written to, so anything that writes to the depth during the opaque queue range will block the skybox. The only way I can think your above example worked is if you were looking at it from the scene view, or all your objects’ materials were in the transparent queue… which is not the case since they’re receiving shadows. AFAIK in the LWRP the scene and game view now actually match behaviors, which also matches the built in rendering paths’ game view.
You are correct here, as I look deeper into this project that I worked on a while ago, I am noticing that the reason I am getting the images above is simply because of the fact that in LWRP, the scene and game view match behaviors. The “invisible” shader is something only seen in the scene view.
Here is a screenshot of the scene, camera preview, and the gameview:
What is was happening there was that I was rendering with another camera in another location which draws in that space where the color mask is 0. So I think the issue I have here has to do with the two cameras not rendering together as expected, not the shader and the fact that I can’t see the skybox anymore.
Thank you so much for mentioning this, it really helped a lot. I would not have noticed this.
Yep, LWRP doesn’t support multi-camera rendering. None of the SRPs do currently. If this is something you need, you’ll need to modifying the LWRP code to add support for it yourself, or stick to the built in rendering paths.