Skip to content

Instantly share code, notes, and snippets.

@yomotsu
Last active April 2, 2016 12:04
Show Gist options
  • Save yomotsu/1d4cbcabbe791a69a4f5c2d00dfa2577 to your computer and use it in GitHub Desktop.
Save yomotsu/1d4cbcabbe791a69a4f5c2d00dfa2577 to your computer and use it in GitHub Desktop.
spriteAnimation in particle
uniform vec2 spriteLength;
uniform sampler2D texture;
varying float progress;
void main() {
vec2 texCoord = vec2(
gl_PointCoord.x / spriteLength.x + 1. / spriteLength.x * floor( spriteLength.x * progress * spriteLength.y ),
1. - ( gl_PointCoord.y / spriteLength.y + 1. / spriteLength.y * floor( spriteLength.y * progress ) )
);
gl_FragColor = texture2D( texture, vec2( texCoord ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment