prosperon/source/shaders/sprite.sglsl

52 lines
703 B
Plaintext
Raw Normal View History

@vs vs
in vec2 vertex;
out vec2 texcoords;
out vec4 fcolor;
out vec4 femissive;
2024-04-23 15:58:08 -05:00
uniform app {
float time;
vec2 window;
};
uniform vp {
mat4 proj;
};
uniform sprite {
vec4 vcolor;
vec4 vemissive;
vec2 spritesize;
vec2 spriteoff;
mat4 model;
};
void main()
{
2024-04-23 18:12:45 -05:00
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;
2024-04-23 15:58:08 -05:00
out vec4 color;
uniform texture2D image;
uniform sampler smp;
void main()
{
2023-10-10 17:37:58 -05:00
color = texture(sampler2D(image,smp), texcoords);
color *= fcolor;
color.xyz = mix(color.xyz, femissive.xyz, femissive.a);
}
@end
@program sprite vs fs