Skip to content
Snippets Groups Projects
Sprite.frag 463 B
Newer Older
  • Learn to ignore specific revisions
  • #version 450 core
    out vec4 FragColor;
    
    uniform sampler2D uSampler[32];
    uniform int uTextures[128];
    uniform vec4 uFrames[128];
    uniform vec2 uSizes[128];
    
    in vec2 Texture;
    flat in int Id;
    
    void main() {
        vec2 coord = vec2(
            (uFrames[Id].x / uSizes[Id].x) + (uFrames[Id].z / uSizes[Id].x) *  Texture.x, 
            (uFrames[Id].y / uSizes[Id].y) + (uFrames[Id].w / uSizes[Id].y) *  Texture.y  
        );
        FragColor = texture(uSampler[uTextures[Id]], coord);
    }