Skip to content

Commit

Permalink
fix: black/white pixel artifacts during rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
GlennWSo authored and Yeicor committed Sep 13, 2024
1 parent b4f4639 commit c083073
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/scene/sdf/material.frag
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ vec4[2] sdfRaycast(vec3 rayPos, vec3 rayDir, int maxSteps) {
}

// Stop condition: out of bounds
if (sdfOutOfBoundsDist(rayPos) > 0.0) {
// NOTE: small epsilon to avoid pixel artifacts
if (sdfOutOfBoundsDist(rayPos) > 1e-4) {
hitPosAndSample[0] = vec4(rayPos, -2.0);
break;
}
Expand Down Expand Up @@ -169,4 +170,4 @@ void main() {
// Compute the depth to fix rendering order of multiple objects.
vec4 hitPosProj = BVP * vec4(hitPos, 1.0);// TODO: Figure out how to set this...
gl_FragDepth = hitPosProj.z / hitPosProj.w;
}
}

0 comments on commit c083073

Please sign in to comment.