Skip to content

Color mapping fails for some class-ids values #1968

@jleibs

Description

@jleibs

For certain values of class-id such as "3" we end up showing the color for the previous class.

Minimal repro:

import numpy as np
import rerun as rr

rr.init("seg_fail", spawn=True)

rr.log_annotation_context(
    "seg_fail",
    [(1, "red", (255, 0, 0)), (2, "green", (0, 255, 0)), (3, "blue", (0, 0, 255)), (4, "yellow", (255, 255, 0))],
)

segmentation_img = np.zeros([128, 128], dtype="uint8")
segmentation_img[10:20, 10:118] = 1
segmentation_img[30:40, 10:118] = 2
segmentation_img[50:60, 10:118] = 3
segmentation_img[70:80, 10:118] = 4
rr.log_segmentation_image("seg_fail/img", segmentation_img)

Output:
image

A bit of investigation hints at this being somehow related to inappropriate application of gamma:

if I modify the value normalization:
https://github.com/rerun-io/rerun/blob/main/crates/re_renderer/shader/rectangle_fs.wgsl#L76

To force a gamma of 1.0:

normalized_value = vec4(pow(normalized_value.rgb, vec3(1.0)), normalized_value.a); // TODO(emilk): handle premultiplied alpha

Then everything works.

However, as far as I can tell we are passing gamma of 1.0 for these class-id mappings, so it seems like something is going wrong in the way the uniform is being mapped?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔺 re_rendererrendering, graphics, GPU🦟 regressionA thing that used to work in an earlier release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions