Skip to content

Commit

Permalink
Fix greyscale colormapping being not gamma-corrected (#2456)
Browse files Browse the repository at this point in the history
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Fix `colormap_srgb` outputting linear greyscale map instead of srgb
greyscale map.

Note how this method is documented as:
`/// Returns a gamma-space sRGB in 0-1 range.`
but then a few lines below outputted `Vec3(t)` directly, i.e. a linear
scale.

This became visually apparent when you put a 3 channel image (no color
map!) next to a single channel image (greyscale color map applied) next
to each other.

Before:
<img width="402" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/65e0feaa-2443-483b-9b6f-424e6b22c0d7">

After:
<img width="411" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/da1ba05e-7343-4700-a218-c5bb240870cb">


(this is not what the sample usually looks like, I made both images take
the value 128, they are different by default)


### 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)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2456

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/1c35935/docs
Examples preview: https://rerun.io/preview/1c35935/examples
<!-- pr-link-docs:end -->
  • Loading branch information
Wumpf authored Jun 16, 2023
1 parent 2c0ecd0 commit 8f55136
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/re_renderer/shader/colormap.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const COLORMAP_VIRIDIS: u32 = 6u;
fn colormap_srgb(which: u32, t_unsaturated: f32) -> Vec3 {
let t = saturate(t_unsaturated);
if which == COLORMAP_GRAYSCALE {
return Vec3(t);
return srgb_from_linear(Vec3(t));
} else if which == COLORMAP_INFERNO {
return colormap_inferno_srgb(t);
} else if which == COLORMAP_MAGMA {
Expand Down

1 comment on commit 8f55136

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: 8f55136 Previous: 2c0ecd0 Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/insert/default 3984700 ns/iter (± 49676) 2875624 ns/iter (± 3789) 1.39
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default 411 ns/iter (± 0) 323 ns/iter (± 3) 1.27
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default 297 ns/iter (± 0) 227 ns/iter (± 0) 1.31
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 456 ns/iter (± 2) 351 ns/iter (± 1) 1.30
datastore/num_rows=1000/num_instances=1000/packed=false/range/default 4085947 ns/iter (± 68339) 2899438 ns/iter (± 6475) 1.41
datastore/num_rows=1000/num_instances=1000/gc/default 2661773 ns/iter (± 6404) 1714974 ns/iter (± 4440) 1.55
mono_points_arrow/generate_message_bundles 36745913 ns/iter (± 1374845) 28431837 ns/iter (± 771229) 1.29
mono_points_arrow/encode_log_msg 229942195 ns/iter (± 691021) 179176232 ns/iter (± 1870822) 1.28
mono_points_arrow_batched/generate_message_bundles 23904940 ns/iter (± 1112894) 18223528 ns/iter (± 80550) 1.31
mono_points_arrow_batched/generate_messages 5499535 ns/iter (± 140176) 3567381 ns/iter (± 15745) 1.54
mono_points_arrow_batched/encode_log_msg 652346 ns/iter (± 3033) 487118 ns/iter (± 1177) 1.34
mono_points_arrow_batched/encode_total 30684810 ns/iter (± 1175234) 23479709 ns/iter (± 329214) 1.31
mono_points_arrow_batched/decode_message_bundles 9357825 ns/iter (± 114143) 7364829 ns/iter (± 8564) 1.27
mono_points_arrow_batched/decode_total 9920348 ns/iter (± 153547) 7853905 ns/iter (± 17269) 1.26
batch_points_arrow/decode_log_msg 48570 ns/iter (± 103) 38204 ns/iter (± 147) 1.27
batch_points_arrow/decode_total 53831 ns/iter (± 223) 41984 ns/iter (± 333) 1.28
arrow_mono_points/insert 2848531213 ns/iter (± 27534658) 1783653188 ns/iter (± 11573641) 1.60
arrow_mono_points/query 1331192 ns/iter (± 8887) 935617 ns/iter (± 1088) 1.42
arrow_batch_points/insert 1503259 ns/iter (± 2870) 1187921 ns/iter (± 10137) 1.27
arrow_batch_points/query 17121 ns/iter (± 68) 12553 ns/iter (± 24) 1.36
arrow_batch_vecs/insert 30158 ns/iter (± 34) 23963 ns/iter (± 50) 1.26
arrow_batch_vecs/query 476223 ns/iter (± 379) 322248 ns/iter (± 474) 1.48

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.