Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES shader to convert color image to black-and-white infrared?

I was able to create a fragment shader to convert a color image to greyscale, by:

 float luminance = pixelColor.r * 0.299 + pixelColor.g * 0.587 + pixelColor.b * 0.114;
 gl_FragColor = vec4(luminance, luminance, luminance, 1.0);

Now I'd like to mimic a Photoshop channel mixer effect:

Black & White Infrared

How can I translate the % percentage values (-70%, +200%, -30%) into r g b floating point numbers (e.g. 0.299, 0.587, 0.114)?

like image 234
ohho Avatar asked Jun 08 '11 07:06

ohho


1 Answers

You should know from school that 10% of a value means multiplying that value by 0.1, so just use (-0.7, 2.0, -0.3).

like image 62
Christian Rau Avatar answered Sep 29 '22 17:09

Christian Rau