亮度brightness其实是对RGB的调整,RGB值越大,效果越亮;反之则越暗。
GPUImage中提供了对图像亮度调整的Filter,其核心代码如下(fragment):
1 varying highp vec2 textureCoordinate; 2 3 uniform sampler2D inputImageTexture; 4 uniform lowp float brightness; 5 6 void main() 7 { 8 lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); 9 10 gl_FragColor = vec4((textureColor.rgb + vec3(brightness)), textureColor.w); 11 }
其中brightness的取值范围为[-1,1]