Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question HDRP fog that ends opaque

Discussion in 'High Definition Render Pipeline' started by alexandre-fiset, Nov 24, 2022.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    In our winter mystery game, we like that the view distance can be close while realistic. But the problem we have is that Unity's fog never really goes fully opaque, like the Linear Fog did in pre-SRP versions of Unity.

    This is the current look on the lowest graphics settings, see the distant trees. They never can be really invisible unless we disable their renderer, which is undesirable.

    Screenshot_24-44-2022-10-44-29.png

    But below is the mockup of the desired outcome. See the opaque fog, ambient-colored, hiding the trees. Being able to drastically reduce the view distance to something like that would be a godsend for lower end platforms.

    Screenshot_24-44-2022-10-44-29.jpg

    We really just need the fog to become "opaque" at some point, fading stuff into oblivion.

    Any pointer on how to achieve that?
     
    valarnur and nehvaleem like this.
  2. valarnur

    valarnur

    Joined:
    Apr 7, 2019
    Posts:
    438
    I was thinking to put another fog volume at distance with bigger density. But then I don't know how to move it as camera moves.
     
  3. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    Here are some settings that might help :
    - Raise the fog base and maximum height : The fog density decreases with the altitude between those two values.
    - Set the "Mip Fog Max" value to 0, to fully blend the skybox with the fog color

    Note that the attenuation distance is not the distance at which the fog is fully opaque, but where the fog "hides 63%" of what is seen. Physically speaking, there is no fog that fully blocks light.

    Here is a gif capture of my setup:
    FogSettings.gif
     
    chap-unity likes this.
  4. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    714
    I know but this is the thing, this is more about optimization than physical accuracy. It's nice to have Mip Fog Near, Far and Max though, but these unfortunately aren't in any LTS version of Unity. I assume it's on HDRP 14+?

    For Kona 1, built-in renderer, on Xbox One and PS4, we could have a 60m view distance. We used a linear fog which ended opaque, and it gave a nice result. Sometimes we wanted to see the sky, sometimes not, and Unity supported both ways. It's not accurate, but it works amazingly well.



    For Kona 2, now with HDRP, it's harder to do that as we can always see some geometries. It's accurate, but we see things pop out of view, which makes thing looks bugged on lower end platforms.



    But I guess our solution will be to have a plane that hides meshes behind it based on depth, or some kind of camera fade for our billboard trees.
     
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya and no near cutoff means that with how they implement this, near is always washed out. And tuning for one end impacts the other so nearly impossible to align to an artistic goal.
     
  6. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    695
    I did my example with Unity 2021.3 LTS (iirc). Try enabling the advanced parameters in the volume component.
     
  7. Wekthor

    Wekthor

    Joined:
    Apr 30, 2011
    Posts:
    164
    So is there no actual solution for distance based fog in HDRP? Like the one we had for years in built-in render pipeline.
     
  8. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,910
    We need linear fog. I can't even do a simple corridor with some fog (volumetric) at the end...
     
  9. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    745
    Linear fog has been talked about here for a while, but Unity has never shown any indication it will add it.
    https://forum.unity.com/threads/hdrp-linear-fog.1119646/

    My guess would be it isn't technically possible to use "unscientific" fog and have it react correctly with the rest of its "physically based lighting".

    No linear fog really sucks.
     
  10. Kabinet13

    Kabinet13

    Joined:
    Jun 13, 2019
    Posts:
    100
    It's pretty easy to set up some basic linear fog in shadergraph as a custom pass, but I do wish we just got it by default.