Search Unity

What's the best way to deal with fog and horizon in URP?

Discussion in 'Universal Render Pipeline' started by Reshima, Mar 12, 2020.

  1. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    So I have a flat map and I'd like to create some fog in the distance so that the horizon blends with the sky.

    Unless if I have a very boring sky in which its color is the same color for the fog, I can't make it work because it seems like the fog only applies to the meshes and not the scene as a whole.

    I'm guessing that the best way to do this would be through post processing, maybe using some depth information to make the whole scene at the horizon blend with the sky, but unfortunately I don't see a fog option in URP Post Processing stack.

    I know that in HDRP there's volumetric fog which solves this problem but for URP I'm running out of ideas. Any thoughts? or would you think it's better for me to actually create some mesh to delimit the map?

     
    Fressbrett likes this.
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    If you make custom shader, pass the sky texture, and sample it and use that instead of the fog color
     
  3. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    You could match the horizon color of your skybox to the fog color you use.

    Or, you could take a circle, apply a simple transparent gradient to blend the fog with the skybox, you'll just match the gradient color to whatever built in fog color you use.

    upload_2020-3-16_23-8-51.png

    The above method is only helpful if you are okay with a single color, although you could probably get creative and figure something else out, but for a more complex fog and if performance isn't much of an issue you'll need to write a custom post effect.
     
    andreiagmu, Reshima and Gametyme like this.
  4. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    That's a great idea deverolirc. What I did in the end was just to adjust my skybox horizon and terrain shape so the blend better. Thanks for the idea though, I'd consider those.
     
  5. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    Does anyone have a blended skybox shader to solve the problem at hand?
     
  6. Weaver

    Weaver

    Joined:
    Jul 2, 2013
    Posts:
    18
    ivank and lilacsky824 like this.
  7. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    Last edited: Jul 10, 2021
    ElevenGame likes this.
  8. Weaver

    Weaver

    Joined:
    Jul 2, 2013
    Posts:
    18
    Excellent, thanks for the info :)