Features:
- reloads shaders when they're saved
- include shaders into other shaders
- handles circular include dependencies
- errors output correct filename and line number
- send uniforms to shaders and ignore unused errors
ShaderScan on GitHub
Direct link to file
Example
MIT License
Live Reload
See shader changes live in your game.
Code: Select all
local ShaderScan = require 'shaderscan'
shaders = ShaderScan()
shaders:load_shader('splitcolor', 'shaders/splitcolor.glsl')
function love.update(dt)
-- Reloads shaders if the file changed. Keeps the original shader
-- if there was an error. Omit this line from production builds.
shaders:update(dt)
end
function love.draw()
love.graphics.setShader(shaders.s.splitcolor)
love.graphics.circle('fill', 400, 400, 500, 500)
end
Use #include directives to organize your shader code. All includes are relative to your project's root (the location of main.lua). They're processed at runtime and error reporting will report the correct file and line number.
Code: Select all
#include "example/lib/math.glsl"
Better Errors
Get errors with file, line number, and the specific line that failed:
Code: Select all
Error: shaderscan.lua:129: Loading 'splitcolor' failed: Error validating pixel shader code:
example/splitcolor.glsl:26: in 'splitcolor' ERROR: 'progres' : undeclared identifier
example/splitcolor.glsl:26: in 'splitcolor' ERROR: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
File: example/splitcolor.glsl
Line:
return mix(left, right, smoothstep01(progres));