URP - Fog end and camera far plane relationship

I am using linear fog. The fog color matches the clear color of the camera and it looks good. I do however see some occasional weirdness where the far clip plane is cutting an object in half which means that the fog depth isn’t being calculated correctly.

I was under the impression that the fog end must match the far clip plane of the camera. This makes sense that the fragment color is an interpolation between the fragment color and the fog color given the depth. But I am seeing visual oddities.

The trees are being visibly cut meaning that the depth calculation appears to be off somehow. I am using a custom shader, but I see the same issue with the SimpleLit shader.

I know I can simply increase the far plane or decrease the fog distance, but I shouldn’t have to. They should not produce this visual issue, unless my understanding of the math is wrong. And I am emulating an old game engine so this needs to be as accurate as possible.

Thanks!

Bump. This seems to be a bug. Linear fog in URP is per vertex.

This would be by design. Fog is calculated simply based on the provided depth (independent of far plane) and remapping factors. If this wasn’t the case then the fog distances wouldn’t make sense from a UX standpoint, as the distances would no longer have a fixed grounding. From memory, I’ve even seen a few games that have this exact thing - where the clip plane is visible through fog.