Skip to content

Commit

Permalink
Fix occlusion culling not respecting cylindrical fog
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Aug 5, 2023
1 parent b13b182 commit cc6e600
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ private static double getClosestVertexDistanceToCamera(Vec3d camera, ChunkSectio
double distanceY = camera.y - (section.getCenterY() + offsetY);
double distanceZ = camera.z - (section.getCenterZ() + offsetZ);

// squared distance: (x^2)+(y^2)+(z^2)
return (distanceX * distanceX) + (distanceY * distanceY) + (distanceZ * distanceZ);
// vanilla's "cylindrical fog" algorithm
// max(length(distance.xz), abs(distance.y))
return Math.max((distanceX * distanceX) + (distanceZ * distanceZ), Math.abs(distanceY));
}

private void init(ArrayDeque<RenderSection> queue,
Expand Down

0 comments on commit cc6e600

Please sign in to comment.