Skip to content
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

Upstream bevy_color_blindness #5606

Closed

Conversation

annieversary
Copy link

@annieversary annieversary commented Aug 7, 2022

This PR upstreams bevy_color_blindness, as discussed in #2724.

As mentioned in that issue, we would ideally have this be a submodule in bevy_render, in order for it to be well-integrated and not it's own segmented niche. Due to cyclic dependencies that's not possible, so for the time being I'm adding it as a top-level crate, pending further discussion.

I've also copied over the main example from bevy_color_blindness, under a new Accessibility category, as a temporary thing.


Changelog

  • Added bevy_color_blindness as a top-level crate.
  • Added examples/accessibility/color_blindness_simulation.rs.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really in a position to judge if this is a good thing to actually have, but it can only be good to have that conversation

I'm by no means a rendering expert, but I've put in a conversation starter

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen A-Accessibility A problem that prevents users with disabilities from using Bevy labels Aug 7, 2022
@alice-i-cecile
Copy link
Member

Lots of feedback, but to be clear I think that this is incredibly valuable, and a fantastic foundation. Feel free to push back if you think I'm wrong; I'm not a rendering expert.

@MrGVSV
Copy link
Member

MrGVSV commented Aug 7, 2022

To avoid the list of bevy crates from growing too large, would it make sense to put this into a bevy_a11y crate or something? Then other upstreamed a11y helpers can be grouped in there as well.

///
/// [`UiCameraConfig`]: bevy_ui::entity::UiCameraConfig
#[derive(Component)]
pub struct ColorBlindnessCamera;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this ColorBlindCamera? The camera itself is color blind and thus simulates how a color blind person would see the game.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about this. It sounds nicer, but I think having all types except one have the -ness suffix would lead to confusion.

@alice-i-cecile
Copy link
Member

To avoid the list of bevy crates from growing too large, would it make sense to put this into a bevy_a11y crate or something? Then other upstreamed a11y helpers can be grouped in there as well.

As I said in the linked issue, I'd really like to avoid isolating accessibility features off on their own. Accessibility is a core requirement, not something to be tacked on at the end. Down the line, I think this probably belongs in something like bevy_postprocessing or bevy_render, but there are some circular dependency troubles that block that for an initial attempt.

@Vrixyz
Copy link
Member

Vrixyz commented Aug 7, 2022

I was the author of the PR for the post-processing example, allow me to link a few relevant discussions which we might want to address:

Window resizing

Full screen triangle

#4797 (comment)

It's discussing 2 things:

  • Prefer a triangle to a quad
  • using a vertex shader to generate the mesh rather than a cpu bound one.

I'll keep an eye on this PR, I suspect this could lead to improve the post processing example 👍

