Use Android 4×5 ColorMatrix in OpenGL ES 2 Shader

| | August 6, 2015

I am trying to use Android Color Matrix in OpenGL ES 2. I have been able to use a 4×4 Matrix using the following code in the Shader (this adds also an intensity parameter):

varying vec2 textureCoordinate;
uniform lowp mat4 colorMatrix;
uniform lowp float intensity;
void main()
    vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    vec4 outputColor = textureColor * colorMatrix;
    gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) *     textureColor);

But i am struggling on how i could convert Android 4×5 matrix to a vec4 matrix usable in the shader. I am not interested in Alpha channel.

Leave a Reply