Giter Site home page Giter Site logo

sinnwrig / urp-fog-volumes Goto Github PK

View Code? Open in Web Editor NEW
76.0 5.0 8.0 256.38 MB

Implementation of Raymarched Volumetric Fog in Unity's Universal Render Pipeline

License: MIT License

HLSL 19.79% C# 75.63% ShaderLab 4.58%
atmosphere effects fog fog-computing graphics graphics-programming graphics-rendering level-design post-process post-processing

urp-fog-volumes's Introduction

Raymarched Fog Volumes for Unity's Universal RP

This repository is an implementation of single-bounce raymarched volumetric fog for Unity's Universal Render Pipeline.

Scenes Outdoors Light Shafts URP Samples- Japanese Garden Nighttime streetlights
Fog Outdoors Fog Garden Fog Building Fog
No Fog Outdoors
Garden
Building

More Examples

Installation

Features

  • Half & quarter-resolution rendering with depth-aware upsampling (Incompatible with temporal rendering).
  • Temporal Rendering with reprojection (Semi-complete).
  • Animated scrolling 3D texture noise
  • 4 primitive shapes that support non-uniform scale and rotation:
    • Cube
    • Capsule
    • Sphere
    • Cylinder
  • Support for all realtime lights, shadows, and cookies up to a maximum of 32 lights per volume.
    • Lighting is not entirely physically-based, and instead exposes artistic controls for finer tweaking.
    • Light attenuation is only single-bounce, and fog does not self-shadow. Multiple-bounce lightmarching will be added soon.
  • Support for APV GI in Unity 2023.1+
  • Samples for the Gas Station, Forest, and Office Building scenes. These can be imported through the package manager.

Usage

  • Add the Fog Volume Render Feature to your renderers.
  • Create a new Fog Volume in the scene by adding the FogVolume component to any object or using the options under GameObject/Volumes/
  • Create or assign a new profile.
  • Adjust object scale and profile settings until you get your desired look.

Limitations

Unresolvable

  • Does not support DirectX 9 (Desktop GPUs before 2009~2011) or DirectX 11 9.x (DirectX version specifically for Windows Phone and Microsoft Surface RT). These shader models are incompatible with dynamic loops.
  • Temporal Reprojection is disabled in scene view, and only works when in play mode. Unity does not seem to generate consistent motion vectors for the editor view, and causes severe warping/blurring.
  • Temporal Reprojection cannot reproject parts where fog is facing the skybox or empty space. Motion vectors can't be created where there are no discernible features to track and compute movement.
  • There is currently a hard cap of 32 lights per volume. This cap can be changed by editing the maximum light constants in VolumetricFog.shader and FogVolume.cs

Under Development

  • Does not use physically based light scattering through the volume, as lighting is single-bounce only. This means that for directional lights, volumes will be evenly lit regardless of density. Lightmarching is planned on being added.
  • Orthographic cameras do not work. This is planned on being fixed.
  • Baked lighting and light probes does not work at the moment. This is planned on being fixed.

Transparency Handling

Due to how transparent objects are rendered to the depth texture, transparency does not work out-of-the-box with Fog Volumes and requires some additional render feature setup detailed in this Forum Post, although a brief tutorial will be provided:

  1. Put all the transparent renderers you want affected by fog into their own seperate layer (i.e 'TransparentDepth).
  2. Remove the layer created just now from the Transparent Layer Mask field in the Filtering section of your active URP renderers. These objects will instead be rendered using the render feature.
  3. Add the Render Objects render feature to your renderers before the Fog Volume render reature.
  4. Set the Event field of Render Objects to AfterRenderingTransparents
  5. Under Filters, set the queue to Transparent and the layer mask to our custom transparent depth layer.
  6. Under Overrides, override Depth and enable Write Depth and set the Depth Test to Less Equal

Potential Issues

I am confident the the asset in its current state has no glaring or overly apparent issues. That said, this asset is not backed by heavy testing, and there is a chance that this package may have bugs or not work on some platforms.

This asset has been tested on:

  • OpenGL 4.5.
  • DirectX 11.
  • DirectX 12.
  • Vulkan.
  • Unity version 2022.3.
  • Windows.
  • Linux.

This asset has not been tested, but may work on:

  • Metal.
  • VR or AR platforms.
  • Versions of Unity below 2022.3.
  • macOS.
  • PlayStation devices.
  • Xbox devices.
  • Nintendo devices.
  • iOS.
  • visionOS.
  • Android.
  • WebGL.
  • UWP.
  • tvOS.

Examples

Japanese Forest with and without fog

Outdoors Fog Outdoors

Oasis with and without fog

Oasis Fog Oasis

Building with and without fog

Building Fog Building

Japanese Garden with and without fog

Garden Fog Garden

Gas station with and without fog

Gas Station Fog Gas Station

Demo Terminal Building with fog

Terminal Fog

urp-fog-volumes's People

Contributors

sinnwrig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

urp-fog-volumes's Issues

renderQueqe for the shader

Hello! How can I set renderQueqe to Transparent+10 for the shader?
Because when the camera inside the fog we can see the water (3000 renderQueqe), for example
Water is rendering "before" the fog, even if it far away
I changed "beforeTransparents" to true in VolumetricFogFeature.cs but nothing changed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.