Hey, thanks for looking at this topic!
I recently updated a project to 5.5 and I noticed that a shader I’m building no longer works as intended, I think, due to the fact that the Z-Buffer near/far values have been reversed. I am using the z-buffer to create a ring of foam around objects sitting in water.
I’m using something similar to this shader by Chris Flynn.
Specifically this section,
//Get the distance to the camera from the depth buffer for this point
float sceneZ = LinearEyeDepth (tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)).r);
//Actual distance to the camera
float partZ = i.projPos.z;
//If the two are similar, then there is an object intersecting with our object
float diff = (abs(sceneZ - partZ)) / _HighlightThresholdMax;
if(diff <= 1)
{
finalColor = lerp(_HighlightColor, _RegularColor, float4(diff, diff, diff, diff));
}
However, with the depth buffer reversed, it’s doing the opposite, and rendering foam in the space closer to the camera. I’ve been messing with the values for quite a while without any real success. Can anyone give me advice on how to get the desired effect with the new 5.5 Depth Buffer?
The above is what I’m trying to accomplish, and below is what’s happening with the same code now, but with a much larger foam threshold.