Search Unity

  1. Curious about what's going to be in 2020.1? Have a look at the 2020.1 beta blog post.
    Dismiss Notice
  2. Want to see 2020.1b in action? Sign up for our Beta 2020.1 Overview Webinar on April 20th for a live presentation from our evangelists and a Q&A session with guests from R&D.
    Dismiss Notice
  3. Interested in giving us feedback? Join our online research interviews on a broad range of topics and share your insights with us.
    Dismiss Notice
  4. New Unity Live Help updates. Check them out here!

    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:
    189
    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. Stanislawe

    Stanislawe

    Joined:
    Mar 26, 2015
    Posts:
    34
    Try
     

    Attached Files:

    • fog.png
      fog.png
      File size:
      39.4 KB
      Views:
      1,727
  3. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    189
    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:
    2
    Last edited: Feb 13, 2020
unityunity