#blend mix #depth off #primitive triangle #cull none @vs vs in vec3 a_pos; in vec2 a_uv; out vec2 uv; out vec4 shade; vec3 pos; struct sprite { mat4 model; vec4 rect; vec4 shade; }; readonly buffer ssbo { sprite sprites[]; }; uniform mat4 vp; uniform float baseinstance; void main() { sprite s = sprites[int(baseinstance)+gl_InstanceIndex]; pos = a_pos; uv = a_uv; pos *= vec3(s.rect.zw,1); uv = (uv*s.rect.zw)+s.rect.xy; gl_Position = vp * s.model * vec4(pos, 1.0); shade = s.shade; } @end @fs fs in vec2 uv; in vec4 shade; out vec4 color; texture2D diffuse; @sampler_type smp nonfiltering sampler smp; void frag() { color = texture(sampler2D(diffuse,smp), uv); color *= shade; } void main() { frag(); } @end @program sprite vs fs