Comment on lines +18 to +34
@fragment
fn fragment(
@builtin(position) position: vec4<f32>,
#import bevy_sprite::mesh2d_vertex_output
) -> @location(0) vec4<f32> {
// Get screen position with coordinates from 0 to 1
let uv = position.xy / vec2<f32>(view.width, view.height);

var c = textureSample(texture, our_sampler, uv);

return vec4<f32>(
c.r * p.red.x + c.g * p.red.y + c.b * p.red.z,
c.r * p.green.x + c.g * p.green.y + c.b * p.green.z,
c.r * p.blue.x + c.g * p.blue.y + c.b * p.blue.z,
c.a
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see an informed comparison with the approach linked in the associated issue: https://github.com/electronicarts/Tunable-Colorblindness-Solution

I translated into bevy if it can help to make a comparison : https://github.com/Vrixyz/bevy/blob/colorblind/assets/shaders/colorblind.wgsl

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not well-versed enough in the mess that is the world of colors to be able to provide any sort of comparison, much less an informed one '^^. Is there any Bevy contributor who does and would be able to help us with this?

@MrGVSV
Copy link
Member

MrGVSV commented Aug 7, 2022

As I said in the linked issue, I'd really like to avoid isolating accessibility features off on their own. Accessibility is a core requirement, not something to be tacked on at the end. Down the line, I think this probably belongs in something like bevy_postprocessing or bevy_render, but there are some circular dependency troubles that block that for an initial attempt.

Oh whoops didn't read the full thread haha. Sure that makes sense and it'd be really great if a11y was treated as a vital part to the crate(s) they affect. That being said, though, it might be worthwhile to group them into their own crate to act as an intermediate step before fully integrating them (if they need an intermediate step, integration isn't straightforward, dependency issues, etc.). Just to get them in quickly and worry about refactoring/integrating in the future. Or to be a place for tools/APIs that might not fit into any one crate otherwise.

But if this isn't actually as good an idea as I think it is I totally understand haha

@inodentry
Copy link
Contributor

Regarding the question of "should we be splitting things into crates, or integrating into existing crates", I'd like to propose the following consideration: having a larger number of smaller crates is more scalable.

Typical bevy users already depend on bevy as a whole, and access everything via reexports or prelude. In practice, there isn't much difference to user convenience or how practical the features are to use, from them being split into more crates.

bevy_render is huge, and a big bottleneck in compile times (as sprite/ui/pbr/etc all depend on it). Let's avoid stuffing it with even more stuff if possible.

Copy link
Member

@NiklasEi NiklasEi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new crate should also be added to the publishing script tools/publish.sh.

@alice-i-cecile alice-i-cecile added this to the Bevy 0.9 milestone Aug 8, 2022
@Vrixyz
Copy link
Member

Vrixyz commented Aug 8, 2022

Depending on how long future discussions/feedbacks take, this PR might be a good candidate for bevy nursery bevyengine/rfcs#63

@alice-i-cecile
Copy link
Member

Yep, this was one of the crates that prompted that discussion for me :)

This commit moves `mode` and `enabled` into `ColorBlindnessCamera`,
which allows for multiple cameras with different modes.

This should allow multiple windows to work correctly, but it hasn't been tested yet.
@annieversary annieversary force-pushed the upstream_bevy_color_blindness branch from 02568fd to aa0fcb0 Compare August 14, 2022 18:00
@annieversary
Copy link
Author

These last commits fix a bunch of stuff that was previously mentioned:

  • ColorBlindnessCamera is now the only thing required (no more ColorBlindnessParams), which allows different cameras to have different modes.
  • Uses the camera's render target to decide the size for the quad. No more relying on the primary window.
  • Respects the camera's render target: the new post-processing camera will have the same target as the original camera.

All of this stuff should make multiple/no windows work, but I haven't tested it yet cause I'm not too familiar with how that works. The existing example continues working correctly.

});
}

fn change_mode(input: Res<Input<KeyCode>>, mut cameras: Query<&mut ColorBlindnessCamera>) {
Copy link
Member

@Vrixyz Vrixyz Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nitpick, to avoid useless computations when input didn't change:

fn change_mode(input: Res<Input<KeyCode>>, mut cameras: Query<&mut ColorBlindnessCamera>) {
    if !input.is_changed() {
        return;
    }

Edit: as noted below, it's not useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works - Input is always updated iirc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed! Thanks for the correction

Copy link
Contributor

@Weibye Weibye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and is a needed and necessary component to the engine as a whole :) I would be happy getting this in as-is.

@mockersf
Copy link
Member

mockersf commented Sep 5, 2022

I don't think this should be included in Bevy. At least not yet.

It is a dev tool to simulate color blindness and should be part of an editor, not something needed in a game directly that would modify automatically the colors to accommodate for color blindness

@alice-i-cecile
Copy link
Member

It is a dev tool to simulate color blindness and should be part of an editor

@mockersf has convinced me. @annieversary, hopefully this review process has been helpful to you (and your code upstream), and I very much welcome you to submit this as an editor tool once we're there!

annieversary added a commit to annieversary/bevy_color_blindness that referenced this pull request Sep 6, 2022
@Selene-Amanita
Copy link
Member

I'm not sure I'm understanding the reasoning to close this PR. I agree it is a dev tool, but I don't see why it should be linked to an editor?

Ideally, if I want to make a game and make sure that it's playable by people with various levels of color-blindness, I wouldn't just view my scenes through an editor and call it a day. If I have enough resources I would make colorblind people play it, but if I have just a handful of playtesters I would want to give some of them a colorblind emulation version of the game, or if I'm by myself I would like to fully play the game with this mode myself at least.

Shouldn't there maybe be a bevy_devtools that would have all the stuff you want to make sure you don't ship with the game at the end but you might want for dev, stuff like colorblindness emulation, DebugName, gizmos, wireframe, ... ?

@Vrixyz
Copy link
Member

Vrixyz commented Jun 17, 2023

Another reason why this PR didn't make it is that the post processing method used was more a "hack" than "the good way", it's based on an old post-processing example. Now bevy main has an updated example, and I think an "official" plugin should use that updated code as its base, it supports resizing out of the box, and doesn't impact the world with arbitrary mesh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Accessibility A problem that prevents users with disabilities from using Bevy A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.