You can create your own custom filters by using shader programs, such as those used in 3D rendering software.
Using Shaders with Sclender
To use a shader with Sclender, that shader must be configured to accept information from Sclender. Additionally, it is necessary to describe some aspects of its behavior (such as how much it scales the capture) for Sclender to understand what to do with it afterward. Both of these requirements can be satisfied by writing up a uniform key file ("UKF").
If you just want to use shaders already purposed for Sclender, you just need to understand that Sclender supports GLSL shaders (for OpenGL) with the ".glsl" extension and each of these requires an accompanying UKF file. To use a shader, drag it (meaning the GLSL file) to the filters list and Sclender will enter it and its UKF file, which should be in the same folder, into its database. This database, should you want to remove files from it, is located in your Users folder under the subfolder "sclender\shaders". You can update a shader to a new version of itself by dragging it back over the filters list. UKF files may be updated in the same manner, without updating the shader itself.
If you want to understand how to make your own shader for Sclender, or use a shader not-purposed for Sclender with Sclender (assuming it's feasible), then read on.
Understanding Uniform Keys
Every custom filter must have an accompanying UKF. This file must always be named after the shader it accompanies, with the extension ".ukf".
For example, if we use a shader named "test.glsl", that shader's key file must be named "test.ukf".
Uniform keys have two purposes: to explain to Sclender how the shader changes its output, and to correspond uniforms used in the shader to Sclender's own internal uniforms.
Uniform Key Syntax
Uniform key files consist of key/value pairs, such as "SCALING = 2". The first word is the key, then the value follows after the colon. There may be one key/value pair per line.
In the case of "SCALING = 2", the key file is telling Sclender that its shader will scale the capture 2x (resulting in an image 4x as large). If the key/value was "SCALING = 3", Sclender would expect the capture to be scaled 3x, and so forth. Another commonly used key is "VSHADER", whose value specifies either the filename of any vertex shaders to be processed, or "SAME" if the vertex and pixel shaders are in the same file.
The "VSHADER" key is optional. Each UKF must include the "SCALING" key.
Sclender Internal Uniforms
The follow is a list of Sclender's uniform variables and what information they can contribute to shaders:
- INTEX: this is the uniform containing the input image sent to the shader by Sclender.
- INWIDTH: specifies the input image's width in pixels.
- INHEIGHT: specifies the input image's height in pixels.
- INSIZE: species the dimensions of the shader's input in pixels as a vec2.
- OUTWIDTH: specifies the width of the shader's output in pixels. Assumed to be the in-width times the value of "SCALING".
- OUTHEIGHT: specifies the height of the shader's output in pixels. Assumed to be the in-height times the value of "SCALING".
- OUTSIZE: specifies the dimensions of the shader's output in pixels as a vec2.
- PROJECTION: specifies the worldview projection used by the shader. (set to the value of "SCALING")
- PARAM: overrides the Filter Param setting of the shader as defined for the filter profile.
Equating Uniforms Identifiers
To use shaders not originally purposed for Sclender with Sclender, it is necessary to equate Sclender's uniforms with those of the shader. This is done by writing the internal uniform as a key followed by the shader uniform as its value.
For example, if the shader's uniform for its input texture is "TEXTURE_IN", you'd write:
INTEX = TEXTURE_IN