Using the kitchen sink plane shader for viewport effects, even if only a small part of them are active, incurs great performance loss on mobile, so split the rendering into multiple optional passes which additionally use the blending hardware for faster mixing (lerping). Also, don't mirror the PingPong textures if the viewport effect covers the entire screen area anyway.
19 lines
335 B
GLSL
19 lines
335 B
GLSL
|
|
uniform sampler2D texture;
|
|
uniform lowp float gray;
|
|
|
|
varying vec2 v_texCoord;
|
|
|
|
const vec3 lumaF = vec3(.299, .587, .114);
|
|
|
|
void main()
|
|
{
|
|
/* Sample source color */
|
|
vec4 frag = texture2D(texture, v_texCoord);
|
|
|
|
/* Apply gray */
|
|
float luma = dot(frag.rgb, lumaF);
|
|
frag.rgb = mix(frag.rgb, vec3(luma), gray);
|
|
|
|
gl_FragColor = frag;
|
|
}
|