-
-
Notifications
You must be signed in to change notification settings - Fork 287
Hit-test-only masks #543
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
base: master
Are you sure you want to change the base?
Hit-test-only masks #543
Conversation
…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
See more details in this [pull request](coronalabs#543).
See more details in this [pull request](coronalabs#543).
Hello! |
@zero-meta It's been a while since I've touched this, but maybe I can take a look in a couple days. Is the scaled-up image also getting clipped too early? Strangely, I was actually thinking about this PR, in light of #751 and #760. I mentioned in DMs (April 10, 2023) to @Shchvova that "Apparently (this PR) has SIGBUS errors on SOME Android devices. I have a feeling it's the This commit (not sure if any others) was an attempt to work around that, but is rather convoluted and I wonder if just (Looks like that's ed674ef in the local list.) Probably the filename encoding (earlier stuff) is also iffy. I remember trying to work around some quirk in the interface, but the details escape me, unfortunately. Possibly just not wanting to add more members to Anyhow, I doubt they're related to the issue in the video, but these are things I never found satisfying. |
Thanks for replying! local fall = display.newImageRect("fallx2.png", 1024, 1024)
local mask = graphics.newHitTestOnlyMaskFromPaint()
fall:setMask(mask) I haven't tested on enough Android devices, and haven't encountered "SIGBUS errors" yet. |
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.