uniform sampler2D spriteTexture; // the 4x4 sprite texture varying float particleID; // the ID of the particle we are drawing varying vec4 particleColor; // the color of the particle varying vec2 textureOffset; varying float textureDiv; void main() { // calculate new texture coordinate into the sprite texture vec2 spriteCoord = gl_TexCoord[0].xy; spriteCoord *= textureDiv; spriteCoord += textureOffset; // fetch the texel vec4 col = texture2D(spriteTexture, spriteCoord); // blend in the particle color col *= particleColor; // output the fragment gl_FragColor = col; }