You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was looking at the breakout example where a ClearColor resource was added. I noticed the Color struct has some constant values to choose from, including the value INDIGO. When using that value on a simple default app, the color generated is much more purple than indigo. A simple reproducible example:
use bevy::prelude::*;fnmain(){App::build().add_plugins(DefaultPlugins).add_resource(ClearColor(Color::INDIGO)).run();}
What you expected to happen
The background color to be indigo.
What actually happened
The background color was purple.
Additional information
My initial search of a hex value for indigo led to #4B0082, which appears to be the programming for Color::INDIGO. Color pickers seem to show that as more of a purple. However I don't want this issue to get heated over the definition of indigo, so do with this info what you will.
Below is what I see when using Color::INDIGO:
From a quick Google search, indigo more closely resembles the color below.
The colours where added in #859, and should be the HTML colours, so #4B0082 for indigo (how nice of GitHub to render the colour! Seems to be between the two colours in your issue)
In #616, there was a difference made between rbg and rgb_linear
I've read some on color spaces, but to spare you the details (although I do believe every game programmer should understand the basics about sRGB and gamma correction), when describing colors you most often want to avoid using the linear colors that haven't been gamma corrected. They are used only when mixing and blending colors, and when sending them to the screen (most often done automatically by the GPU in a shader).
When giving color values, they should always be in sRGB (the standard RGB space, aka gamma corrected), and this is the colorspace that all programs use when interfacing with users (the values they give, and what you give).
TLDR:
change it from linear to srbg, which is the Color::rgb function.
Edit: actually looking at it, I guess you can't since Color::rgb_linear is a const function, and Color::rgb isn't, and looking at Rust reference it can't be since it has float operations. I guess just convert the value from sRGB to linear by-hand, and change the function's parameters. And check the other color constants as well, doing the same operation if they're likewise weird looking.
So the list that's currently in Bevy is a smaller subset of that.
I'll submit a PR later for all of the CSS colours using the generated values. I personally think it's worth having.
The full fix would be to have a const function to create colours with standard rgb hex. To do that, this TODO should be done
Activity
mockersf commentedon Jan 2, 2021
The colours where added in #859, and should be the HTML colours, so
#4B0082for indigo (how nice of GitHub to render the colour! Seems to be between the two colours in your issue)In #616, there was a difference made between rbg and rgb_linear
Color::INDIGOis set up usingrgb_linearbevy/crates/bevy_render/src/color.rs
Line 45 in 72b2fc9
If I take the same values and use them as rgb, I get the expected colour:
I'm not very fluent in colour spaces, so would be great if someone that knows those better could take a look at it
TheZalli commentedon Jan 4, 2021
I've read some on color spaces, but to spare you the details (although I do believe every game programmer should understand the basics about sRGB and gamma correction), when describing colors you most often want to avoid using the linear colors that haven't been gamma corrected. They are used only when mixing and blending colors, and when sending them to the screen (most often done automatically by the GPU in a shader).
When giving color values, they should always be in sRGB (the standard RGB space, aka gamma corrected), and this is the colorspace that all programs use when interfacing with users (the values they give, and what you give).
TLDR:
change it from linear to srbg, which is the
Color::rgbfunction.Edit: actually looking at it, I guess you can't since
Color::rgb_linearis a const function, andColor::rgbisn't, and looking at Rust reference it can't be since it has float operations. I guess just convert the value from sRGB to linear by-hand, and change the function's parameters. And check the other color constants as well, doing the same operation if they're likewise weird looking.sburris0 commentedon Jan 13, 2021
I noticed this and did some testing,
rgb_linear()seems to always produce much lighter colors than expectedColor::MIDNIGHT_BLUEis pretty light.tigregalis commentedon Jan 16, 2021
I grabbed the list of 148 (139*) "named colours" in CSS to generate this code using bevy's own
Colorfunctions. Do we want this full list?This is Indigo:
*duplicates are:
mockersf commentedon Jan 16, 2021
Yes... and no 😃
The full fix would be to have a
constfunction to create colours with standard rgb hex. To do that, this TODO should be donebevy/crates/bevy_render/src/color.rs
Line 14 in cf0e9f9
But fixing the colours to have the correct value in linear until this is done is better than what we have now.
tigregalis commentedon Jan 18, 2021
So the list that's currently in Bevy is a smaller subset of that.
I'll submit a PR later for all of the CSS colours using the generated values. I personally think it's worth having.
Maybe I'll have a go at this a bit later on. What should these types be called?
Relevant discussion: #688
mockersf commentedon Jan 18, 2021
I would go with
Colorfor the standard one that everybody is used to, andLinearColorfor the linear variant, that is the one we have currentlycolor spaces and representation (#1572)