#version 120 #extension GL_EXT_gpu_shader4 : require uniform sampler2DRect matrixTexture; uniform sampler2DRect colorTexture; uniform mat4 mvpMatrix; void main(){ float y = 0; float x = gl_InstanceID*4; mat4 transformMatrix = mat4( texture2DRect(matrixTexture, vec2((x+0.5), y+0.5)), texture2DRect(matrixTexture, vec2((x+1.5), y+0.5)), texture2DRect(matrixTexture, vec2((x+2.5), y+0.5)), texture2DRect(matrixTexture, vec2((x+3.5), y+0.5))); // Multiply the shape coordinates by the transformation matrix // Offset by the position vec4 vPos = transformMatrix * gl_Vertex; // Set the front color to the color passed through with glColor gl_FrontColor = texture2DRect(colorTexture, vec2((gl_InstanceID+0.5), 0.5)); gl_BackColor = gl_FrontColor; // Multiply by the model view and projection matrix gl_Position = mvpMatrix * vPos; }