Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 7, 2024
1 parent 80d9f8b commit ecea21c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions yt_idv/shaders/block_histogram.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ void main() {
uint N = dims.x;
uint NxM = dims.x * dims.y;
uint NxMxL = dims.x * dims.y * dims.z;

// Calculate global thread ID
uint globalIdx = gidZ * gl_NumWorkGroups.y * gl_NumWorkGroups.x + gidY * gl_NumWorkGroups.x + gidX;
// Check if global ID is within texture bounds
if (globalIdx >= NxMxL) {
return;
}

// Calculate 3D texture coordinates from global ID
uint z = globalIdx / (NxM);
uint remainder = globalIdx % (NxM);
uint y = remainder / N;
uint x = remainder % N;

// Sample the value from the 3D texture
vec4 texValue = texture(texData, vec3(x, y, z));

// Normalize the value to the range [0, 1] based on min and max
float normalizedValue = (texValue.r - minVal) / (maxVal - minVal);

// Clamp the normalized value to [0, 1]
normalizedValue = clamp(normalizedValue, 0.0, 1.0);

// Calculate the bin index based on the number of bins
int binIndex = int(normalizedValue * (numBins - 1));

// Use atomicAdd to safely increment the count in the corresponding bin
atomicAdd(imageLoad(uHistogram, binIndex), 1);

}
}

0 comments on commit ecea21c

Please sign in to comment.