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

Fix volumetric fog artifacts when inside the fog #86103

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

ecmjohnson
Copy link
Contributor

Resolves #74790 by forcing the froxel volume to the full frame whenever the camera could have its near plane inside the fog volume. This uses the AABB of the fog volume as a proxy for the fog volume itself. Depth can still be culled based on the farthest corner in froxel space.

testing_fix

The min/max corners of the fog volume are tracked while mapping each corner into froxel space. This constructs an AABB around the transformed fog volume. This AABB is then expanded by the distance from the camera position to the corner of the near plane. If the camera is inside this AABB, then only the z depth froxel coordinate can be safely culled. Otherwise, I think considering just the corners is correct.

I renamed the min/max variables to froxel_min/froxel_max to be avoid confusion with the minimum/maximum world-space corners of the fog volume. I also renamed the points variable to froxels, again to be clear these points are in froxel space.

@ecmjohnson ecmjohnson requested a review from a team as a code owner December 13, 2023 01:43
@akien-mga akien-mga added bug topic:rendering cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Dec 13, 2023
@akien-mga akien-mga added this to the 4.3 milestone Dec 13, 2023
@clayjohn clayjohn modified the milestones: 4.3, 4.4 Jul 24, 2024
@clayjohn clayjohn added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Jul 24, 2024
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks great to me! Sorry this slipped through the cracks for so long

@Repiteo Repiteo merged commit 9f908a3 into godotengine:master Oct 24, 2024
16 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 24, 2024

Thanks!

@idchlife
Copy link

@ecmjohnson thank you!

@Anzo1992
Copy link

Anzo1992 commented Jan 11, 2025

I downloaded the Godot 4.4-dev7 version and saw that the FogVolume fix was implemented in Godot 4.4-dev4 version.

I tested a scene and it's still showing some cutting/clipping when moving the camera around.

This is how the fog looks like once i load the scene.
Normal(standing)

This is how it looks when I move the camera around:
Moving_camera

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release topic:rendering topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Volumetric Fog shows artifacts at camera edge at certain angles inside Fog Volumes
8 participants