Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a volumetric fog density multiplier texture to better represent high-frequency detail #11324

Open
Calinou opened this issue Dec 9, 2024 · 0 comments

Comments

@Calinou
Copy link
Member

Calinou commented Dec 9, 2024

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Volumetric fog works well to represent low-frequency detail, but its froxel-based nature prevents it from displaying high-frequency detail unless you increase the volumetric fog size/depth project settings by a lot. This makes it much slower to render.

This limits is flexibility in representing things like smoke or dust.

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

Add a volumetric fog density multiplier texture to better represent high-frequency detail.

While this wouldn't increase the resolution of the underlying froxel data that contains the fog color and density, this would make it look like the fog is more detailed.

This in turn would also make lower-resolution fog more viable, which can be important if you want to increase the maximum distance at which volumetric fog is visible (Volumetric Fog Length property).

This is similar in concept to what glow maps achieve for glow.

I believe CS2's smokes do something similar to give them an impression of detail:

Image

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

Four new properties would be added to Environment:

  • Volumetric Fog Density Map: Texture3D
    • Only the red channel is used, so that you can use a R8 texture to reduce memory utilization.
    • Black pixels map to a density multiplier of 0.0. Red pixels map to a density multiplier of 1.0.
    • NoiseTexture3D is particularly well-suited here.
  • Volumetric Fog Density Map Strength: float ([0.0; 1.0], default 1.0)
    • Controls the intensity at which the density map applies. 0.0 effectively disables the density map without needing you to unassign the texture, which can be used to transition from a "not density-mapped" to a "fully density-mapped" state smoothly using AnimationPlayer or Tween.
  • Volumetric Fog Density Map Offset: Vector3 (default 0.0, 0.0, 0.0)
    • This can be animated over time to make the fog details scroll, without affecting where the fog is positioned in the world.
  • Volumetric Fog Density Map Scale: Vector3 (default 1.0, 1.0, 1.0)
    • This can be used to adjust the scale of the density map in world space and avoid visible tiling. Higher values make the texture cover a larger area.

This new texture is then used to multiply the fog density on each pixel on the screen, with a world-space transformation to ensure each fog pixel remains stable as the camera moves or rotates.

To ensure there's no performance cost if the feature isn't used, this would most likely make use of a specialization constant to toggle the functionality in the shader on-demand.

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

No.

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

This is about improving the flexibility of volumetric fog, making it more usable as a replacement for traditional alpha billboards where it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant