-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Hit-test-only masks #543
Open
ggcrunchy
wants to merge
27
commits into
coronalabs:master
Choose a base branch
from
ggcrunchy:MaskFromBitmap2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hit-test-only masks #543
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nd buffer and assignment logic Next up, prepare details from graphics.defineEffect()
…from Program Slight redesign of TimeTransform with caching (to synchronize multiple invocations with a frame) and slightly less heavyweight call site
Err, was calling Modulo for sine method, heh That said, time transform seems to work in basic test
Fixed error detection for positive number time transform inputs Relaxed amplitude positivity requirement
Maintenance Revert Test
My mistake adding back changes made
This reverts commit 0b5e1e9.
…t-only masks (probably not the issue, but paranoid :) ) Doing no-bitmap test before trying to make paint, to avoid bool pointer (much more suspect) Workaround for Windows doing double-lock (non-issue with another upcoming PR) Wasn't passing along hit-test-only-ness through CreateAndAdd() File-based technique seems to not work
Shchvova
approved these changes
Apr 18, 2023
Shchvova
approved these changes
Apr 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Basically, this is for the case where you want the hit-testing feature of masks, but don't need their graphical effect. This avoids their VRAM cost, as well as batch-breaking that results from the change in mask texture.
Furthermore, if your display object uses a bitmap you can have it sample that directly, and never load an actual mask asset.
On at least some platforms, there are performance costs when computing a loaded mask's grayscale values (future PR), but of course if you skip the load altogether you'll only pay for the bitmap, which you're already doing.
This came up while @mark-sgs and I were testing some stuff on the experimental build—since it flushed out some performance issues at scale—although this PR is independent of said build.
--
This adds two new functions:
mask = graphics.newHitTestOnlyMask( filename[, baseDir] )
mask = graphics.newHitTestOnlyMaskFromPaint( [opts] )
The first one loads from a file as usual, but has no GPU presence. The latter will pick up the display object's image or bitmap paint instead.
At the moment there are no actual
opts
. I thought small non-0 alphas might be a problem, so this was available for threshold tuning, but so far that hasn't been an issue.Support for image sheets would be an obvious future improvement / need, but bitmaps are already useful.
--
Here's my test:
test mask thing.zip
You can set
TestMaskFromPaint
totrue
to do a bitmap-based test, else use a mask file.In the former case the background will blink if you touch it and not the little image. In either test you'll get a printout of the touch phase when clicking on the image.