This is an old revision of the document!
[ShaderTemplate] Code = "// Shader code void main() { // Do stuff }" KeepInCache = <bool> ParamList = ParamFloat # ParamTexture # ParamVector ParamFloat = <float> ParamVector = <vector> ParamTexture = path/to/TextureFile|screen UseCustomParam = <bool>
Here's a list of the available properties for an orxSHADER
structure:
KeepInCache
: Defines if the shader code should be kept in memory even if no shader of this type is currently in use. This saves time (reading from disk + compiling) but costs memory. Its default value is false
.screen
is provided). If an invalid path is provided for a parameter, or the parameter isn't defined at all, the owner's texture will be used 2).UseCustomParam
: Defines if parameters can have their value overridden at runtime (ie. interactive). Its default value is false
which means only the default values will be used.Here's a simple example of a non-interactive shader as seen in the spawner/shader tutorial.
[Decompose] Code = "void main() { float fRed, fGreen, fBlue; // Computes positions with offsets vec2 vRedPos = vec2(gl_TexCoord[0].x + offset.x, gl_TexCoord[0].y + offset.y); vec2 vGreenPos = vec2(gl_TexCoord[0].x, gl_TexCoord[0].y); vec2 vBluePos = vec2(gl_TexCoord[0].x - offset.x, gl_TexCoord[0].y - offset.y); // Red pixel inside texture? if((vRedPos.x >= 0.0) && (vRedPos.x <= 1.0) && (vRedPos.y >= 0.0) && (vRedPos.y <= 1.0)) { // Gets its value fRed = texture2D(texture, vRedPos).r; } // Green pixel inside texture? if((vGreenPos.x >= 0.0) && (vGreenPos.x <= 1.0) && (vGreenPos.y >= 0.0) && (vGreenPos.y <= 1.0)) { // Gets its value fGreen = texture2D(texture, vGreenPos).g; } // Blue pixel inside texture? if((vBluePos.x >= 0.0) && (vBluePos.x <= 1.0) && (vBluePos.y >= 0.0) && (vBluePos.y <= 1.0)) { // Gets its value fBlue = texture2D(texture, vBluePos).b; } // Outputs the final decomposed pixel gl_FragColor = vec4(fRed, fGreen, fBlue, 1.0); }" ParamList = texture#offset offset = (-0.05, -0.05, 0.0) ~ (0.05, 0.05, 0.0); <= Let's take some random offset
Please see the spawner/shader tutorial for more information.