prosperon/source/shaders/sprite.sglsl
2024-04-28 13:33:37 -05:00

52 lines
703 B
Plaintext

@vs vs
in vec2 vertex;
out vec2 texcoords;
out vec4 fcolor;
out vec4 femissive;
uniform app {
float time;
vec2 window;
};
uniform vp {
mat4 proj;
};
uniform sprite {
vec4 vcolor;
vec4 vemissive;
vec2 spritesize;
vec2 spriteoff;
mat4 model;
};
void main()
{
texcoords = vertex;
gl_Position = proj * model * vec4(vertex, 0, 1.0);
fcolor = vcolor;
femissive = vemissive;
}
@end
@fs fs
in vec2 texcoords;
in vec4 fcolor;
in vec4 femissive;
out vec4 color;
uniform texture2D image;
uniform sampler smp;
void main()
{
color = texture(sampler2D(image,smp), texcoords);
color *= fcolor;
color.xyz = mix(color.xyz, femissive.xyz, femissive.a);
}
@end
@program sprite vs fs