Search Unity

volumetric fog shader

Discussion in 'Shaders' started by dirk_z, Dec 18, 2019.

  1. dirk_z

    dirk_z

    Joined:
    Jun 3, 2018
    Posts:
    4
    Hi, i'm working on a volumetric fog shader.
    i'm creating this shader with Shader Graph.

    The problem is that the shader is not volumetric. It's only on the sides.
    So when you look from the top the fog has the transparency of the top side, and same on the bottom.

    The problem:
    fogexample.PNG
    My node setup:
    fognodes.PNG

    Thank you.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    First, Shader Graph forum is this way -> https://forum.unity.com/forums/shader-graph.346/

    Second: The position node gets you the world position of the mesh being rendered, not the position of the scene. You can get the scene depth, but you need to do more work (ie: math) to figure out the world position from that. Most fog shaders just do a depth comparison between the mesh's surface position and the scene depth behind it.

    Like this:
    https://twitter.com/Cyanilux/status/1174999494552952832/photo/1

    I'm not entirely sure what you're use case is, but the easiest solution may be to use a shader on your rocks with a height fog, like the nodes you already have are doing, but lerping the albedo to black and emissive to the fog color.