]> git.tdb.fi Git - libs/gl.git/commitdiff
Add the shader for UnlitMaterial
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Mar 2021 23:50:31 +0000 (01:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 11:46:15 +0000 (13:46 +0200)
This was supposed to be in 2f198e3

shaderlib/unlit.glsl [new file with mode: 0644]

diff --git a/shaderlib/unlit.glsl b/shaderlib/unlit.glsl
new file mode 100644 (file)
index 0000000..57be8b1
--- /dev/null
@@ -0,0 +1,28 @@
+import msp_interface;
+import common;
+
+uniform sampler2D texture;
+uniform vec4 tint;
+
+layout(constant_id=auto) const bool use_texture = false;
+layout(constant_id=auto) const bool use_vertex_color = false;
+layout(constant_id=auto) const bool use_fog = false;
+
+#pragma MSP stage(fragment)
+vec4 get_color()
+{
+       vec4 result = tint;
+       if(use_texture)
+               result *= texture(texture, texcoord.xy);
+       if(use_vertex_color)
+               result *= color;
+       return result;
+}
+
+void main()
+{
+       vec4 color = get_color();
+       if(use_fog)
+               color.rgb = apply_fog(color.rgb);
+       frag_color = color;
+}