I have a pretty simple question about the ZTest instruction in ShaderLab. According to the Documentation the only valid parameters are { Less | Greater | LEqual | GEqual | Equal | NotEqual | Always } - however, I found that “Never” also works and leads to the shader never being rendered.
What I’m looking for is a setting that would only render the shader if at the current fragment position nothing has been written to the depth buffer (something like “ZTest Less [some constant]”). Is this possible and if not is there a reason for its absence?
This sadly won’t work in my scenario, but in this specific case it’s not really an issue and I’ll get over it. I was mainly interested in the details of this limitation, so thanks for clearing this up for me.
How does Unity’s skybox work? It renders after solid geometry for all pixels with “initial” depth.
The only way I can think of would be rendering it at the far clipping plane which would work for a cubemapped skybox, however not for the regular one.
I want to use a skybox for my second render pass where the depth of the first pass should be utilized.
one of the possible tricks (though you will need to setup stuff yourself) is to tweak proj matrix
search google for “eric lengyel infinite projection” (the pdf in question should be among first results)
Haha, I found exactly this paper during my own research. Thanks to Alexey I gave it another go, so here it is - a little script to set up an infinite projection matrix (Rendering is not clipped beyond far plane) - just add script to camera: