-
-
Notifications
You must be signed in to change notification settings - Fork 291
Capture-type texture resource #361
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
Capture-type texture resource #361
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.
…ws already, via other repository)
Refined rounding for capture rect (was one too much on Android, often) Rogue files
Added bool output to HasFramebufferBlit() to detect scalability, added NV_framebuffer_blit too (which would provided it even in GL ES) Added gpuSupportsScaledCaptures option to system.getInfo()
…it fights with some default settings (multisample stuff)
I was discussing the Vulkan backend with somebody earlier and I just realized that Anyhow, they're fairly trivial changes and I have them at hand if needed. |
This is a new type of texture resource.
We can create a texture of a certain size—typically the viewable content—and spawn "event" objects: rather than draw to the screen, these will capture its contents to the texture. We can then sample this texture for our own images and effects.
Events "happen" (rather than draw) according to where they are in the display hierarchy: back-to-front, first-to-last. The event should be found before an object that wants to use it.
Kan posted a nice example on Discord, based on a preview version.
It's implemented with
glBlitFramebuffer
, when available; otherwiseglCopyTexSubImage2D
.Seems to pass muster on Mac (M1), Windows, Android (emulator and device), iPhone and tvos (emulators).
I piggybacked the new classes,
TextureResourceCapture
andTextureResourceCaptureAdapter
, into the corresponding canvas texture files. This was only to avoid adding new files and updating projects / makefiles; it would be fine to migrate them into their own files, if desired.I made
GetParent()
a public method ofLuaLibDisplay
so that the capture event object could also use it. (This is also in the adapter file.)I added some
ContentToScreen()
variants that don't do rounding. These might also have applicability elsewhere, e.g. thedisplay.capture()
family.As mentioned in the next section, there is still a tiny bit of shimmer if capturing and immediately redisplaying in-place, possibly just a pixel in either dimension. It might be possible to solve even this, but didn't seem pressing.
Here's a sample:
capture.zip
The part in the green outline may be dragged around. This will drag the outline, the capture event object, and a circle that immediately redraws the captured contents: apart from a little shimmer, it resembles the background, as it should.
The captured contents are also drawn to a couple outlined rects along the right side.
Further, the rounded rect on the left captures one of those capture-displaying rects along with part of its neighborhood. The event object is later in the hierarchy than the green outline, so will show that, too, if it was in view.
Finally, the part up top shows a different area; however, its capture texture is the same as that for the rounded rect. This demonstrates that we can capture more than once, using separate event objects: an image will use the current result. (Due to its sequencing, this capture can also pick up the green outline.)
I also removed a few
// STEVE CHANGE
things that snuck into past PRs.Some rough docs:
and
About the disabled scaling:
On Mac, where I first tested everything, the view surface is created with some multisampling stuff. Other platforms might do likewise.
Unfortunately, rescaled draws require our target texture also have this information. It seemed annoying to try to make these agree—on either side—thus the disabling for now.
It did appear to work when stripping that stuff from the view surface configuration.
On Android, there seems to be a
GL_EXT_blit_framebuffer_params
extension. (My own phone had neither this nor theANGLE
andNV
extensions I'm checking.) The only reference to this I've seen online was... in extension lists. sighIt certainly sounds relevant, and I have guesses about what it might do, but probably will have to ask in a Khronos forum / server or something for actual details. At any rate, the
glCopyTexSubImage2D
approach seemed to run okay.