Documentation on built-in uniforms

0 favourites
From the Asset Store
Isometric Stategy Roleplay Game Building and Streets Pack.
  • 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?

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • I should. I'll work on getting it put in a tutorial.

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

    Fantastic info as usual, R0J0. Much appreciated.

  • 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.

  • 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.

  • Sticky this!

  • 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...

  • I should. I'll work on getting it put in a tutorial.

    Did this ever happen? I couldn't find anything on the matter. I would be happy to write a serries that would help people get a go on effects but I find myself often struggling as well. There doesn't seem to be a good tutorial on simply writing different types of frag shaders.

  • Ruskul

    Nope, I never got around to it. What it would consist of is just what I posted here.

  • Ruskul

    Do a Search for 'Toby Schachman GLSL pixel shaders'

    His Github page has an interactive book/ shader editor you can download and run offline.

  • Ruskul

    Do a Search for 'Toby Schachman GLSL pixel shaders'

    His Github page has an interactive book/ shader editor you can download and run offline.

    This is pure gold, but it is so short and basic. I seem to be only finding a prototype of the idea and not an actual complete book. (all thats in there is gl_fragcolor stuff... I remember know I think I ran through this when I was first getting started with shaders a couple years ago.

  • Ruskul

    'This is pure gold, but it is so short and basic.' ? ?

    -----------------------------------------------------------------------------------

    Here is an in-progress table of contents for the book:

    1. Introduction

    * What are pixel shaders?

    * What can you do with pixel shaders?

    2. Colors

    * Gradients

    * Vector Math

    * Color Spaces, Rainbows

    3. Working with Textures

    * Image Filters

    * Compositing

    4. Transformations

    *Patterns

    * Coordinate Spaces

    * Polar Coordinates

    * Distortion

    * Displacement Maps

    5. Multiple Point Sampling

    * Edge Detection

    * Blur

    6. Generative Textures

    * Noise

    * Quasicrystals

    * Fractals

    7. Raytracing

    * Case Study: Mirrors and Kaleidoscopes

    * 3D

    8. Integrating Shaders With Other Frameworks

    * WebGL

    * Processing, openFrameworks, Jitter, Quartz Composer.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)