prosperon/source/shaders/sprite.sglsl

55 lines
756 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;
texcoords.y = 1 - texcoords.y;
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);
color.a = 1.0;
}
@end
@program sprite vs fs