2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
uniform sampler2D texture;
|
|
|
|
|
2014-12-23 17:33:33 +00:00
|
|
|
uniform lowp vec4 tone;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-12-23 17:33:33 +00:00
|
|
|
uniform lowp float opacity;
|
|
|
|
uniform lowp vec4 color;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
uniform float bushDepth;
|
2014-12-23 17:33:33 +00:00
|
|
|
uniform lowp float bushOpacity;
|
2013-09-23 05:15:01 +00:00
|
|
|
|
|
|
|
varying vec2 v_texCoord;
|
|
|
|
|
2013-10-02 13:00:17 +00:00
|
|
|
const vec3 lumaF = vec3(.299, .587, .114);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
/* Sample source color */
|
2013-09-23 05:15:01 +00:00
|
|
|
vec4 frag = texture2D(texture, v_texCoord);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
/* Apply gray */
|
2013-10-02 13:00:17 +00:00
|
|
|
float luma = dot(frag.rgb, lumaF);
|
2013-09-01 14:27:21 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
/* Apply bush alpha by mathematical if */
|
2014-12-23 17:33:33 +00:00
|
|
|
lowp float underBush = float(v_texCoord.y < bushDepth);
|
2013-12-31 21:26:49 +00:00
|
|
|
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
gl_FragColor = frag;
|
|
|
|
}
|