gelly-gmod / gelly

Library to integrate fluids into a game engine
GNU General Public License v3.0
22 stars 5 forks source link

Revamp the depth filter #90

Closed yogwoggf closed 4 months ago

yogwoggf commented 5 months ago

Context

Right now, the depth filter achieves a fairly smooth isosurface, but to be perfectly honest, the artifacts are becoming noticeable.

Artifact 1: Pull-away

image

I'm calling this artifact "pull-away," as it's a result of the filter being unable to continue past the edges of the fluid and thus "pulling" the edges towards the center of the sphere. This causes a false edge and the normals to reach a grazing angle a little bit before the edges are actually apparent.

It is exacerbated by a higher filter size.

Artifact 2: Aliasing

image

When the angle in which an isosurface is viewed becomes too perpendicular to the general normal of the fluid, the filter will repeatedly reject surrounding pixels causing a generational effect of aliasing between iterations--ultimately leading to invalid normals and a black specular reflection.

image

This image shows the isosurface when the angle is less intense, as you can see--specular highlights are visible.

Artifact 3: Border sample failure

image

When the filter reaches the edge of the screen, it oversamples itself and returns an incorrect normal.

Artifact 4: Surface decay when inside a volume of fluid

image

Ultimately, our main goal for this specific artifact is to simply not render any particles when in water. We could do this by running a parallel reduction-esque algorithm by checking if the overall depth is lower than some threshold.

Scope

Pull-away

Aliasing

Border sample failure

Surface decay

Acceptance Criteria

todo

Other

yogwoggf commented 5 months ago

In #94, we've mitigated artifact 4 entirely 🥳