Commands



Commands are special type of comments in ths GLSL, starting from "//!" or from "/*!". They are metadata describing internal (e.g. post processing program, used Vertex Shader) or external (e.g. Uniform Controls, uniform groups, info, presets) aspects of shaders.

Commands have syntax derived from XML, apart from Uniform Controls - which have syntax compatible with the Fragmentarium. Most of the XML-based commands do not have closing tag (although you can put "/" before ">" if you want). Only exceptions are "<info></info>" and "<preset></preset>" Commands.

This document describes available commands, their syntax and application.

Uniform Control commands

Uniform Controls (UC) are used only at the end of uniform variable declarations. Their purpose is to make possible to change uniform values during shader execution by user controlled widgets/controls/components. Each UC has corresponding widget (or set of widgets) in the Uniform Controls View. There are few types of UCs with different names and parameters. They are described in depth in separate document.

examples:

uniform bool WithGamma; //! checkbox[true]
uniform float Gamma; //! slider[0.1, 2.2, 10]
uniform float Frequency; //! slider[-10, 2, 100]


Group command

Group commands are used to group UCs on separated tabs on the Uniform Controls View. Every uniform variable, declared after group command, belongs to that group.

syntax:

//! <group name="GROUP_NAME">

// or with optional slash:
//! <group name="GROUP_NAME"/>

// IMPORTANT: never use closing tag: </group>

examples:

//! <group name="Group #1"/>

uniform bool WithGamma; //! checkbox[true]
uniform float Gamma; //! slider[0.1, 2.2, 10]

//! <group name="Group #2"/>

uniform float Frequency; //! slider[-10, 2, 100]


Post processing command

Post processing command is used for making two-pass renderings. It tells Synthclipse that you want to use two shaders. One that renders output image to a texture (first pass) and the second that uses the texture as an input (second pass).

Post processing command has one parameter: "shader" - it is a path to a Fragment Shader file (with .fragx or .frag extension) that will be used in the second pass. This FS should contain declaration of backbuffer uniform variable:

// sampler for the image texture generated in the first pass:
uniform sampler2D backbuffer;

It can also, optionally, contain subframe uniform variable:

// Variable indicating which subframe is actually rendered in "Progressive Rendering Mode".
uniform int subframe;

syntax:

//! <post-processing shader="POST_PROCESS_SHADER">

// or with optional slash:
//! <post-processing shader="POST_PROCESS_SHADER"/>

// IMPORTANT: never use closing tag: </post-process>

examples:

//! <post-processing shader="Fragmentarium/BufferShader.frag"/>
//! <post-processing shader="PostprocessingShader.fragx"/>

Camera command

Camera command tells Synthclipse what type of camera should be used with mouse navigation. There are two possible variants: 2D or 3D. With each type of camera there is related set of uniform variables.
For 2D case these variables are:

// Central coordinates of the Viewport:
uniform vec2 Center;

// Magnification factor:
uniform float Zoom;

For 3D case these variables are:

// Position of the camera:
uniform vec3 Eye;

// Forward/direction vector of the camera:
uniform vec3 Direction;

// Up vector of the camera:
uniform vec3 Up;

If you declare them in your shader, they will by automatically updated after scrolling mouse wheel or dragging mouse pointer over the Viewport. You can declare them in Fragment Shader (*.fragx, *.stoy, *.frag) or in Vertex Shader (*.vert) - depending on your needs. They have default Uniform Controls but you can declare your own UCs if you want.

Camera command is optional.

syntax:

//! <camera type="CAMERA_TYPE">

// or with optional slash:
//! <camera type="CAMERA_TYPE"/>

// IMPORTANT: never use closing tag: </camera>

examples:

//! <camera type="2D"/>

//! <camera type="3D"/>

Vertex Shader command

VS command tells Synthclipse what Vertex Shader should be used for rendering. If no VS command is specified, simple default Vertex Shader will be used.

// Default Vertex Shader

layout(location = 0) in vec3 VertexPosition;

