Javascript SDK template r101 update

For developers using the Construct 2 Javascript SDK

Post » Mon Sep 03, 2012 3:13 pm

Hi all,

The Javascript SDK has been updated for r101. Download here:

http://www.scirra.com/downloads/javascript-sdk-template.zip

Changes

- New edittime flags for plugins:
pf_effects: allow WebGL shader effects to be added to objects. Must be added to any plugins that draw in order to enable WebGL effects on that object.
pf_predraw: add to any plugins that do not draw like a sprite (i.e. don't just draw a single image at the size of the object). This is necessary for WebGL effects to work properly on objects which do advanced drawing.

- New Effect template SDK. This template will help you get going writing custom WebGL shader effects for Construct 2.

As always, it is highly recommended for all plugin developers to update to the latest template. Thanks for your continued work improving Construct 2!Ashley2012-09-03 15:14:04
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Sep 03, 2012 4:17 pm

This should help greatly. Thanks. Any idea when the other webgl features will be implemented? I'm guessing quite. A while since they appear lengthy to code right. In particular the textures and drawing features. I came across a ray casting thread here yesterday and loved the 3d visual effects but the calculating and drawing slices of an image seemed CPU intensive. If we could utilize the drawing features we could draw angled boxes like in the example and paste a texture image onto it. Or am I wrong in how the drawing and textures are done with webgl?

Thanks again for posting this so quickly,

Lance
B
69
S
21
G
15
Posts: 701
Reputation: 15,629

Post » Mon Sep 03, 2012 4:44 pm

What other WebGL features do you mean specifically? Things like raycasting are academically interesting, but not yet practical due to the impractical performance requirements. Also, most other WebGL features relate to 3D games, so aren't really applicable to 2D games.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Feb 18, 2013 10:11 am

@Ashley

Currently i'm pretty much into web gl sahder writing.. at least i try. But still there are some things a bit unclear to me. For example which version of glsl es are we dealing with, my guess is 1.0 because you pointed to page 3 and 4 of the reference card.
That brings me to the question if there is any chance to raise this in the near future, because in 1.0 one has to struggle with a lot of limitations (e.g. array initializing, loops etc.).

Another suggestion would be to elaborate a bit more on the pre-defined parameters we can use in shaders. Right now the template.fx speaks of seconds, pixelWidth, pixelHeight etc.. Is that everything? In the file "glwrap.js" there is one additional parameter "LayerScale". Might this be useful to include it into the template?

How difficult would it be to implement furthers params we can use? As i already suggested it would be awesome to pass vector values (vec2, vec3, vec4) on the fly.

Thanks for your reply!
B
59
S
7
G
2
Posts: 93
Reputation: 4,228

Post » Mon Feb 18, 2013 11:37 am

@oppenheimer - it's the version of GLSL that you get with WebGL, and WebGL is based on OpenGL ES 2, so it's (I think) OpenGL ES Shading Language 1.0. It's limited, but this is by design for compatibility with mobile devices which have weaker GPUs.

I've got adding more parameters on my todo list but there are any you're after specifically?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Mon Feb 18, 2013 3:25 pm

@Ashley - So a game developer who targets desktop/browser apps has the same restrictions in shader usage as a mobile developer. Maybe a concept where the dev has the option to specify a certain glsl version would be good. The shader xml has to contain a param to define this gl version then. This would be flexible solution for multitarget exports.

I can imagine that it means a lot of work for you, but to be really future proof (regarding mobile hardware as well), it's inevitable to open up the options a bit.

Speaking of options.. The same way fragment shaders are implemented, it should be possible to include vertex shaders. Back in 2009 you stated "What can you usefully do with four vertices?" speaking about CC. There we had the opportunity to distort the vertices via events. Kinda bottlenecked, but it was possible. With a vertex shader it should be possible to adaptively add more vertices to an object. You claim that C2 is not a 3D software, but again i think, that you should open up the possibilites for the user a little bit more. Think of how much bandwidth will be saved if a user wants to add a 3d model with one texture instead of a precomputed sprite sheet.

Concerning your last question, i can't think of further params to be included. But the 3 vector types (and arrays perhaps) would be pretty useful imho.
B
59
S
7
G
2
Posts: 93
Reputation: 4,228

Post » Thu Feb 21, 2013 8:43 pm

@Ashley

I thought a bit more on what to add to the skd/shader documentation and the backend. In CC we had the option to get the boxWidth and boxHeight within a shader. That would be a really cool feature for generative shaders (like a shape-shader or simplex noise), because it's independent from the texture size. The other params like boxTop//Bottom/Left/Right and hotspot positions can be discarded i think, because we can access those directly (0,1,0,1) or by events setting regular floats.

I hope that it won't take much time to implement & you agree on usefulness.
B
59
S
7
G
2
Posts: 93
Reputation: 4,228


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests