26 lines
No EOL
877 B
GLSL
26 lines
No EOL
877 B
GLSL
#include "../sample/sprite.glsl"
|
|
|
|
/*
|
|
contributors: Patricio Gonzalez Vivo
|
|
description: sample a frame on a sprite sheet
|
|
use: <SPRITELOOP_TYPE> SpriteLOOP(<SAMPLER_TYPE >tex, <vec2> st, <vec2> grid, <float> frame)
|
|
options:
|
|
- SAMPLER_FNC(TEX, UV)
|
|
- SAMPLESPRITE_TYPE: vec4
|
|
- SAMPLESPRITE_SAMPLER_FNC(UV)
|
|
examples:
|
|
- /shaders/animation_sprite.frag
|
|
license:
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
*/
|
|
|
|
#ifndef FNC_SPRITELOOP
|
|
#define FNC_SPRITELOOP
|
|
|
|
SAMPLESPRITE_TYPE spriteLoop(SAMPLER_TYPE tex, vec2 st, vec2 grid, float start_index, float end_index, float time) {
|
|
float frame = mod(time, end_index-start_index);
|
|
return sampleSprite(tex, st, grid, start_index + frame);
|
|
}
|
|
|
|
#endif |