Skip to content

Implementation of an atmospheric scattering example found on ShaderToy, ported to URP and made to work with baked optical depth. Inspired by Sebastian Lague's series on Atmospheric Rendering

License

Notifications You must be signed in to change notification settings

sinnwrig/URP-Atmosphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atmospheric Scattering For Unity's Universal RP

Open Source (MIT) implementation of an atmospheric scattering shadertoy : https://www.shadertoy.com/view/wlBXWK.

Ported to HLSL and Unity's Universal RP.

Features

  • Atmospheric Scattering Render Feature.
  • Atmospheric Scattering Settings ScriptbleObject.
  • Atmospheric Scattering Effect Behaviour.
  • Modified to work with Baked Optical Depth, inspired by Sebastian Lague's video on Atmospheric Rendering found here: https://www.youtube.com/watch?v=DxfEbulyFcY.

Usage

  • Download the complete project repository from GitHub or download only the UnityPackage found in Assets/Atmosphere
  • Add the Atmosphere Render Feature to the current active renderer.
  • Create a new AtmosphereSettings scriptableObject by right-clicking/Create/Atmosphere/Atmosphere Profile.
  • Add an AtmosphereEffect component to an object in your scene.
  • Assign the Atmosphere Settings created earlier to the Atmosphere Effect component.
  • Tweak the planet/ocean radius and atmosphere scale to appropriate values. Use the example scene as reference for working values.

There is currently no hard limit on amount of active effects allowed in any given scene, but it is best to reduce the amount as much as possible

Optional

If the scene is using a URP camera stack with the explicit purpose of increasing view distance/maintaining depth precision:

  • Add the Depth Stack render feature to your current active renderer.
  • Make sure your overlay camera is set to clear depth.
  • Atmosphere will automatically use the far camera's depth buffer when needed, increasing the effect's render distance.

Potential issues/Requirements

  • Not tested with VR/AR.
  • Earlier versions of URP have shown issues with the Depth Stack not working properly.
  • Requires compute shader support on active platform.
  • Attempts to pre-bake Optical Depth values into Texture3D's on the CPU did not work in shader.
  • Tested on Linux and Windows machines with Unity 2022. Mac, Mobile, and other platforms are untested.
  • Orthographic cameras do not work.

Limitations

  • Each active effect supports only one main light. Can be modified to use more lights, potentially for multiple suns/moons.

Example Scene with Default Earthlike profile

  • Atmosphere at daytime- default profile with point light added for faux ambient lighting Atmosphere at daytime
  • Atmosphere at sunset- tweaked absorbtion values to look redder Atmosphere at sunset
  • Atmosphere at near-nighttime- tweaked absorbtion values to look redder Atmosphere at nighttime
  • Atmosphere from space- side view with default profile Atmosphere from space
  • Atmosphere and planet forming eclipse- default profile showing some mie glow along the edge Atmosphere from space-again

Example Scene with Exoplanet Atmosphere profile

  • Exoplanet atmosphere at daytime Goofy colored atmosphere
  • Exoplanet atmosphere from space Goofy colored atmosphere from space
  • Exoplanet forming eclipse Goofy colored atmosphere from space again

About

Implementation of an atmospheric scattering example found on ShaderToy, ported to URP and made to work with baked optical depth. Inspired by Sebastian Lague's series on Atmospheric Rendering

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published