godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix volumetric fog artifacts when inside the fog

Open ecmjohnson opened this issue 1 year ago • 0 comments

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 avatar Dec 13 '23 01:12 ecmjohnson