Skip to content

Commit

Permalink
Fix color greyscale colormap not being even (#3391)
Browse files Browse the repository at this point in the history
### What

Pointed out in #3373 that our grey colormap looked broken in the
preview. When diving into it I got at first a scare about our color
space pipeline being broken, but eventually I concluded that it was only
the gray colormap which was broken.

Grey before/after with reference gradient from gimp:

![fix](https://github.com/rerun-io/rerun/assets/1220815/d293d4a1-7aa4-4307-b66e-f0b6ad6ec7de)
It's not perfectly equal to the reference, but then again the test
wasn't executed with maximum vigor either. Some slight differences are
to be expected due to the amount of conversions we need to go through to
arrive at the final image.

(unchanged) turbo colormap gradient compared with the render from
Matplot webpage (a bit sloppy but shows that we're definitely not some
wild gamma converstion away from it!):
<img width="1248" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/1440e775-7b7c-4327-a6b0-dadbf8e78a6f">



This affects all usages of the greyscale colormap.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3391) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3391)
- [Docs
preview](https://rerun.io/preview/3eee011742a208f6f3d07353c67fb0f3059c6851/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/3eee011742a208f6f3d07353c67fb0f3059c6851/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
Wumpf authored Sep 21, 2023
1 parent 6bb3a8e commit 3d4a6a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/re_renderer/shader/colormap.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const COLORMAP_VIRIDIS: u32 = 6u;
fn colormap_srgb(which: u32, t_unsaturated: f32) -> Vec3 {
let t = saturate(t_unsaturated);
if which == COLORMAP_GRAYSCALE {
return srgb_from_linear(Vec3(t));
// A linear gray gradient in sRGB gamma space is supposed to be perceptually even as-is!
// Easy to get confused: A linear gradient in sRGB linear space is *not* perceptually even.
return Vec3(t);
} else if which == COLORMAP_INFERNO {
return colormap_inferno_srgb(t);
} else if which == COLORMAP_MAGMA {
Expand Down

0 comments on commit 3d4a6a5

Please sign in to comment.