bevy_color: Add a primaries module with chromaticities and RGB conversion matrices - #25393
Open
stuartparmenter wants to merge 4 commits into
Open
bevy_color: Add a primaries module with chromaticities and RGB conversion matrices#25393stuartparmenter wants to merge 4 commits into
stuartparmenter wants to merge 4 commits into
Conversation
mate-h
suggested changes
Aug 13, 2026
stuartparmenter
force-pushed
the
hdr-wave1-color-primaries
branch
from
August 13, 2026 18:40
809e9aa to
6ef85b3
Compare
mate-h
approved these changes
Aug 13, 2026
mate-h
left a comment
Contributor
There was a problem hiding this comment.
Great, this looks good to me!
|
|
||
| /// The CIE 1931 XYZ tristimulus value of this chromaticity at luminance `1.0`, | ||
| /// in `f64` precision for matrix derivation. | ||
| const fn to_dxyz(self) -> DVec3 { |
Comment on lines
+149
to
+158
| fn rgb_to_xyz_dmat3(&self) -> DMat3 { | ||
| let primaries = DMat3::from_cols( | ||
| self.red.to_dxyz(), | ||
| self.green.to_dxyz(), | ||
| self.blue.to_dxyz(), | ||
| ); | ||
| // Scale each column so that (1, 1, 1) maps to the white point at Y = 1. | ||
| let scale = primaries.inverse() * self.white.to_dxyz(); | ||
| primaries * DMat3::from_diagonal(scale) | ||
| } |
Contributor
There was a problem hiding this comment.
this reads much better now without that nested function
Zeophlite
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
bevy_colorhas no data about RGB primary sets and no way to derive the conversion matrices between them. The upcoming HDR output PRs need these matrices, and this PR is the first piece of that series.Solution
primariesmodule.Chromaticity, a CIE 1931 xy coordinate pair.RgbPrimarieswith constants forBT709,BT2020,DISPLAY_P3andACES_CG.rgb_to_rgb_matrix, which derives the conversion matrix between any two primary sets.Testing
bevy_colortests pass.This PR was built by me with the assistance of Claude Code w/ Fable 5