There are 5 shader file types used in Synthclipse:
You can create them using New Synthclipse File Wizard.
Fragx file is the main file type used in Synthclipse. It is executable Fragment Shader file. There are two default templates for fragx files:
// Default template for 2D .fragx file. #include <Fragmentarium/2D.frag> vec3 color(vec2 p) { return vec3(fract(p), 0.0); }
// Default template for 3D .fragx file. #include <Fragmentarium/3D.frag> vec3 color(vec3 ro, vec3 rd) { return abs(rd); }
These templates are based on code written by Mikael Hvidtfeldt Christensen in his Fragmentarium. In the included files ("Fragmentarium/2D.frag", "Fragmentarium/3D.frag") there are declared some standard uniforms for camera and antialiasing.
In case of 3D template, there is also declaration of post processing shader. It enables Progressive Rendering Mode. If you would like to take advantages of this mode also in 2D case, you would have to include "Fragmentarium/Progressive2D.frag" instead of "Fragmentarium/2D.frag".
Stoy is another executable Fragment Shader file type. It is dedicated for Shadertoy development. Default template has declarations of all standard Shadertoy uniforms.
// Default template for .stoy file. uniform vec3 iResolution; // viewport resolution (in pixels) uniform float iGlobalTime; // shader playback time (in seconds) uniform float iChannelTime[4]; // channel playback time (in seconds) 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) void mainImage(out vec4 fragColor, in vec2 fragCoord) { // TODO: Add your code here. vec2 uv = fragCoord.xy / iResolution.xy; fragColor = vec4(uv, 0.5 + 0.5 * sin(iGlobalTime), 1.0); } void main() { vec4 color; mainImage(color, gl_FragCoord.xy); color.w = 1.0; gl_FragColor = color; }
Sau files are used for Audio Shaders which generate 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).
// Default template for .sau file. uniform float iBlockOffset; uniform float iChannelTime[4]; // channel playback time (in seconds) uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) uniform vec4 iDate; // (year, month, day, time in seconds) uniform float iSampleRate; // sound sample rate (i.e., 44100) vec2 mainSound(float time) { // TODO: Add your code here. return vec2(sin(6.2831 * 440.0 * time) * exp(-3.0 * time)); } void main() { float t = iBlockOffset + (gl_FragCoord.x + gl_FragCoord.y * 512.0) / 44100.0; vec2 y = mainSound(t); vec2 v = floor((0.5 + 0.5 * y) * 65536.0); vec2 vl = mod(v, 256.0) / 255.0; vec2 vh = floor(v / 256.0) / 255.0; gl_FragColor = vec4(vl.x, vh.x, vl.y, vh.y); }
Vert type is used for Vertex Shader files. It is the only file type accepted by vs command. Default template has declaration for input vertex attribute: VertexPosition.
// Default template for .vert file. layout(location = 0) in vec3 VertexPosition; void main() { gl_Position = vec4(VertexPosition, 1.0); }
Frag file type means: non-executable Fragment Shader file. It is intended for files that can be included to executable Fragment Shader files (*.fragx, *.stoy) or to other frag files. Default template is an empty file.
Glsl file type is also dedicated for non-executable shader code, but is more general than frag file type. It is intended for inclusion not only to Fragment Shader files but to all types of shaders. (Currently only Vertex Shaders, but in future versions of Synthclipse there is planned support for other types). Default template is an empty file.