-- Use this function to perform your initial setup
displayMode(STANDARD)
function setup()
k = {}
g = {}
for x = 1, 20 do
k[x] = mesh()
k[x].texture = "Blocks:Stone"
k[x].color = vec3(1, 2, 1)
k[x].shader = shader("Project:Colorise")
g[x] = k[x]:addRect(0, 0, 0, 0)
end
--[[m = mesh()
m.texture = readImage("Blocks:Stone")
m.shader = shader("Effects:Ripple")
rIdx = m:addRect(0, 0, 0, 0)]]
--m:setRectColor(i, 255,0,0)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
--strokeWidth(5)
for x = 1, 20 do
k[x]:setRect(g[x], 20*x, 30, 25, 25)
k[x]:draw()
end
-- Here we set up the rect texture and size
--[[m:setRect(rIdx, WIDTH/2, HEIGHT/2, 180, 180)
-- Configure out custom uniforms for the ripple shader
m.shader.time = ElapsedTime
m.shader.freq = 2
-- Draw the mesh
m:draw()]]
end
The only change I’ve made in the shader is the fragment:
//
// A basic fragment shader
//
//Default precision qualifier
precision highp float;
//This represents the current texture on the mesh
uniform lowp sampler2D texture;
//The interpolated vertex color for this fragment
varying lowp vec4 vColor;
uniform vec3 color;
//The interpolated texture coordinate for this fragment
varying highp vec2 vTexCoord;
void main()
{
//Sample the texture at the interpolated coordinate
lowp vec4 col = texture2D( texture, vTexCoord ) * vColor;
//Set the output color to the texture color
gl_FragColor = vec4(col.r * color.x, col.g * color.y, col.b * color.z, 1);
}