Jump to content

Fog is closer at center of view


Recommended Posts

Hi,

I'm trying out the fog feature in a scene, and having trouble getting it behave in a way that makes sense visually.

The trouble is, linear fog is much stronger in the center of the viewport than at the edges. E.g in this demo - at first you should see a certain number of cubes directly in front of the camera, but if you rotate the camera you'll be able to see a further cube that wasn't visible initially.

I assume this happens because fog distance is being calculated as distance from the camera along the camera vector, rather than just distance from the camera.

Is this a bug, or a feature, or something that can be worked around? Thanks!

Link to post
Share on other sites

It is not a physical fog but a distance fog.

Distance is computed here:

https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/ShadersInclude/fogVertex.fx

As you can see the distance if from the vertex to the camera (on z axis). 

 

It is fairly easy to change it to len( (view * worldPos) ) which, I agree, makes more sense

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...