Skip to content

Commit

Permalink
Near stability
Browse files Browse the repository at this point in the history
- Fix near plane rejection logic
- Fix lod clamp
  • Loading branch information
Jozufozu committed Sep 14, 2024
1 parent 6c1fbf6 commit f009cb8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ bool _flw_testSphere(vec3 center, float radius) {
}

bool projectSphere(vec3 c, float r, float znear, float P00, float P11, out vec4 aabb) {
if (c.z > r + znear) {
// Closest point on the sphere is between the camera and the near plane, don't even attempt to cull.
if (c.z + r > -znear) {
return false;
}

Expand Down Expand Up @@ -91,7 +92,7 @@ bool _flw_isVisible(uint instanceIndex, uint modelIndex) {
float width = (aabb.z - aabb.x) * _flw_cullData.pyramidWidth;
float height = (aabb.w - aabb.y) * _flw_cullData.pyramidHeight;

int level = clamp(0, int(ceil(log2(max(width, height)))), _flw_cullData.pyramidLevels);
int level = clamp(int(ceil(log2(max(width, height)))), 0, _flw_cullData.pyramidLevels);

ivec2 levelSize = textureSize(_flw_depthPyramid, level);

Expand Down

0 comments on commit f009cb8

Please sign in to comment.