Skip to content

Commit 684a294

Browse files
committed
fix discrete colormap
1 parent d875811 commit 684a294

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

webgpu/shaders/colormap.wgsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ fn getColor(value: f32) -> vec4<f32> {
2525

2626
v = clamp(v, 0.0, 1.0);
2727

28-
var colorIndex = v * (Nf - 1.0);
28+
var colorIndex: f32;
2929
if (u_cmap_uniforms.discrete == 1u) {
30-
colorIndex = floor(colorIndex);
30+
colorIndex = min(floor(v * Nf), Nf - 1.0);
31+
} else {
32+
colorIndex = v * (Nf - 1.0);
3133
}
3234

3335
var uv = vec2f(0.5, 0.5);

0 commit comments

Comments
 (0)