prosperon/shaders/basetext.cg

61 lines
914 B
Plaintext
Raw Normal View History

2024-05-30 17:12:54 -05:00
@vs vs
in vec2 a_pos;
in vec2 a_uv;
struct letter {
vec2 pos;
vec2 wh;
vec2 uv;
2024-10-14 20:07:32 -05:00
vec2 uv_size;
2024-05-30 17:12:54 -05:00
vec4 color;
};
readonly buffer ssbo {
letter ls[];
};
2024-10-14 20:07:32 -05:00
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
2024-05-30 17:12:54 -05:00
out vec4 color0;
vec2 pos;
uniform mat4 vp;
@include_block vert
void main()
{
2024-10-14 20:07:32 -05:00
letter charData = ls[gl_InstanceIndex];
2024-10-15 17:15:50 -05:00
fuv = charData.uv + a_pos*charData.uv_size;
2024-05-30 17:12:54 -05:00
uv = a_uv;
2024-10-14 20:07:32 -05:00
color0 = charData.color;
pos = charData.pos+(a_pos*charData.wh);
2024-05-30 17:12:54 -05:00
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
2024-05-30 17:12:54 -05:00
sampler smp;
@include_block frag
void main()
{
float lettera = texture(sampler2D(text,smp),fuv).r;
frag();
2024-10-15 17:15:50 -05:00
color.a *= lettera;
2024-05-30 17:12:54 -05:00
}
@end
@program text vs fs