-
-
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
ClearColor and Sprite same value yields different color #4356
Comments
Good find. Thanks for the excellent issue and report. Under the hood, I bet this has something to do with linear vs sRGB colors. |
Issue is that |
Is it confirmed that this is a rounding issue? I would have expected the rgb value to be off by one in that case but the values are Even considering |
I can reproduce the issue, and it is fixed by #4357, so I'm fairly certain it's a rounding issue somewhere |
Didn't see the PR, thanks for elaborating. I tried it with a few different colors and they all seem to match up. Though, I would prefer a different fix if I'm honest. With #4357 I'm not able to set accurate clear colors using I guess it's because the quantization to |
I'm relatively certain that this is from our sprite rendering code, which converts the input color to u8s and stores them in a single u32 vertex attribute. (see vertex_color in If anything this is a "bug" there. One fix would be to pass each float in individually as a |
IMO the most important thing is accurate color. As a user I would expect the colors in my sprite to match my drawing program. |
I'm not sure this is so much a bug as a "known limitation" that should be documented... This would only be visible when using the sprite color instead of an image, which doesn't feel like the main feature. |
"wrong color" is a bug imo (but i agree that this is a matter of perspective). these things should "just work" in a way that is compatible across features. if an artist cant easily say "i want this sprite to be the same color as the background", thats on us to fix i think (and probably takes precedence over optimization, at least for defaults) |
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
commands.spawn_bundle(SpriteBundle {
transform: Transform::from_xyz(50.0, 0.0, 0.0),
sprite: Sprite {
color: BG_COLOR,
custom_size: Some(Vec2::new(100.0, 100.0)),
..Default::default()
},
..Default::default()
});
commands.spawn_bundle(MaterialMesh2dBundle {
mesh: meshes.add(Mesh::from(shape::Quad::default())).into(),
transform: Transform::default()
.with_scale(Vec3::splat(100.0))
.with_translation(Vec3::new(-50.0, 0.0, 0.0)),
material: materials.add(ColorMaterial::from(BG_COLOR)),
..default()
});
} the |
# Objective - Fix bevyengine#4356 ## Solution - Do not reduce the color of sprites to 4 u8
# Objective - Fix bevyengine#4356 ## Solution - Do not reduce the color of sprites to 4 u8
Bevy version
Bevy 0.6.1
Operating system & version
Pop!_OS 21.10 x86_64
What you did
Set a sprite and the background to the same rgb value
What you expected to happen
The rectangle sprite should be indistinguishable from the background.
Only one color should be visible.
What actually happened
The sprite (center) renders slightly darker than the background.
The text was updated successfully, but these errors were encountered: