]> git.tdb.fi Git - libs/gl.git/blob - shaderlib/unlit.glsl
Annotate uniforms with descriptor set layout qualifiers
[libs/gl.git] / shaderlib / unlit.glsl
1 import msp_interface;
2 import common;
3
4 struct UnlitMaterialParameters
5 {
6         vec4 color;
7 };
8
9 layout(set=1) uniform UnlitMaterial
10 {
11         UnlitMaterialParameters unlit_material;
12         float alpha_cutoff;
13 };
14
15 layout(set=1) uniform sampler2D color_tex;
16
17 layout(constant_id=auto) const bool use_texture = false;
18 layout(constant_id=auto) const bool use_vertex_color = false;
19 layout(constant_id=auto) const bool use_fog = false;
20 layout(constant_id=auto) const bool use_alpha_cutoff = false;
21
22 #pragma MSP stage(fragment)
23 virtual vec4 get_color()
24 {
25         vec4 result = unlit_material.color;
26         if(use_texture)
27                 result *= texture(color_tex, texcoord.xy);
28         if(use_vertex_color)
29                 result *= color;
30         return result;
31 }
32
33 void main()
34 {
35         vec4 color = get_color();
36         if(use_alpha_cutoff && color.a<alpha_cutoff)
37                 discard;
38
39         if(use_fog)
40                 color.rgb = apply_fog(color.rgb);
41         frag_color = color;
42 }