Skip to content

Commit

Permalink
Round to nearest color_index when doing color mapping (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed May 2, 2023
1 parent 22cc69d commit 3b4b301
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/re_renderer/shader/rectangle_fs.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ fn fs_main(in: VertexOut) -> @location(0) Vec4 {
let colormap_size = textureDimensions(colormap_texture).xy;
let color_index = normalized_value.r * f32(colormap_size.x * colormap_size.y);
// TODO(emilk): interpolate between neighboring colors for non-integral color indices
let color_index_i32 = i32(color_index);
// It's important to round here since otherwise numerical instability can push us to the adjacent class-id
// See: https://github.com/rerun-io/rerun/issues/1968
let color_index_i32 = i32(round(color_index));
let x = color_index_i32 % colormap_size.x;
let y = color_index_i32 / colormap_size.x;
texture_color = textureLoad(colormap_texture, IVec2(x, y), 0);
Expand Down

0 comments on commit 3b4b301

Please sign in to comment.