Shader - AlsoGhostglowDev/Ghost-s-Utilities GitHub Wiki
a Utility that specializes in handling shader-related functionalities.
local shader = require 'ghostutil.shader'filters: dictionary<string, string> = { }fixShaderCoord(?forceFix: boolean): voidFixes the shader's coordinates being incorrect or causing visual glitches that may occur when the game window is resized. This function only really needs to be ran once.
Parameters:
-
forceFix(optional): Forces the fix to be applied again, defaults tofalse.
─────────────────────────
addCameraFilter(camera: string, filter: string, ?floats: dictionary<string, number>, ?tag: string): voidPushes a new filter to the specified camera.
Parameters:
-
camera: The camera to apply the filter to. -
filter: The filter to apply to the camera. -
floats(optional): Dictionary containing float values mapped to their corresponding uniform identifier. -
tag: (optional): The shader's sprite tracker's tag. If not specified, it will use the name of the filter instead. This can be used to change the uniform values manually withsetShaderFloat, etc.
View Example
-- assuming you had a fragment shader file named "chrom.frag" in your "shaders" folder.
--[[
the "chrom" shader has 2 float uniform values of which are:
- intensity
- distFactor
you can set these float uniform values in the 3rd optional argument.
]]
shader.addCameraFilter('game', 'chrom', {
intensity = 0.04,
distFactor = 0.2
})─────────────────────────
removeCameraFilter(camera: string, tag: string, ?destroy: boolean): voidRemoves the specified filter from the given camera.
Parameters:
-
camera: The camera to remove the filter from. -
tag: The filter's sprite tracker tag. If you didn't set the tag inaddCameraFilter, you'll just need to put in the filter name instead. -
destroy(optional): If the filter's sprite tracker object should be destroyed, else it'll stay in memory. Defaults totrue.
View Example
-- assuming you added a shader tagged "chrom" with addCameraFilter on the game camera.
-- to remove it, simply:
shader.removeCameraFilter('game', 'chrom')─────────────────────────
clearCameraFilters(camera: string): voidClears all the filters from the given camera.
Parameters:
-
camera: The camera to clear the filters from.
─────────────────────────
tweenShaderFloat(tweenTag: string, tag: string, float: string, to: number, ?duration: number, ?options: TweenOptions): voidTweens a shader's float uniform value. This also works with normal sprites with a shader applied from setSpriteShader.
Parameters:
-
tweenTag: The tween's tag. -
tag: The filter's sprite tracker tag. If you didn't set the tag inaddCameraFilter, you'll just need to put in the filter name instead. However, if this is just for a normal sprite, just simply put it's normal tag. -
float: The float's uniform identifier. -
to: The target end value. -
duration(optional): Determines how long the tween will take, defaults to1. -
options(optional): The tween's options; Refer toTweenOptions.
View Example
-- tweens the chrom's shader float "intensity" to 0.06.
shader.tweenShaderFloat('coolTween', 'chrom', 'intensity', 0.06, 2, {
ease = 'cubeIn'
})─────────────────────────
clearRuntimeShader(shaderName: string): voidRemoves the specified shader from the runtimeShaders map. Enabling you to have a unique shader object without having to make a new fragment file just to have a unique value for each sprite with the same shader.
Parameters:
-
shaderName: The shader's file name.
GhostUtil 3.0.0 • Docs 3.0.0, Revision 1
a Lua Library made by GhostglowDev; for Psych Engine
© 2025 GhostglowDev — Ghost's Utilities
Licensed under the MIT License.