Shaders Functions
Functions to add Shaders to sprites and change their properties.
initLuaShader
initLuaShader(name:String):Bool
Preloads a Shader .vert/.frag inside "shaders/" folder, might be good for intensive shaders but it's generally not needed.
Returns "true" if the operation was successful.
- name - Shader .vert/.frag name, don't include the extension!
Examples:
- initLuaShader('pixelate') - Preloads "mods/My-Mod/shaders/pixelate.frag".
setSpriteShader
setSpriteShader(tag:String, shaderName:String):Bool
Sets a Sprite's Shader to a .frag/.vert file inside "shaders/" folder.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- shaderName - Shader .vert/.frag name, don't include the extension!
Examples:
- setSpriteShader('mySprite', 'pixelate') - Sets Lua Sprite with tag "mySprite" to use "mods/My-Mod/shaders/pixelate.frag" shader.
removeSpriteShader
removeSpriteShader(tag:String):Bool
Sets a Sprite's Shader to a .frag/.vert file inside "shaders/" folder.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
Examples:
- removeSpriteShader('mySprite') - Removes Shader from the Lua Sprite with tag "mySprite".
getShaderBool
getShaderBool(tag:String, prop:String):Bool
Returns an "uniform bool" shader variable's value.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
Examples:
- getShaderBool('mySprite', 'iVar') - Returns the value of an uniform variable named "iVar" from a Lua Sprite named "mySprite".
getShaderBoolArray
getShaderBoolArray(tag:String, prop:String):Array<Bool>
Returns an "uniform bool" shader variable's array values.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
getShaderInt
getShaderInt(tag:String, prop:String):Int
Returns an "uniform int" shader variable's value.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
getShaderIntArray
getShaderIntArray(tag:String, prop:String):Array<Int>
Returns an "uniform int" shader variable's array values.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
getShaderFloat
getShaderFloat(tag:String, prop:String):Float
Returns an "uniform float" shader variable's value.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
getShaderFloatArray
getShaderFloatArray(tag:String, prop:String):Array<Float>
Returns an "uniform float", "uniform vec2", "uniform vec3" or "uniform vec4" shader variable's array values.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
setShaderBool
setShaderBool(tag:String, prop:String, value:Bool):Bool
Sets an "uniform bool" shader variable's value.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
Examples:
- setShaderBool('mySprite', 'iVar', true) - Sets the value of an uniform variable named "iVar" from a Lua Sprite named "mySprite" to "true".
setShaderBoolArray
setShaderBoolArray(tag:String, prop:String, value:Array<Bool>):Bool
Sets an "uniform bool" shader variable's array values.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
Examples:
- setShaderBoolArray('mySprite', 'iVar', {true, false, true}) - Sets the value of an uniform variable named "iVar" from a Lua Sprite named "mySprite" to an Array of "[true, false, true]".
setShaderInt
setShaderInt(tag:String, prop:String, value:Int):Bool
Sets an "uniform int" shader variable's value.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
setShaderIntArray
setShaderIntArray(tag:String, prop:String, value:Array<Int>):Bool
Sets an "uniform int" shader variable's array values.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
setShaderFloat
setShaderFloat(tag:String, prop:String, value:Float):Bool
Sets an "uniform float" shader variable's value.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
setShaderFloatArray
setShaderFloatArray(tag:String, prop:String, value:Array<Float>):Bool
Sets an "uniform float", "uniform vec2", "uniform vec3" or "uniform vec4" shader variable's array values.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- value - Value to set.
setShaderSampler2D
setShaderSampler2D(tag:String, prop:String, bitmapPath:Float):Bool
Imports a Bitmap to an "uniform sampler2D" shader variable.
Returns "true" if the operation was successful.
- tag - Sprite variable name or Lua Sprite nametag.
- prop - Uniform variable name.
- bitmapPath - Image path, don't include the extension!
Examples:
- setShaderBool('mySprite', 'iVar', 'myImage') - Imports "mods/My-Mod/images/myImage.png" to the Sampler2D variable.