prosperon/shaders/basetext.cg
2024-10-15 17:15:50 -05:00

61 lines
914 B
Plaintext

@vs vs
in vec2 a_pos;
in vec2 a_uv;
struct letter {
vec2 pos;
vec2 wh;
vec2 uv;
vec2 uv_size;
vec4 color;
};
readonly buffer ssbo {
letter ls[];
};
out vec2 uv; // Normalized UV, from 0 to 1 on the letter, for special effects
out vec2 fuv; // This is the UV given to get the correct letter from the texture
out vec4 color0;
vec2 pos;
uniform mat4 vp;
@include_block vert
void main()
{
letter charData = ls[gl_InstanceIndex];
fuv = charData.uv + a_pos*charData.uv_size;
uv = a_uv;
color0 = charData.color;
pos = charData.pos+(a_pos*charData.wh);
vert();
gl_Position = vp * vec4(pos, 0.0, 1.0);
}
@end
@fs fs
in vec2 uv;
in vec2 fuv;
in vec4 color0;
out vec4 color;
texture2D text;
@sampler_type smp nonfiltering
sampler smp;
@include_block frag
void main()
{
float lettera = texture(sampler2D(text,smp),fuv).r;
frag();
color.a *= lettera;
}
@end
@program text vs fs