I’ve started playing with the glsl shaders in a Codea but I’m trying to create a simple light, I’ve tried a few tutorials and a few copy and paste solutions out of desperation but none of them seem to work (at all)
Could one of you kind souls help me out with just a simple ambient light to give my cube a little more life please?
function shadeCube(oC)
local sA = 100
local c = {}
-- Far
for i = 1,6 do
table.insert(c,color(oC.r-sA,oC.g-sA,oC.b-sA))
end
-- Left
for i = 1,6 do
table.insert(c,color(oC.r-sA,oC.g-sA,oC.b-sA))
end
-- Close
for i = 1,6 do
table.insert(c,color(oC.r-sA/2,oC.g-sA/2,oC.b-sA/2))
end
-- Right
for i = 1,6 do
table.insert(c,oC)
end
-- Top
for i = 1,6 do
table.insert(c,oC)
end
-- Bottom
for i = 1,6 do
table.insert(c,color(oC.r-sA,oC.g-sA,oC.b-sA))
end
return c
end
The ordre of the cube faces are in the code. “sA” is the shadow amount.
I’ll be covering all sorts of lights in the next few posts, including point lights (lights that are in your scene, like streetlights), spotlights (lights focussed in one direction, like torches), flickering, maybe more.
Shader lighting is not for complete beginners, though, be warned!