-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use LinearRgba
for user-facing APIs, rather than Color
#13103
Use LinearRgba
for user-facing APIs, rather than Color
#13103
Conversation
Resolve merge conflicts in `lienar-rgba-everywhere`
Tests are not yet updated and will fail, but `cargo check` succeeds.
Splitting this off into a separate issue.
Opened alice-i-cecile#167, which migrates |
Migrate `bevy_gizmos`
Fix examples, implement `From<Color>` for `StandardMaterial`
I think this is more |
Just as a small warning, this PR may make usage of the One could argue that this is actually a good thing, because it forces developers to choose the color representation that bests fits their project. Either way, it's something to keep in mind. |
Yep, reducing usage of I'm not thrilled with all of the |
A few ideas for reducing this:
|
Putting this on hold until this thread on Discord resolves itself, deciding whether this is a good idea or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is a big regression in terms of UX. I would really like to see benchmarks here to have a better sense. Conversion cost feels pretty theoretical and while I'm sure there are scenarios where it matters quite a bit I'd imagine there are many more where it doesn't matter at all. I'm coming at this from the perspective of wanting to support and make it easy for users to be expressive, which colors (🎨) my bias. In Nannou, we support Into<Color>
everwhere and can convert to LinearRgba
internally if that's the final decision, but imagining myself as a raw Bevy consumer, the API feels less playful. I'm less likely to experiment with other color spaces on a whim. Yeah, .into()
isn't much, but IME this kind of friction matters.
Personally, a split approach of using Into<Color>
by default and LinearRgba
where there's a know performance concern doesn't seem that bad to me? I've missed out on some of this discussion but I'm not sure that consistency is really the most important thing here. I think that it's sensible that there are "high level" and "low level" color operations and while there may be some blurriness between the two, that seems more like a case by case basis to make a decision on.
I'd also like to ask whether we could stick with Into<Color>
but provide "raw" alternatives for where performance matters. I know this means the user would have to know when they're getting hurt by this, but I think that's an option I'd consider too.
Thanks for doing the massive refactor on this though! These kinds of changes are tedious and sometimes you need to see it to have an opinion. Curious what others think.
Initial stress testing showed no meaningful difference. I don't think there's serious performance gains here in real applications. My current stance is that this PR should be closed, with |
I agree with closing this. The PR seems like too much change and too little gain. Since Alice and I agree on this, I'm going to close it. |
Objective
We should make a decision on this pattern before shipping the new color type to users. There will not be a perfect decision: there are very real trade-offs with each choice, but the choice should be deliberate, rather than incidental.
Fixes #12212.
Solution
This PR implements the simple and efficient solution 2, laid out in #12212, which simply uses
LinearRgba
as our standard user-facing color type.Change Log
All uses of
Color
in the engine have been removed.Instead,
LinearRgba
is consistently used to store information about colors across UI and rendering.Migration Guide
All fields which previously held a
Color
now store aLinearRgba
. The full list of types and fields is:When defining a color palette for your application, consider defining these in a human-friendly color space: such as
Hsla
,Labch
orSrgba
. When spawning objects in your game, convert the stored colors intoLinearRgba
using theFrom/Into
traits.