Skip to content

Distance based fog? #14601

@greggman

Description

@greggman

Should fog be distance from camera instead of distance from camera's zplane?

Currently fog is just the z distance from the zplane of the camera. That means if you just turn the camera in place objects that are not really getting closer to the camera come out of the fog. That doesn't seem correct (although maybe it's intentional?)

Here's 6 cubes in a circle around the camera. The camera is spinning in place. you can see the cubes come out of the fog even though they are not actually closer to the camera

http://jsfiddle.net/greggman/Lx3mhvbe/

Changing the fog from this

fogDepth = -mvPosition.z;

to this

fogDepth = length(mvPosition);

Seem like it might work?

Example: https://fog-fix.glitch.me/

Not sure it's correct but the objects are no long coming out of the fog

Three.js version
  • Dev
  • r94

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions