I'm attempting to write a ray-tracing based shader where for each pixel of a quad I calculate the origin and direction of the ray from the camera and test for intersection with my scene (currently a sphere).
If intersection occurs I want to set the depth buffer value to the depth of the intersection rather than leave it as the depth of the quad, so I'm writing to DEPTH. I'm aware this means that early z-culling for my pixel shader will be disabled as it can't be determined if my pixel will be infront or behind until it has completed for that pixel.
However, one property of my shader is that the depth will always be deeper than the one that would be used for early z-culling, and therefore it is still valid to perform early z-culling as something that is in front of the quad is guaranteed to be in front of what the ray intersects. I vaguely remember there being some way to inform the rendering pipeline that although the depth was being modified, it would always be modified to deeper, and this would leave suitable optimisations, that would otherwise be turned off, on. I've not been able to find what this was though despite a lot of Googling, does anyone know what it is? If this doesn't actually exist and I'm mis-remembering, is there a way of forcing early z-culling to be enabled even in use cases like mine?