Grab WebGL canvas of a Sprite

For developers using the Construct 2 Javascript SDK

Post » Wed Oct 31, 2012 8:53 am

The question is more specifically for @Ashley.

For some examples and plugins I'm planning to create, it would be useful to grab a Sprite on which a shader has been applied. I can now easily grab the <img> of a Sprite, when WebGL isn't used. However, I don't know what and where to grab to get that (because you can't easily convert a WebGLTexture back to a <canvas>).
@Ashley is there an easy way to do that ?
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Wed Oct 31, 2012 2:21 pm

You mean you want to grab the image of a sprite with a shader applied?

The shader compositor (which runs all the effects) is one of the most difficult and complicated parts of the engine. I don't think this will be at all easy to do, and possibly very slow (since it might depend on retrieving pixel data). I'm afraid I can't see an easy way to do this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Wed Oct 31, 2012 4:07 pm

@Ashley : OK. I'm a bit sad, because having the possibilty to retrieve effects applied on Sprites would be great for a few things...

I have another questions about shaders. The Sprite is seens as a quad with four vertices. So there is no need for a vertex shader.
However, having the possibility to tesselate to quad can open the possibility to apply vertex shaders on the tesselated Sprite. That would help to create crumpled paper effects on a Sprite, or page flip. Are you planning to add a more refined way to deal wth vertex shaders, or is it out of the scope of C2 ?
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Wed Oct 31, 2012 5:34 pm

It's out of the scope of C2 for the moment, the shader compositor does not support vertex shaders at all right now (and I dread to think how complicated it would be to add them...)

We might eventually add something like mesh distortion from Classic back in, but it's a very complex feature to get right. Users expect the collision mask is distorted the same way and so on, and used incorrectly it can cause performance problems too.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Wed Oct 31, 2012 5:41 pm

[QUOTE=Ashley]We might eventually add something like mesh distortion from Classic back in, but it's a very complex feature to get right. Users expect the collision mask is distorted the same way and so on, and used incorrectly it can cause performance problems too.[/QUOTE]
Very much please add this feature! Even with the collision mask not distorted with the image, it's very useful and awesome and I utterly loved it in CC. I also found ways to make my own distorted collision mask using invisible sprites.

What do you mean by "used incorrectly" though? For reference if it ever gets put in, so I can know what to avoid.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Wed Oct 31, 2012 6:45 pm

@Arima - if you make the columns/rows high, so there are say 400-1000 cells, then spawn a few instances, you could easily be reaching the equivalent rendering demand of 10,000 sprites.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Wed Oct 31, 2012 8:11 pm

@Ashley : OK, thanks for the answer.
I was thinking about that because when I people were asking for a Mode7 shader, I realised that without vertex shader, it's going to be difficult to do it properly.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Wed Oct 31, 2012 8:40 pm

@Pode I think it's possible to simulate Mode7 using only a pixel shader. I will try some ideas, but I think it's doable.

Too bad it's not that easy to grab the image of a sprite with a shader applied. :/

I was counting on R0j0 updating his canvas plugin to allow me to create some iterative shaders to simulate fluids like smoke, air flows, possibly water, etc.

I did this once in CC. But to be doable there needs to be a way to use the output of the last frame as the input of the next one.Animmaniac2012-10-31 20:43:38
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Wed Oct 31, 2012 8:56 pm

[QUOTE=Ashley] @Arima - if you make the columns/rows high, so there are say 400-1000 cells, then spawn a few instances, you could easily be reaching the equivalent rendering demand of 10,000 sprites.[/QUOTE]

Why can't we just go with poly's rather than rows/ columns?
Its not like we don't use them for collisions already.
Granted its slower, but I think we've crossed that bridge already.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Thu Nov 01, 2012 1:13 am

@newt - sometimes you want a lot of rows but just one column, e.g. to make an archway.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests