uniform float sizeScalar; varying float particleID; varying vec4 particleColor; varying vec2 textureOffset; varying float textureDiv; #define SPRITE_TILING 4.0 // set this to the tilling factor in the sprite texture #define SPRITE_DIV 1.0 / SPRITE_TILING void main(void) { // The ICE graph defines the radius of each particle // and the hardware mapping widget on the "advanced" // tab stores the value of the radius attribute in the // R component of the color (see advanced tab). gl_PointSize = gl_SecondaryColor.g * sizeScalar; // pass the color of the particle to the fragment shader particleColor = gl_Color; // pass the ID of the particle to the fragment shader, this // will be used to generate texture coordinate into the // texture to select the right sprite image particleID = gl_SecondaryColor.r; textureOffset.x = SPRITE_DIV * mod(particleID,SPRITE_TILING); textureOffset.y = SPRITE_DIV * floor(SPRITE_TILING*SPRITE_TILING/particleID); textureDiv = SPRITE_DIV; // transform particle gl_Position = ftransform(); }