Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Volumetric Fog for URP (Forward+)

Discussion in 'Assets and Asset Store' started by Mseon, Nov 17, 2023.

  1. Mseon

    Mseon

    Joined:
    May 21, 2021
    Posts:
    4
    Hi community,
    I made a volumetric fog package for URP, specially designed for forward+ rendering considering performance. It's basically copied HDRP code to work for URP.

    It includes exponential height fog, and volumetric lighting as HDRP fog behaves.
    Note that while fog in HDRP requires local volumes to show volumetric lighting, you don't need to place any local volumes unless you want ground smoke volume in this package. The volumetric lighting for local lights is only working for forward+.

    One of the main differences between this package and HDRP fog is while HDRP can specify the volumetric lighting intensity for each light, URP lights do not have that property. So I created a new parameter 'localScatteringIntensity' to control the scattering intensity for all local lights(= point, spot). There's no option to control only the local light volumetric scattering intensity unless you change the intensity of each light.

    Tooltips might not be sufficient yet though, the algorithm follows HDRP fog properties so if you know how to use and customize HDRP fog settings then it would not be an issue.

    Limitations
    1. XR not supported
    2. Additional Directional & Local(point & spot) lights are only available in Forward+
    3. DiffuseGI does not contribute to lighting
    4. Noise texture is not supported
    5. The number of LocalSmokeVolume is 4 at maximum.
    6. Volumetric lighting is only enabled in a scene view in edit mode. If playing, only enabled in a game view.
    You can download the package here.

    Please feel free to give me any feedback.
     
    GodlikeAurora, Trigve and CodeSmile like this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,922
    Just found this by accident, looking for how to simulate fog with URP. The package looks nice enough to give it a try ... but not without a LICENSE. This means the repository is restricted content and it would be illegal to use it in any form without your express permission.

    Please add a LICENSE file of your choice to the repository if you wish others to use it.
    Personally I would recommend MIT License, it's unrestrictive and has a disclaimer that you cannot be held liable for anything.
     
  3. Mseon

    Mseon

    Joined:
    May 21, 2021
    Posts:
    4
    Thanks for your input. Just added a license file :)
     
    CodeSmile likes this.
  4. XJonOneX

    XJonOneX

    Joined:
    Dec 19, 2017
    Posts:
    116
    I may not know what I'm asking, but can this occlude objects in the distance with the right settings like Unity's Lighting->Environment fog? With this I can only seem to apply like, a shade of color to objects with a varying intensity.
     
  5. RyanJacques262003

    RyanJacques262003

    Joined:
    May 23, 2024
    Posts:
    2
    Hi, I seem to have trouble getting the local smoke to show no matter what setting I adjust. Can you provide a more detail guide on this.
     
  6. Mseon

    Mseon

    Joined:
    May 21, 2021
    Posts:
    4
    Volumetric fog basically uses the 'Exponential Height Fog' algorithm when an object is farther away than the 'Depth Extent' value. So Unity fog (= distance fog) and volumetric fog are different. To obscure objects in the far distance, use Unity's built-in fog.
     
  7. Mseon

    Mseon

    Joined:
    May 21, 2021
    Posts:
    4
    Could you share with me the config/local volume settings? The local volume also follows HDRP local volume properties, so you can see the details here if you need more information.
    - https://docs.unity3d.com/Packages/c...inition@14.0/manual/Local-Volumetric-Fog.html