Skip to content

Implement ray marched volumetric fog as an extension of the current froxel-based solution #8580

Description

@InitialCon

Describe the project you are working on

A cross platform 3D game where the player can see far into the distance.

Describe the problem or limitation you are having in your project

The current volumetric fog solution works by slicing the view frustrum up into froxels and using fog volumes or a global density to calculate the density and colour of individual froxels. This provides high quality close to the camera but has a limitation on how far the effect can work due to the quality being inversely proportional to the effect's distance or requiring a much larger froxel buffer size which causes performance and memory problems very quickly. This method is also not feasible on mobile platforms due a number of factors including the performance requirement.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

An alternate method of computing volumetric fog is to use ray marching. This method works by marching advancing a ray along the scene for each pixel and computing which fog volumes are the closest and calculating their densities at a set position. The density and colour are then interpolated as the ray progresses giving the appearance of a continuous volume. The rays can be jittered slightly to take advantage of taa or the entire effect can be reprojected to increase quality and performance. This method requires vastly less resources and should be possible as a high end option in the mobile and compatibility renderers. Another benefit of this approach is that it can blend seemlessly with the current froxel based fog to maintain the high quality up close while allowing high performance volumetrics at much higher distances.

Edit: Global illumination and lights other than the main directional light should be ignored for performance reasons, especially on mobile. Additionally, Rockstar recommends disabling fog volumes and only computing global fog however, if the number of fog volumes considered is kept low this shouldn't be an issue. This could be acheived by only computing ray marched fog for certain layers of fog volumes to prevent performance problems.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Expose a new option in the volumetric fog section of the world environment such as "enable long distance fog". When this option is enabled several other options become available such as the start distance(by default this will be set to the max distance of the froxel based fog or 0 if froxel fog is disabled), the step count, as well as the default density and colour. To allow for this method to work on mobile and in the compatibility renderers a new option "enable froxel fog" must be added with it defaulting to on to avoid breaking compatibility and having its value set to zero if the project is running on a platform that doesn't support it.

This is the same method as the one used in Red Dead Redemption 2 and thus it serves as a good example of the performance and quality possible: https://www.youtube.com/watch?v=9-HTvoBi0Iw&t=7100s

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, since it is not currently possible to read the contents of fog volumes from user facing shaders or scripts.

Is there a reason why this should be core and not an add-on in the asset library?

This is a pretty standard implementation of long distance volumetrics and would enable several other add-ons which would help the overall godot ecosystem. It could be made into an add-on if the ability to read the values from a fog volume at an exact position was added however the complexity of doing it in a script would make it very difficult compared to exposing it natively.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions