glsl计算sprite的亮度饱和度对比度
//glsl计算sprite的亮度饱和度对比度 #ifdef GL_ES precision mediump float; #endif uniform sampler2D u_texture; varying vec2 v_texCoord; varying vec4 v_fragmentColor; void main(void) { vec4 color = texture2D(u_texture, v_texCoord); if(color.a >= 0.4) { vec3 avg = vec3(0.5,0.5,0.5); vec3 luncoeff = vec3 (0.2125, 0.7154, 0.0721); float T1 = 0.4; float T2 = 2.4; //计算亮度 vec3 brtColor = color.rgb * T2; float intensityf = dot(brtColor,luncoeff); vec3 intensity = vec3(intensityf,intensityf,intensityf); //计算饱和度 vec3 satColor = vec3(mix(intensity, brtColor, 1.)); //计算对比度 vec3 conColor = vec3(mix(avg, satColor, T1)); gl_FragColor = vec4(conColor.r,conColor.g,conColor.b,color.a); } else { gl_FragColor = color; } }