-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add optional transparency passthrough for sprite backend with bevy_picking #16388
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
Add optional transparency passthrough for sprite backend with bevy_picking #16388
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
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’m excited for this change. I did a quick visual code review but haven’t tested it yet.
/// Off by default for backwards compatibility. This setting is provided to give you fine-grained | ||
/// control over if transparency on sprites is ignored. | ||
pub passthrough_transparency: bool, | ||
/// How Opaque does part of a sprite need to be in order count as none-transparent (defaults to 10) |
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.
Can you elaborate in the docs what the units are? 10 what? What is a valid range I could use, as a user?
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.
Can these two options be combined into a single enum? It doesn't make sense to have an alpha cutoff setting when alpha passthrough is disabled. e.g.
SpritePickingAlphaTest {
/// Don't test alpha, only consider the rect of sprites.
Ignore,
/// Test the pixel alpha when running hit tests. Alpha values below this will not be considered for picking.
Threshold(u8)
}
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.
Yeah an enum is probably a better idea for those settings. Will rework to include.
Seems everyone agrees that this should be enabled by default so I've updated that and introduced a new |
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
Can you add a small migration guide explaining that this is now on by default? Definitely the better default, but could break existing users. |
Added. Hope that's ok and clear? |
The migration guide was clear and effective, but the tone / target audience was a bit weird. The goal is to communicate "why is my stuff broken and how do I fix it", but your initial draft was closer to a change log :) I've quickly edited the PR description incorporating the information you've added. These get automatically scraped / compiled, so it's good to clean them up here. |
… in picking_backend. Previously SpriteBackendSettings was private, making it impossible to change the SpritePickingMode. Now we can!
This is already taken care of in `compute_pixel_space_point`.
This matches the `SpritePickingPlugin`.
…cking (bevyengine#16388) # Objective - Allow bevy_sprite_picking backend to pass through transparent sections of the sprite. - Fixes bevyengine#14929 ## Solution - After sprite picking detects the cursor is within a sprites rect, check the pixel at that location on the texture and check that it meets an optional transparency cutoff. Change originally created for mod_picking on bevy 0.14 (aevyrie/bevy_mod_picking#373) ## Testing - Ran Sprite Picking example to check it was working both with transparency enabled and disabled - ModPicking version is currently in use in my own isometric game where this has been an extremely noticeable issue ## Showcase  ## Migration Guide Sprite picking now ignores transparent regions (with an alpha value less than or equal to 0.1). To configure this, modify the `SpriteBackendSettings` resource. --------- Co-authored-by: andriyDev <[email protected]>
…cking (bevyengine#16388) # Objective - Allow bevy_sprite_picking backend to pass through transparent sections of the sprite. - Fixes bevyengine#14929 ## Solution - After sprite picking detects the cursor is within a sprites rect, check the pixel at that location on the texture and check that it meets an optional transparency cutoff. Change originally created for mod_picking on bevy 0.14 (aevyrie/bevy_mod_picking#373) ## Testing - Ran Sprite Picking example to check it was working both with transparency enabled and disabled - ModPicking version is currently in use in my own isometric game where this has been an extremely noticeable issue ## Showcase  ## Migration Guide Sprite picking now ignores transparent regions (with an alpha value less than or equal to 0.1). To configure this, modify the `SpriteBackendSettings` resource. --------- Co-authored-by: andriyDev <[email protected]>
…cking (bevyengine#16388) # Objective - Allow bevy_sprite_picking backend to pass through transparent sections of the sprite. - Fixes bevyengine#14929 ## Solution - After sprite picking detects the cursor is within a sprites rect, check the pixel at that location on the texture and check that it meets an optional transparency cutoff. Change originally created for mod_picking on bevy 0.14 (aevyrie/bevy_mod_picking#373) ## Testing - Ran Sprite Picking example to check it was working both with transparency enabled and disabled - ModPicking version is currently in use in my own isometric game where this has been an extremely noticeable issue ## Showcase  ## Migration Guide Sprite picking now ignores transparent regions (with an alpha value less than or equal to 0.1). To configure this, modify the `SpriteBackendSettings` resource. --------- Co-authored-by: andriyDev <[email protected]>
…cking (bevyengine#16388) # Objective - Allow bevy_sprite_picking backend to pass through transparent sections of the sprite. - Fixes bevyengine#14929 ## Solution - After sprite picking detects the cursor is within a sprites rect, check the pixel at that location on the texture and check that it meets an optional transparency cutoff. Change originally created for mod_picking on bevy 0.14 (aevyrie/bevy_mod_picking#373) ## Testing - Ran Sprite Picking example to check it was working both with transparency enabled and disabled - ModPicking version is currently in use in my own isometric game where this has been an extremely noticeable issue ## Showcase  ## Migration Guide Sprite picking now ignores transparent regions (with an alpha value less than or equal to 0.1). To configure this, modify the `SpriteBackendSettings` resource. --------- Co-authored-by: andriyDev <[email protected]>
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1961 if you'd like to help out. |
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1966 if you'd like to help out. |
# Objective - Docs in sprite picking plugin / example contain outdated information. References: - Sprite picking now always require `Picking` - bevyengine#17842 - Transparency pass-through added - bevyengine#16388 ## Solution - Fix the docs.
Objective
Solution
Testing
Showcase
Migration Guide
Sprite picking now ignores transparent regions (with an alpha value less than or equal to 0.1). To configure this, modify the
SpriteBackendSettings
resource.