-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add support for alpha-testing in sprite picking backend #14929
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
Comments
Correct me if I'm wrong but I think one use case for this is when you have rounded button images/sprites? For those, at least in my case, I don't want to trigger the interaction on the transparent pixels, i.e. only trigger interactions on clicks inside the round parts of the image. In that case, I'd agree I expected this behavior by default. This issue is for the sprite picking backend, but is there any overlap with doing this for existing bevy UI buttons with images? I have some UI buttons with a |
For the case of rounded buttons specifically, we should be able to do a faster test. I agree that that should be on by default though. But yes, new issue please! It should be fixed in its own PR. |
Seconding this, it'd be very useful in the project I'm working on right now |
…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 (#16388) # Objective - Allow bevy_sprite_picking backend to pass through transparent sections of the sprite. - Fixes #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]>
Originally posted by @aevyrie in #14757 (comment)
We can either add a whole new backend for this, or add a configuration option to the existing backend. Checking the alpha value of each pixel is more expensive but more intuitive and should be enabled by default with a way to toggle it off.
The text was updated successfully, but these errors were encountered: