+SHADER_DEFINE( shader_buttons,
+ // VERTEX
+ "layout (location=0) in vec2 a_co;"
+ "uniform vec4 uOffset;" // Tile x/y, uv x/y
+ "uniform mat3 uPv;"
+ ""
+ "out vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ // Vertex transform
+ "vec3 worldpos = vec3( a_co + uOffset.xy, 1.0 );"
+ "gl_Position = vec4( uPv * worldpos, 1.0 );"
+
+ // Create texture coords
+ "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
+ "aTexCoords = (edge_safe_coords + uOffset.zw) * 0.25;"
+ "}",
+
+ // FRAGMENT
+ "out vec4 FragColor;"
+ ""
+ "uniform sampler2D uTexMain;"
+ "uniform vec4 uColour;" // rgb, light amount
+ ""
+ "in vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec4 glyph = texture( uTexMain, aTexCoords.xy );"
+
+ "FragColor = vec4( uColour.rgb * (mix(glyph.r, glyph.g, uColour.a)+0.02)*2.6 + glyph.b * 0.4, glyph.a );"
+ "}"
+ ,
+ UNIFORMS({ "uPv", "uOffset", "uTexMain", "uColour" })
+)
+
+SHADER_DEFINE( shader_sprite,
+
+ // VERTEX
+ "layout (location=0) in vec2 a_co;" // quad mesh
+ "uniform vec4 uUv;"
+ "uniform vec3 uPos;"
+ ""
+ "uniform mat3 uPv;"
+ ""
+ "out vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec2 vertex_world = uUv.zw * (a_co-0.5) * uPos.z + uPos.xy;"
+ "gl_Position = vec4( uPv * vec3( vertex_world, 1.0 ), 1.0 );"
+ "aTexCoords = uUv.xy + a_co*uUv.zw;"
+ "}",
+
+ // FRAGMENT
+ "uniform sampler2D uTexMain;"
+ "out vec4 FragColor;"
+ ""
+ "in vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec4 texture_sample = texture( uTexMain, aTexCoords );"
+ "FragColor = texture_sample;"
+ "}"
+ ,
+ UNIFORMS({ "uPv", "uTexMain", "uUv", "uPos" })
+)
+
+SHADER_DEFINE( shader_post_darken,
+ "layout (location=0) in vec2 a_co;"
+ "out vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "gl_Position = vec4( a_co * 2.0 - 1.0, 0.0, 1.0 );"
+ "aTexCoords = a_co;"
+ "}",
+
+ "uniform sampler2D uTexMain;"
+ "out vec4 FragColor;"
+ ""
+ "in vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec4 texture_sample = texture( uTexMain, aTexCoords );"
+ "FragColor = vec4(pow(texture_sample.rgb,vec3(2.2)), 1.0);"
+ "}"
+ ,
+ UNIFORMS({"uTexMain"})
+)
+
+SHADER_DEFINE( shader_post_blur,
+ "layout (location=0) in vec2 a_co;"
+ "out vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "gl_Position = vec4( a_co * 2.0 - 1.0, 0.0, 1.0 );"
+ "aTexCoords = a_co;"
+ "}",
+
+ "uniform sampler2D uTexMain;"
+ "uniform vec2 uDir;"
+ "out vec4 FragColor;"
+ ""
+ "in vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec4 colour = vec4(0.0);"
+
+ "vec2 off1 = vec2(1.411764705882353) * uDir;"
+ "vec2 off2 = vec2(3.2941176470588234) * uDir;"
+ "vec2 off3 = vec2(5.176470588235294) * uDir;"
+ "colour += texture2D( uTexMain, aTexCoords ) * 0.1964825501511404;"
+ "colour += texture2D( uTexMain, aTexCoords + off1 ) * 0.2969069646728344;"
+ "colour += texture2D( uTexMain, aTexCoords - off1 ) * 0.2969069646728344;"
+ "colour += texture2D( uTexMain, aTexCoords + off2 ) * 0.09447039785044732;"
+ "colour += texture2D( uTexMain, aTexCoords - off2 ) * 0.09447039785044732;"
+ "colour += texture2D( uTexMain, aTexCoords + off3 ) * 0.010381362401148057;"
+ "colour += texture2D( uTexMain, aTexCoords - off3 ) * 0.010381362401148057;"
+ "FragColor = colour;"
+ "}"
+ ,
+ UNIFORMS({"uTexMain","uDir"})
+)
+
+SHADER_DEFINE( shader_post_comp,
+ "layout (location=0) in vec2 a_co;"
+ "out vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "gl_Position = vec4( a_co * 2.0 - 1.0, 0.0, 1.0 );"
+ "aTexCoords = a_co;"
+ "}",
+
+ "uniform sampler2D uTexMain;"
+ "uniform sampler2D uTexBloom;"
+ "uniform vec2 uComp;" /* x: bloom, y: vignette */
+ "out vec4 FragColor;"
+ ""
+ "in vec2 aTexCoords;"
+ ""
+ "void main()"
+ "{"
+ "vec4 texture_sample = texture( uTexMain, aTexCoords );"
+ "vec4 bloom_sample = texture( uTexBloom, aTexCoords );"
+
+ "vec2 vigCoord = aTexCoords - 0.5;"
+ "float vig = pow(1.0 - dot( vigCoord, vigCoord ), 2.0);"
+
+ "FragColor = (texture_sample + bloom_sample*0.3*uComp.x)"
+ " * max(uComp.y, vig);"
+ "}"
+ ,
+ UNIFORMS({"uTexMain", "uTexBloom", "uComp"})
+)