Search Unity

HDR Fog

Discussion in 'Global Illumination' started by Marc-Saubion, Sep 20, 2018.

  1. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    Hi.

    I'm working on a HDR workflow using the auto exposure parameter of the post effects. This allows an reproduction of the eye mechanism when going from full sunlight to darker environment like the inside of a house or the night. It also give a lot of realism with lit objects and shadowy area rendering bright or dark depending on where the player stand: for example, insides of a house are dark seen from outside.

    Though I have an issue with the fog. My HDR skybox and sun are very powerful in order to take advantage of the different range of light intensities and as a result, Unity's fog is dark in daylight because it is not a HDR Color and can't follow.

    2018-09-20 19_24_32-Window.jpg
    2018-09-20 19_25_11-Window.jpg
    Here is an example of what the fog looks like event though it is pure white.

    2018-09-20 19_25_27-Window.gif

    Is there any way to change that? Or does anybody know an asset on the store solving that issue?

    Thanks.
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hey! It is not possible to use HDR ranges for fog in the built-in render pipeline. However, the HD render pipeline offers additional fog options within its Scene Settings game object, which tonemap nicely when using HDR lights.

    Unity_2018-09-25_17-30-27.png
     
  3. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Hey Marc, we had the same issue... it's frustrating that you can't have brighter fog in order to match, say, misty mornings where the early morning sun creates very brightly lit 'fog'.

    What we did was write custom fog functions for our shader. There's the 'Final Color' option if you're using surface shaders, otherwise just wrote from scratch our fog function still taking colour and mode (Exp2, Linear) from Unity.
     
    kristijonas_unity likes this.
  4. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    Hi kristijonas_unity.

    Is the HD render pipeline VR compatible? As far as I know it is not but I don't know if it's too heavy or if it not supported at all.
     
  5. Marc-Saubion

    Marc-Saubion

    Joined:
    Jul 6, 2011
    Posts:
    655
    Hi MattVLSG.

    I found a solution using Aura and adding some fog in the sunlight. It gives a convicing lit fog. Not perfect for every situations but did the job this time.

    I'm not sure what shader you are refering to. Is it something available on the asset store?
     
  6. MattVLSG

    MattVLSG

    Joined:
    Apr 2, 2018
    Posts:
    43
    Hey,

    No it was just custom shaders for our project. So if you were using Surface Shaders, you add a final colour hook, there's a 'Fog' example here.
    https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html

    Which is where we wrote our own fog function... which doubled the fog colour, so at least white will be extremely bright. And we used the Fog Color alpha to control how much of the sun colour comes through.

    Extreme example below, it's greenish fog but the sun is coming through to the left.

    2018-10-22 16_47_11.png


    Also wrote a custom skycube shader to have fog, as the default Unity one doesn't actually fog the skydome it appears! This is important if you want the fog to nicely blend out from world objects into the sky. We added a height value for the cubemap 2018-10-22 16_51_04.png