Build-in uniforms



There are few build-in uniform variables available in Synthclipse shaders. "Build-in" in a sense that their values are provided automatically without the need of Uniform Controls. However, it does not mean that you can use them without declaring them in your code.

Mouse state uniforms

A family of uniforms related to mouse state. They are analogous to Shadertoy's uniform iMouse.

// Mouse pixel coordinates: 
// xy: current (if mouse button is down)
// zw: click point

uniform vec4 synth_Mouse;  // Left mouse button

uniform vec4 synth_LMouse; // Left mouse button (same as "synth_Mouse")
 
uniform vec4 synth_RMouse; // Right mouse button

uniform vec4 synth_MMouse; // Middle mouse button

Camera uniforms

Camera uniforms are generated by Synthclipse's camera - the one which is set in the Camera View and which can be controlled by mouse and keyboard.

// Projection Matrix. Valid only for 3D cameras.
uniform mat4 synth_ProjectionMatrix;

// Camera's View Matrix. Valid only for 3D cameras.
uniform mat4 synth_ViewMatrix;

// Camera's Normal Matrix. Valid only for 3D cameras.
uniform mat3 synth_NormalMatrix;

// Camera's center position. Valid only for 2D camera.
uniform vec2 synth_Center;

// Camera's zoom factor. Valid for 2D and 3D cameras.
uniform float synth_Zoom;

// Viewport resolution. (Analogous to Shadertoy's "iResolution")
uniform vec2 synth_Resolution;

time / iGlobalTime / synth_Time

Time uniform variable is probably the most important build-in variable. It is used for animating shaders. Its value is a current animation time, in seconds.

// Declaration of time uniform variable.
uniform float time;

// alternatively you could use Shadertoy's equivalent:
uniform float iGlobalTime;

// or Synthclipse's equivalent:
uniform float synth_Time;

pixelSize

PixelSize is vec2 uniform variable whose components are given by:

pixelSize.x = 1.0 / width;
pixelSize.y = 1.0 / height;

where width and height are Viewport's width and height, respectively. This variable is supported only for compatibility with the Fragmentarium.

// Declaration of pixelSize uniform variable.
uniform vec2 pixelSize;

subframe

Subframe uniform indicates which "sub frame" is currently rendered. Sub frames are generated when Progressive Mode is enabled (which you can set in the Rendering View). If it is disabled, the uniform will always be set to 1.

// Declaration of subframe uniform variable.
uniform int subframe;

subframeCount

SubframeCount uniform variable tells the total number of "sub frames". This is the same value as the "Subframes" parameter from the Rendering View.

// Declaration of subframeCount uniform variable.
uniform int subframeCount;

backbuffer

Backbuffer uniform is an image generated in a previous "sub frame". Sub frames are generated when Progressive Mode is enabled (which you can set in the Rendering View). If it is disabled or when rendering the first sub frame, back buffer image is cleared with (0.0, 0.0, 0.0, 0.0) color value.

// Declaration of backbuffer uniform variable.
uniform sampler2D backbuffer;

frontbuffer

Frontbuffer uniform variable is available only in the post processing shaders. It is the result image generated during first pass of the rendering. (The second and final pass is the post processing).

// Declaration of frontbuffer uniform variable.
uniform sampler2D frontbuffer;

Shadertoy uniforms

Synthclipse supports every uniform known from Shadertoy except of iChannelResolution which I think it's not very useful. iChannelTime is treated a little bit different than in Shadertoy: its components are always equal to the iGlobalTime.

These uniforms are available not only in ".stoy" files but also in any other shader file type.

// Shadertoy uniforms

uniform vec3      iResolution;           // viewport resolution (in pixels)
uniform float     iGlobalTime;           // shader playback time (in seconds)
uniform float     iTimeDelta;            // render time (in seconds)
uniform int       iFrame;                // shader playback frame
uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
uniform vec4      iDate;                 // (year, month, day, time in seconds)
uniform float     iSampleRate;           // sound sample rate (i.e., 44100)\n"
uniform float     iFrameRate;            // frames per second (effectively "1.0 / iTimeDelta")

// iChannelTime components are always equal to iGlobalTime.
uniform float     iChannelTime[4];       // channel playback time (in seconds)

GLSL Sandbox uniforms

Synthclipse also supports GLSL Sandbox uniforms needed for GLSL Sandbox Importer.

// GLSL Sandbox uniforms

// Normalized mouse position. Components of this vector are always between 0.0 and 1.0.
uniform vec2 mouse;

// Screen (Viewport) resolution.
uniform vec2 resolution;

// surfaceSize is equal to: vec2(resolution.x / resolution.y, 1.0)
uniform vec2 surfaceSize;