Skip to content

[BUG] Color accuracy: approximate OKLab transform + grayscale light theme charts #896

Description

@rajpreetcodes

Bug Report

Platform

All platforms (Linux, macOS, Windows)

Current Behavior

In apps/desktop/src/theme.rs:150-181, the OKLab to sRGB conversion uses approximate hardcoded coefficients that produce visibly incorrect colors:

let red = linear_srgb_to_srgb(4.076_741_7 * l - 3.307_711_6 * m + 0.230_969_94 * s);
let green = linear_srgb_to_srgb(-1.268_438 * l + 2.609_757_4 * m - 0.341_319_4 * s);
let blue = linear_srgb_to_srgb(-0.004_196_086_3 * l - 0.703_418_6 * m + 1.707_614_7 * s);

These are simplified approximations of the OKLab inverse transform. For a video editor, color accuracy is critical - these inaccuracies will compound across the rendering pipeline.

Additionally, light theme chart colors are all grayscale (chroma=0):

chart_1: oklch(0.87, 0.0, 0.0),  // All chart_1 through chart_5 have chroma=0
chart_2: oklch(0.556, 0.0, 0.0),
chart_3: oklch(0.439, 0.0, 0.0),
chart_4: oklch(0.371, 0.0, 0.0),
chart_5: oklch(0.269, 0.0, 0.0),

This makes charts unusable in light mode - all bars/lines render as identical gray.

Expected Behavior

  1. Use the exact OKLab inverse transform matrix from the specification (Björn Ottosson's paper)
  2. Light theme chart colors should have distinct hues (chroma > 0)

Steps To Reproduce

  1. Run desktop app in light mode
  2. Observe chart components - all colors are identical gray
  3. Compare rendered colors against reference OKLab implementation

Recurrence Probability

Always - deterministic color math error

Additional Context

For a video editor, color fidelity is a core requirement. Consider using a vetted color space library like palette or oklab crate instead of hand-rolled approximations. The current implementation deviates from the OKLab spec.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions