2024-07-22 19:07:02 -05:00
|
|
|
@vs vs
|
|
|
|
in vec3 a_pos;
|
|
|
|
in vec2 a_uv;
|
|
|
|
out vec2 uv;
|
2024-09-10 14:33:49 -05:00
|
|
|
out vec4 shade;
|
2024-07-22 19:07:02 -05:00
|
|
|
|
|
|
|
vec3 pos;
|
|
|
|
|
|
|
|
struct sprite {
|
|
|
|
mat4 model;
|
|
|
|
vec4 rect;
|
2024-09-10 14:33:49 -05:00
|
|
|
vec4 shade;
|
2024-07-22 19:07:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
readonly buffer ssbo {
|
|
|
|
sprite sprites[];
|
|
|
|
};
|
|
|
|
|
|
|
|
uniform mat4 vp;
|
2024-09-29 06:10:42 -05:00
|
|
|
uniform float baseinstance;
|
2024-07-22 19:07:02 -05:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2024-09-29 06:10:42 -05:00
|
|
|
sprite s = sprites[int(baseinstance)+gl_InstanceIndex];
|
2024-07-22 19:07:02 -05:00
|
|
|
pos = a_pos;
|
|
|
|
uv = a_uv;
|
2024-09-27 10:19:05 -05:00
|
|
|
pos *= vec3(s.rect.zw,1);
|
2024-07-22 19:07:02 -05:00
|
|
|
uv = (uv*s.rect.zw)+s.rect.xy;
|
|
|
|
gl_Position = vp * s.model * vec4(pos, 1.0);
|
2024-09-10 14:33:49 -05:00
|
|
|
shade = s.shade;
|
2024-07-22 19:07:02 -05:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@fs fs
|
|
|
|
|
|
|
|
in vec2 uv;
|
2024-09-10 14:33:49 -05:00
|
|
|
in vec4 shade;
|
2024-07-22 19:07:02 -05:00
|
|
|
|
|
|
|
out vec4 color;
|
|
|
|
|
|
|
|
texture2D diffuse;
|
2024-10-02 11:56:33 -05:00
|
|
|
|
|
|
|
@sampler_type smp nonfiltering
|
2024-07-22 19:07:02 -05:00
|
|
|
sampler smp;
|
|
|
|
|
|
|
|
void frag()
|
|
|
|
{
|
|
|
|
color = texture(sampler2D(diffuse,smp), uv);
|
|
|
|
color *= shade;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
frag();
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@program sprite vs fs
|