|
require("eyesy") |
|
|
|
modeTitle = "S - Lissajous Plasma Ramps" |
|
modeExplain = "Demonstrate loading a shader in Eyesy ofLua, by Anagram/Dewb" |
|
|
|
print(modeTitle) |
|
print(modeExplain) |
|
|
|
function script_path() |
|
local str = debug.getinfo(2, "S").source:sub(2) |
|
return str:match("(.*/)") |
|
end |
|
|
|
print(script_path()) |
|
|
|
function setup() |
|
w = of.getWidth() |
|
h = of.getHeight() |
|
time = 0 |
|
|
|
k1s = knob1 |
|
k2s = knob2 |
|
k3s = knob3 |
|
k4s = knob4 |
|
k5s = knob5 |
|
|
|
inLTexture = of.Texture() |
|
inRTexture = of.Texture() |
|
inLTexture:allocate(256, 1, 0x1903) -- of.GL_RED |
|
inRTexture:allocate(256, 1, 0x1903) -- of.GL_RED |
|
|
|
shader = of.Shader() |
|
shader:load(script_path() .. "vertex.glsl", script_path() .. "fragment.glsl", "") |
|
end |
|
|
|
function update() |
|
time = (time + of.getLastFrameTime()) % 3600.0 |
|
|
|
-- basic knob smoothing |
|
k1s = (k1s + knob1) / 2 |
|
k2s = (k2s + knob2) / 2 |
|
k3s = (k3s + knob3) / 2 |
|
k4s = (k4s + knob4) / 2 |
|
k5s = (k5s + knob5) / 2 |
|
|
|
-- need to enhance SWIG for loadData to convert table to float array? |
|
--inLTexture:loadData(inL, 256, 1, 0x1903) -- of.GL_RED |
|
--inRTexture:loadData(inR, 256, 1, 0x1903) -- of.GL_RED |
|
end |
|
|
|
function draw() |
|
shader:beginShader() |
|
shader:setUniform2f("resolution", w, h) |
|
shader:setUniform1f("time", time) |
|
shader:setUniform1f("knob1", k1s) |
|
shader:setUniform1f("knob2", k2s) |
|
shader:setUniform1f("knob3", k3s) |
|
shader:setUniform1f("knob4", k4s) |
|
shader:setUniform1f("knob5", k5s) |
|
of.drawRectangle(0, 0, w, h) |
|
shader:endShader() |
|
end |
|
|
|
function exit() |
|
print("script finished") |
|
end |