I’m trying to add fog to my shader, which will be used with an orthographic camera. Unfortunately, I’m not super familiar with how orthographic projections actually work. I’m using URP 12.1 and Unity 2021.3.
In my vertex shader, I do this:
VertexPositionInputs pos = GetVertexPositionInputs(input.position);
output.fogFactor = ComputeFogFactor(pos.positionCS.z);
In my fragment shader, I do this to test the output:
return float4(input.fogFactor, input.fogFactor, input.fogFactor, 1);
With a perspective camera, this works fine and I get the expected results. With an orthographic camera, I get a solid black color for all objects.
I’m wondering why this happens? I’ve tried digging through the source code of ComputeFogFactor and related methods, but I just got confused. Anyone here that can give me some pointers?