OpenGL shader player,compatible with single pass interactive shader format, shadertoy, glsl sandbox shaders with generally few adaptations.

In Usine, the openGL shader is made of a vertex, a fragment containing eventually interactive shader format definitions, and a header containing various definitions and compatibility settings.

It's outside the purpose of the manual to teach you how to create a shader but you can start with examples of the library. There are 3 kind of examples:
draw: simples shaders which are drawing images with optional mouse interaction.
isf: Interactive Shader Format shaders with extra inputs on the modules according to the ISF definitions.

fx: shaders which are transforming an input image and contain a video input inlet.

The header contains the following compatibility definitions. It can be changed by editing the file /Resources/Templates/Shaders inside the application folder.
/////////////////////////////////////////////////////////////////////////////////
// compatibility with Sandbox
uniform float time; // shader playback time (in seconds)
uniform vec4 date; // current date vec4(Y,M,D,S)
uniform vec2 resolution; // viewport resolution (in pixels)
uniform vec2 mouse; // mouse pixel coords. xy: current
uniform float mousedown; // is 1.0 if mouse is down 0.0 otherwize
uniform int frame; // shader playback frame
uniform float timedelta; // render time (in seconds)
//////////////////////////////////////////////////////////////////////////////////
// compatibility with shadertoy
#define iMouse vec4(mouse.x*resolution.x,mouse.y*resolution.y,mousedown,mousedown)
#define iTime time
#define iTimeDelta timedelta
#define iResolution vec3(resolution.x,resolution.y,0.0)
#define iChannel0 backbuffer
#define iFrame frame
#define iDate date
//////////////////////////////////////////////////////////////////////////////////
// compatibility with ISF
#define RENDERSIZE resolution
#define FRAMEINDEX frame
#define TIME time
#define TIMEDELTA timedelta
#define isf_FragNormCoord (gl_FragCoord.xy/resolution.xy)
//////////////////////////////////////////////////////////////////////////////////
// Usine inputs
uniform sampler2D backbuffer; // background texture
uniform vec2 surfaceSize; // surface resolution (in pixels) = resolution
Activates or deactivates the module.
Total time used for the calculation of the module.
Video output flow(s).
Overall speed of the shader.
Restarts the shader (sets the time uniform to 0).
Width in pixels of the shader video output, from 40 to 4096 (default 1280).
Height in pixels of the shader video output, from 40 to 2160 (default 720).
Opens the shader editor window.
File name of the shader fragment to open.
When ON, in unlock mode, the position and the size of the child controls are snapped to a grid of grid size pixels when they are moved or resized with the mouse. Floating controls dragged inside the panel are snapped too.
Step of the grid in pixels, in the range [1..40], used when snap to grid is ON. Default 2.
When the fragment contains an ISF JSON definition, each entry of its INPUTS list adds an inlet to the module, below the ISF parameters separator, named after the NAME of the entry. Usine adds the matching uniform declaration to the header, so the fragment uses the name directly. The DEFAULT, MIN, MAX, VALUES and LABELS fields are used when present. The supported types are float, bool, event, color, long, image, audio, audioFFT and point2D; any other type is reported as an error in the trace.
The default fragment of a new module (/Resources/Templates/Shaders/Default Fragment.fs) declares one input of each kind, which gives the following inlets.
Input of type image: video inlet. The received frame is uploaded as a texture declared as uniform sampler2D, read with IMG_THIS_PIXEL(input_image) or IMG_NORM_PIXEL(input_image, coord).
Input of type float: float fader declared as uniform float, with the DEFAULT, MIN and MAX of the definition (default 0.5 in [0..1] in the default fragment).
Input of type audio or audioFFT: array inlet. The values of the array are uploaded as a texture one pixel high and as wide as the array, declared as uniform sampler2D; the shader reads them in the alpha component, for example IMG_THIS_PIXEL(input_audio).a.
Input of type color: color inlet declared as uniform vec4 (red, green, blue and alpha in [0..1]). DEFAULT gives the initial color as [r, g, b, a].
Input of type long: combobox inlet declared as uniform int. Its items are the LABELS of the definition, the uniform receives the entry of VALUES of the selected item, and DEFAULT gives the item selected at creation.
Input of type bool: switch inlet declared as uniform bool. DEFAULT accepts true, false, 1 or 0.
Input of type event: button inlet declared as uniform bool. The uniform is true during the single frame that follows a click on the button, false otherwise.
Input of type point2D, first coordinate: a point2D input gives two float inlets, named after the input with -X and -Y appended, and a single uniform vec2 with the name of the input (input_point in the default fragment). DEFAULT, MIN and MAX are read as [x, y] pairs.
Input of type point2D, second coordinate: the y component of the uniform vec2 of the input (see input_point-X).
Button. Opens the manual page of the selected object (or of its parent module for a control) in the web browser. If no page exists for this object, an error is traced in the trace panel.
For more details about information/help creation, see create-help-file.
Free multi-line text attached to the module, saved with the patch. When it is not empty, it is shown as the hint of the module (mouse over the module header in the patch) in place of the default module hint, even when the module hints are disabled.
visible only in god mode, see setup-panel-tab-expert.
Read-only, not saved. Current private numeric ID of the object, used internally to identify it (for example as the target of a bind ID).
Read-only, not saved. Private ID used to store and recall the values of this control in presets.
Button. Generates a new unique ID, original ID and preset ID for the object. Use it if you experience difficulties in Polyphonic mode or if two objects share the same ID. Preset values and binds referring to the old IDs are lost.
Read-only, not saved. Absolute address of the object in the Usine objects tree, built from the workspace root. This is the address to use to reach the object from scripts, the objects panel or remote messages. Only shown for objects that are registered in the objects list. See objects-address.
Read-only, not saved. Address of the object relative to the current patch, valid inside that patch only. See objects-address.
Free user-defined address for the object (empty by default). When set, the object is also registered in the objects tree under this name, so it can be reached independently of its position in the workspace (the value is also reported in the mouse-over and mouse-down chunks). Changing it rebuilds the objects list. Only available on objects that support a user address. See objects-address.
version 7.0.250921
Edit All Pages