Skip to content

Commit

Permalink
Happy as a clamp
Browse files Browse the repository at this point in the history
- Fix instances vanishing close to the edge of your screen
  • Loading branch information
Jozufozu committed Sep 21, 2024
1 parent 40cfc08 commit b7b7cca
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ bool _flw_isVisible(uint instanceIndex, uint modelIndex) {

ivec4 bounds = ivec4(aabb * vec4(levelSizePair));

// Clamp to the texture bounds.
// Since we're not going through a sampler out of bounds texel fetches will return 0.
bounds = clamp(bounds, ivec4(0), levelSizePair);

float depth01 = texelFetch(_flw_depthPyramid, bounds.xw, level).r;
float depth11 = texelFetch(_flw_depthPyramid, bounds.zw, level).r;
float depth10 = texelFetch(_flw_depthPyramid, bounds.zy, level).r;
Expand Down

0 comments on commit b7b7cca

Please sign in to comment.