Documentation on built-in uniforms

Share your Construct 2 effect files

Post » Thu Sep 18, 2014 10:28 pm

Hello,

I'm quite new to Construct, but I'm experienced with GLSL and have been looking into developing effects for Construct.
While I've been able to figure out how to make effects from examining .fx files and their corresponding XML files, one thing has been bugging me: From what I've figured out, Construct sends many uniforms to the shader, such as samplerFront, samplerBack and others.

I've been able to figure out what many of these are from just trial and error, but it would be really helpful to have a reference for these. Unfortunately, I haven't veen able to find anything like that anywhere.

Does anyone know if there is some kind of documentation on developing shaders for Construct?
B
4
S
1
Posts: 3
Reputation: 356

Post » Fri Mar 27, 2015 3:21 am

Bump! I would really like this. I too am trying to learn C2 shader dev but trying to do everything with reverse engineering is rough.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Fri Mar 27, 2015 7:17 pm

@sqiddster @glitchg

Here's an overview of all the variables the C2 provides for effects.
All vertex positions, unless stated otherwise are in relation to the screen where (0,0) is the top-left and (1,1) is the bottom-right.

varying vec2 vTex
This is the vertex co-ordinate of the current pixel

uniform sampler2D samplerFront
this is the source pixels. AKA the object's texture or the result of the previous shader.
uniform sampler2D samplerBack
this is where stuff is being drawn to

uniform float pixelWidth
1.0/width or in other words a pixel width in vertex co-ordinates
uniform float pixelHeight
1.0/height or in other words a pixel height in vertex co-ordinates

uniform vec2 destStart
The top-left vertex co-ordinate of the rectange being drawn to.
uniform vec2 destEnd
The bottom-right vertex co-ordinate of the rectange being drawn to.
For example a rectangle that covers the entire screen would have a destStart of (0,0) and a destEnd of (1,1)
Usually they define a rectangle that covers just the object, but depending on the xml settings it can be larger.

uniform float layerScale
uniform float layerAngle
^ In radians I think.
Both these are basically the same as their counterparts in C2


Now the folling two aren't used in any bundled effects but they'd have the same values as ViewportLeft(0), ViewportTop(0) and scrollx and scroly respectively.
uniform vec2 viewOrigin
Top-left of screen in layout pixels
uniform vec2 scrollPos
Center of screen in layout pixels.

uniform float seconds
Time.

uniform float opacity
Current object/layer opacity in the range of 0.0 to 1.0

In glwrap.js there are these others: aPos, aTex, matP, and matMV but they are only used in the vertex shader and I'm not even sure you can access them from a pixel shader.
B
92
S
32
G
107
Posts: 5,273
Reputation: 69,957

Post » Sat Mar 28, 2015 7:14 am

@R0j0 Thanks! I'm worried though for the sake of others that this post will be lost in the aether. Maybe you could put it in a tutorial or something?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Mar 28, 2015 7:30 am

I should. I'll work on getting it put in a tutorial.
B
92
S
32
G
107
Posts: 5,273
Reputation: 69,957

Post » Sat Mar 28, 2015 8:21 am

Surely, this would also be better off in the SDK section of the manual ? (@Ashley).

Fantastic info as usual, R0J0. Much appreciated.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,379
Reputation: 58,440

Post » Sat Mar 28, 2015 9:58 am

Yeah, it's really weird that Scirra has written literally 0 documentation on effects. I guess it's not really high on the priority list.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Mar 28, 2015 10:04 am

sqiddster wrote:Yeah, it's really weird that Scirra has written literally 0 documentation on effects. I guess it's not really high on the priority list.



It is a little bizzare, considering the number of (unfulfilled) requests for effects in the "What shader effects do you want? " thread.

If the documentation was better, many more would at least make the attempt at creating effects, to the benefit of everyone.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,379
Reputation: 58,440

Post » Thu Apr 16, 2015 8:46 pm

Sticky this!
Luca ConTato [RisingPixel]
Image
B
22
S
8
G
2
Posts: 112
Reputation: 2,899

Post » Sat Dec 19, 2015 1:47 am

Bump - for the greater good. Took me a year to stumble across this... I've written a few but without documentations of any kind this is a royal pain in the but. Possibilities are limitless but this is a big stumbling block for anyone (like me) who didn't already know how to write shaders. You can find tutorials, but they don't cover what construct 2 is doing...
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Next

Return to Effects

Who is online

Users browsing this forum: totoe and 0 guests