Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Shader Graph - How to interpret the Fog Node's density value?

Discussion in 'Graphics Experimental Previews' started by Pelican_7, Oct 11, 2018.

  1. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    Hi all,

    I'm trying to add fog in an unlit shader graph but can't work out how to interpret the Fog Node's density value. The documentation states that the density value is in clip space, so I assumed it would be relative to the camera's clipping planes? Is this incorrect?

    For example, if I create a simple unlit graph that writes fog density directly to the color output...

    Capture.PNG

    ... and create a simple scene...

    Capture2.PNG

    ...If I move the cubes, the shader behaves in reverse to how I expected - they get darker (the fog density gets less) as they get further away.

    Capture3.PNG

    And if I move the camera instead, nothing happens to the fog density value at all (cubes are colored the same as in the first image).

    Capture4.PNG

    So I feel I'm clearly misunderstanding how this value is to be used. Any help is much appreciated!

    Thanks.
    -andy.
     
    Tsutomu_Abe likes this.
  2. StenCG

    StenCG

    Joined:
    Mar 26, 2015
    Posts:
    66
    Try
     

    Attached Files:

    • fog.png
      fog.png
      File size:
      39.4 KB
      Views:
      4,837
    Typhonite and Vacummus like this.
  3. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    Thanks @Stanislawe. From your screenshot it looks like the Fog node now has an input – Position – so I'm expecting we can now feed the world position into the node to get world space fog.
     
  4. rthom

    rthom

    Joined:
    Feb 13, 2018
    Posts:
    3
    Last edited: Feb 13, 2020
    jq911 and jjbish like this.
  5. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484