Orthographic camera and fog in URP?

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?

Nevermind, I kinda figured it out by isolating the fog rendering code from the standard URP lit shader and repurposing it. Outputting the fogCoord for testing purposes still gets me black objects everywhere, but if I do the following I get the fog effect that I want, for both perspective and orthographic cameras. So I’ll just call that a win and mark the topic as “resolved”.

New fragment shader:

float fogCoord = InitializeInputDataFog(float4(input.worldPos, 1.0), input.fogFactor);
outputColor.rgb = MixFog(outputColor.rgb, fogCoord);

The code from the vertex shader wasn’t changed.