Search Unity

How can volumetric fog be made without HDRP?

Discussion in 'General Graphics' started by coder_58, Jun 19, 2022.

  1. coder_58

    coder_58

    Joined:
    Mar 29, 2020
    Posts:
    31
    Hi,

    I know I can install HDRP and set up a fog volume but I have very specific materials and skyboxes and behaviors in my scene and don't want to mess them up. I'd appreciate any insight. Thanks.
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,923
    No HDRP, no volumetric fog. If you don't want to switch your project to HDRP but need volumetric fog, you have to write it yourself. Ray marching is what you want to be doing:

     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,628
    One way is to use a particle effect. It's simple and it can look pretty good depending on what you're trying to do.

    Another thing is that you can change the settings for Unity's built-in fog at any time, so you can write a script that changes the settings when the player steps inside a certain volume.

    It's also possible to write a shader to do a grab-pass and apply a depth-based effect on it. This method doesn't hold up if you try to walk through it, but it can work if you want to fog-out something in the distance that the player can't get to. I've done this with built-in renderer, but I've not used URP.

    Which renderer are you using?
     
  4. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    You can always see if a screen-space volumetric effect (aka Sunshafts) works for your scene - I personally find them adequate.


    There are some assets (including my own) that have solutions for this, but it's actually one of the simplest post-processing effects to code yourself. You take the depth texture, overlay the main scene colour texture only where depth is at max (ie. skybox), then do a directional blur in the direction the sun is facing.