void main() {
        gl_Position = vec4(VertexPosition, 1.0);
}

syntax:

//! <vs file="VERTEX_SHADER_FILE">

// or with optional slash:
//! <vs file="VERTEX_SHADER_FILE"/>

// IMPORTANT: never use closing tag: </vs>

examples:

//! <vs file="Fragmentarium/3D.vert"/>

//! <vs file="MyVertexShader.vert"/>

Audio shader command

Audio shader command is used for attaching a shader that generates music instead of rendering graphics. Audio shaders ware invented by the Shadertoy team. Good example of such shader is: the Music toolbox by nimitz. (You can import it to Synthclipse).

syntax:

//! <audio shader="AUDIO_SHADER_FILE">

// or with optional slash:
//! <audio shader="AUDIO_SHADER_FILE"/>

// IMPORTANT: never use closing tag: </vs>

examples:

//! <audio shader="Melody.sau"/>

Info command

Info command is intended for shader description, license and author's name.

syntax:

/*!
 * <info>
 *   some text.
 * </info>
 */

examples:

/*!
 * <info>
 *   Author: Kamil Kolaczynski
 *   Title: Mandelbrot Set
 *   Description: This is classical Mandelbrot Set with Orbit trap coloring.
 *   License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
 * </info>
 */

Preset command

Preset commands are automatically generated by Synthclipse whenever you save some presets using the Save button in the Uniform Controls View:


A preset with name "Default" or "default" gets special treatment. It is, by default, automatically loaded after shader build. You can change this by manually loading other preset (using Load button on the Uniform Controls View). Next time you build the shader, preset you have loaded last will be used.

syntax:

/*!
 * <preset name="PRESET_NAME">
 *    UNIFORM_NAME_1 = VALUE_1
 *    UNIFORM_NAME_2 = VALUE_2
 *    UNIFORM_NAME_3 = VALUE_3
 *    ...
 * </preset>
 */

// if preset is related to some post processing shader, it has "program" parameter with its name:
/*!
 * <preset name="PRESET_NAME" program="POST_PROCESSING_SHADER_PATH">
 *    UNIFORM_NAME_1 = VALUE_1
 *    UNIFORM_NAME_2 = VALUE_2
 *    UNIFORM_NAME_3 = VALUE_3
 *    ...
 * </preset>
 */
 
 // or if preset is saved in a separate file:
 
 //! <preset file="/path/to/some.preset" />

examples:

/*!
 * <preset name="Default">
 *  Frequency = 2.0
 *  Gamma = 2.2
 *  WithGamma = true
 * </preset>
 */

/*!
 * <preset name="Octobulb" program="Fragmentarium/BufferShader.frag">
 *  Brightness = 1.0
 *  Contrast = 1.0
 *  Exposure = 0.78
 */
 
 //! <preset file="D:/Revers/Synth/my_shader.preset" />

Messages commands

Messages commands are used to highlight some fragments in a code. Their role is only informative. They are mostly autogenerated by Synthclipse importers.

syntax:

//! INFO: message
//! WARNING: message
//! ERROR: message

examples:

//! INFO: text of an info message

//! WARNING: text of a warning message

//! ERROR: text of an error message

synthclipse_skip command

synthclipse_skip command tells Synthclipse to not modify given line. For now it is only applicable to lines with "gl_FragCoord" variable.

If one uses default Vertex Shader ("Basic2D.vert" for Shadertoy and "GLSLSandbox.vert" for GLSL Sandbox), or any other Vertex Shader that contains declaration ""out vec4 glFragCoord;", then Synthclipse replaces all occurrences of "gl_FragCoord" variable in Fragment Shader with its own version - "glFragCoord" - that is suitable for tiled rendering.

To prevent this replacement one needs to mark any line containing phrase "gl_FragCoord" with synthclipse_skip command. (Alternatively one can use his own Vertex Shader)

syntax:

//! synthclipse_skip

examples:

vec2 uv = gl_FragCoord.xy / iResolution.xy; //! synthclipse_skip