Preventing fog from moving further away at edges of the viewport

At edge of the view, fog near is further away. For example, notice the characters become more visible when I look around and they are near the edge of the viewport:

In reality, when we rotate our heads, fog doesn’t move away.

Seems like the distance calculation needs to start from the position of the camera.

1 Like

Something like this?
THREE.ShaderChunk.fog_vertex = "#ifdef USE_FOG\n\tvFogDepth = length( mvPosition );\n#endif";


Huh… If it’s that easy, why isn’t this default behavior I wonder? :thinking:

Fog was once implemented like this: distance fog by greggman · Pull Request #14633 · mrdoob/three.js · GitHub

But this change had to be reverted because of issues on certain mobile devices: Reverted distance fog. See #14736 and #14786. · mrdoob/three.js@63f6d20 · GitHub

After a year another PR tried to implement the feature: Fix fog to use view distance by supereggbert · Pull Request #17316 · mrdoob/three.js · GitHub


There’s also this PR: