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

Hit-test-only masks #543

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

ggcrunchy
Copy link
Contributor

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 to true 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.

ggcrunchy and others added 23 commits February 7, 2019 17:09
…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
@ggcrunchy ggcrunchy requested a review from Shchvova as a code owner April 2, 2023 00:26
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants