[Bug] Opacity should not be gamma corrected
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 14.6k
- Forks
- 2.3k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 42
Description
Description
I don't believe opacity should be gamma corrected. Gamma provides a (very rough) approximation of perceived linearity of lightness in RGB colors, but there's no perceptual basis for applying gamma to opacity. When using sRGB (source of the 2.2 value) the gamma is not applied to alpha channels. Possible unwanted effects:
- 50% opacity overlay becomes 73% opaque instead, isn't an even blend of two layers, and is order-dependent
- linear animation from 0 → 1 is converted to something more like ease-in interpolation
I see this has been around for a while (https://github.com/visgl/deck.gl/commit/aa58f4f42e2b4af2215cab3e649e467b2ccac0ca) ... has it been an issue in practice? I guess if not, perhaps it's more trouble than it's worth to change now?
Related code:
Flavors
- Script tag
- React
- Python/Jupyter notebook
- MapboxOverlay
- GoogleMapsOverlay
- CartoLayer
- ArcGIS
Expected Behavior
Opacity should be passed to the shader as-is, linear, without gamma correction.
Steps to Reproduce
n/a
Environment
n/a
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/core/src/lib/layer.ts around lines 1069-1071 and trace how opacity is passed to the shader. Review the existing discussion and verify the expected behavior for opacity blending and animation; done means opacity reaches the shader linearly without gamma correction and the relevant behavior is validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100