In the case I"m thinking of I'd like to explicitly composite snapshotA over snapshotB (subtract, add, whatever), snapshotC over snapshotD, then composite the resulting B and D over whatever happens to be on the screen below it.

rakoonic2

[GLOBAL: userInfoPane.html]

rakoonic2

Contributor

503 posts

Corona SDK

20 October 2013 - 10:19 AM

Walter, regarding snapshots - have you given any more thoughts to my suggestion that they stop being an actual image (of sorts), and instead become a factory resource a la imagesheet, so you can spawn sprites from them? I can't think of any other conceptual way of having multiple images sharing a single snapshot that doesn't end up with a system that is alien to corona's current way of doing things?

I wouldn't assume that snapshots will just be used for rendering to the screen - at least, not directly. Their greatest strengths are to use them as more than just a filterable container anyway

What I envisage is that a snapshot works as it does, but you can't apply it directly to the screen. You'd need to spawn images from it, which gives you the ability to clone them. Something like:

Or, and this would be even more awesome - make it so you can create image sheets from a snapshot - this would add a TON of useful abilities (for example I am stuck in a demo I am working on because I need to create 10 strips from a single snapshot - currently the only way to do it is to cycle through them 1 at a time per frame).

Creating spritesheets and animations from a snapshot might not seem very intuitive, but being able to spawn sprites based on only sections of a snapshot would greatly increase flexibility, and make the snapshot very useful for setting up graphics to be re-used throughout the project.

chrislott

rakoonic2

[GLOBAL: userInfoPane.html]

rakoonic2

Contributor

503 posts

Corona SDK

21 October 2013 - 04:33 PM

Last two posts = most eloquence ever seen in this forum - I am in total agreement.
Walter, my only concern is that I'm not fully conversant on the behaviour of fills - as long as an image based upon a snapshot (however it is done, via fill or cloning or something) distorts properly when you do things like distort in 2.75d etc then I'm going to be a happy bunny

uuela9971

[GLOBAL: userInfoPane.html]

uuela9971

Enthusiast

64 posts

Corona SDK

24 October 2015 - 05:53 AM

we are converting snapshot images into png files via Flash and using as image files, we have had some successful results with scaling small simple objects. We have not looked into any bump mapping yet. Testing the idea of setting these up in sprite sheets for object textures. We are going to try building the sprite sheets using texture packer.

vlads

[GLOBAL: userInfoPane.html]

vlads

Contributor

610 posts

Corona Staff

26 January 2016 - 07:15 PM

Hello, everyone!
So here is a new feature. Give it a spin, we would like to get your feedback on it.
Half a year ago we introduced texture apis. Building on that API here is modifiable texture. It resembles Snapshot object, but it is quite different, even if APIs may seem similar.

New feature is TextureResourceCanvas type. It is in-memory texture, you can render stuff into it, and than assign it to other objects. Note that you can assign it to several different objects.
It is a subject to manual texture management, so beware of memory leaks. If you don't use it anymore, you have to release it. After you release it, you're loosing pointer Lua handle to it, but Display Objects using it would not become invalid.

Here width and height here is dimensions of canvas where you would draw your objects, basically dimensions of visible world in canvas.Pixel width/height - size of underlying texture. If omitted, this values would be selected to correspond to pixel dimensions of display object with width/height. You can set it to like 32 for cool pixely effects (with proper scaling modes), or just some other number, for example to save memory etc.

After it is created you can assign it to the fill to other objects. Use "canvasTexture.filename" and "canvasTexture.baseDir" pretty much anywhere where those parameters are expected. For example, in composite paint or creating image rect:

This call would schedule to render objects in internal queue before next frame, and after rendering them it would move them to cache.
You can also set custom background colour. This colour would fill the texture when it is cleared.

Canvas texture resources has a lot of fun applications, but also some limitations. Like nested textures can work weirdly, or native objects would not work at all.

Also, there is no possibility to add setPixel/getPixel. Textures are stored on GPUs and do not provide direct buffer access.

Also, I rewrote snapshot paint example, to use canvas. It has fire in the middle to demonstrate manual updates. It is attached to this post. Also, some other random example with star in it and composite paint.

It takes an image of your choice and the brush from the CanvasPaint example (probably should have just used a circle, since the brush has its own alpha and you get a peculiar tapering fade).

When you run it, drag around on the screen to paint in time values, which gradually increase from 0 to 1, going into the red channel. Once it hits 1 it stops painting.

Click the red circle when you're ready and the effect's time threshold will transition from 0 to 1, unveiling pixels with the right time values. You can adjust the "// check time vs. uv" line to change the behavior.

This is a pretty boring proof of concept. The idea can get a lot fancier, though.

This kind of thing compiles and runs, but I seem to be consistently getting "black", suggesting the sampler is unbound.

Are there complications in Corona's surrounding boilerplate, or am I just missing something obvious here?

(This is on Windows and I do have a way to detect that vertex texture units are available beforehand, although it's pretty clumsy: basically, a dummy pixel with an auxiliary shader that branches on gl_MaxVertexTextureImageUnits, followed by display.colorSample() and such.)

Also, might legitimate VTF support be a possibility? I think this would bring a lot of power in situations similar to my own.

vlads

[GLOBAL: userInfoPane.html]

vlads

Contributor

610 posts

Corona Staff

31 January 2016 - 06:01 PM

I don't see where you can bound this sampler. We're bounding textures to CoronaSampler0 (also to CoronaSampler0 if you use composite paint). Try using CoronaSampler0 instead of u_FillSampler0, and don't declare it, it's already declared & bound.

EDIT: I see it, it is in our sample. Well... basically CoronaSampler# is a synonym to u_FillSampler#. Use that instead and don't declare it.

StarCrunch

[GLOBAL: userInfoPane.html]

StarCrunch

Contributor

787 posts

Corona SDK

02 February 2016 - 05:05 PM

@vlads Well, I've got a good proof of concept going for what I was after: mesh test

It seems to be working well on Windows desktop but on somebody else's OSX machine it's not. (On the latest daily build, too.) His screenshots from OSX were consistent with the texture not being read. I haven't attempted on a device.

This basically tests two approaches. In the first, when vertex texture fetch is available, positions and uvs are stored in a texture. Otherwise, positions (which must change) are stored in vertex userdata and uvs plus offsets-to-uvs are stored in the texture. Both techniques are used to sculpt some boring stock triangles into arbitrary ones dynamically.

Actually, if anybody else reading this would care to give the linked code a spin on Windows and / or OSX desktop (or device, I guess, though I'm not sure it's ready) and confirm (or not) what I said above, it'd be most appreciated!