fuckingtech/public/assets/glsl/lygia/animation/spriteLoop.glsl
Elias Rhouzlane bf76c6b086 fix: code
2025-04-06 17:23:52 +02:00

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