mkxp-z/shader/tilemap.frag
Aeodyn 050da27ca0 Brought the tilemap class mostly in line with Essential's CustomTilemap wrt animations, though at the cost of backwards compatibility.
(This could be rescued by per-tile animation lentghs in tilemap.vert, but this should suffice for now.)
2020-07-14 19:34:38 +00:00

33 lines
569 B
GLSL

uniform sampler2D v_texture;
uniform lowp vec4 tone;
uniform lowp float opacity;
uniform lowp vec4 color;
in vec2 v_texCoord;
const vec3 lumaF = vec3(.299, .587, .114);
out vec4 fragColor;
void main() {
/* Sample source color */
vec4 frag = texture(v_texture, v_texCoord);
/* Apply gray */
float luma = dot(frag.rgb, lumaF);
frag.rgb = mix(frag.rgb, vec3(luma), tone.w);
/* Apply tone */
frag.rgb += tone.rgb;
/* Apply opacity */
frag.a *= opacity;
/* Apply color */
frag.rgb = mix(frag.rgb, color.rgb, color.a);
fragColor = frag;
}