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

Add support for alpha-testing in sprite picking backend #14929

Open
alice-i-cecile opened this issue Aug 26, 2024 · 3 comments · May be fixed by #16388
Open

Add support for alpha-testing in sprite picking backend #14929

alice-i-cecile opened this issue Aug 26, 2024 · 3 comments · May be fixed by #16388
Labels
A-Picking Pointing at and selecting objects of all sorts C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon

Comments

@alice-i-cecile
Copy link
Member

              > Not sure what you mean by "test against alpha". Could you elaborate? EDIT - By that, do you mean whether or not the sprite is visible due to alpha/invisible texels? I'll add docs for that.

Exactly. I think most users would expect fully transparent pixels to not be hittable. Might be something where the backend/component specifies a threshold, so any alpha below that value will be ignored. Doesn't need to be added right now, but would be nice to mention in the plugin docs.

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.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes A-Picking Pointing at and selecting objects of all sorts X-Uncontroversial This work is generally agreed upon labels Aug 26, 2024
@mgi388
Copy link
Contributor

mgi388 commented Aug 27, 2024

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 UiImage as its child, and I've wanted a way to avoid triggering interactions when clicking on the non-rounded parts. The sprite picking backend operates on Sprites only, so I don't expect this new picking backend to work for UiImages. It's fine if the answer is "that's a new issue", but I did wonder if they were somehow covered by the same approach.

@alice-i-cecile
Copy link
Member Author

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.

@jessicamaybe
Copy link

              > Not sure what you mean by "test against alpha". Could you elaborate? EDIT - By that, do you mean whether or not the sprite is visible due to alpha/invisible texels? I'll add docs for that.

Exactly. I think most users would expect fully transparent pixels to not be hittable. Might be something where the backend/component specifies a threshold, so any alpha below that value will be ignored. Doesn't need to be added right now, but would be nice to mention in the plugin docs.

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.

Seconding this, it'd be very useful in the project I'm working on right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Picking Pointing at and selecting objects of all sorts C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@alice-i-cecile @jessicamaybe @mgi388 and others