# BGE Color Correction

**URL:** <https://blenderartists.org/t/bge-color-correction/561252>\
**Category:** Game Engine Support and Discussion\
**Created:** [January 3, 2013, 5:38am UTC](https://blenderartists.org/t/bge-color-correction/561252 "2013-01-03T05:38:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![whateva\_man](https://blenderartists.org/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@whateva\_man](https://blenderartists.org/u/whateva_man)\
**Post date:** [January 3, 2013, 5:38am UTC](https://blenderartists.org/t/bge-color-correction/561252/1 "2013-01-03T05:38:47Z")

</div>

Well, the last thread I found on this was closed over a year ago without any real answer to the question:  
  
**Is there a way to create color correction in GLSL?**

 

I made this small “framework”:_//code by flemming stäbler, 2013  
//use if you like, but don’t distribute this as your own!  
//no warranty, tested in blender 2.65 on an amd r6570._  
   
_uniform sampler2D bgl\_RenderedTexture;  
void main(void)  
{  
vec4 texcolor = texture2D(bgl\_RenderedTexture, gl\_TexCoord[0].st);_

 

float red = texcolor.r;  
float green = texcolor.g;  
float blue = texcolor.b;

float redl = red \* max((-2 \* red) +1, 0); //low band  
float greenl = green \* max((-2 \* green) +1, 0);  
float bluel = blue \* max ((-2 \* blue) +1 , 0);

float redm = red \* min(2 \* red, (-2 \* red) + 2); //mid band  
float greenm = green \* min(2 \* green, (-2 \* green) + 2);  
float bluem = blue \* min(2 \* blue, (-2 \* blue) + 2);

_float redh = red \* max((2 \* red) - 1, 0); //hi band  
float greenh = green \* max((2 \* green) - 1, 0);  
float blueh = blue \* max((2 \* blue) - 1, 0);_  
   
_**redl = redl \* 0.44;  
redm = redm \* 0.80;  
redh = redh \* 1.40;**_

 

greenl = greenl \* 0.48;  
greenm = greenm \* 0.55;  
greenh = greenh \* 1.64;

**bluel = bluel \* 0.65;  
bluem = bluem \* 0.50;  
blueh = blueh \* 1.22;**

float redf = redl + redm + redh; //summing it up  
float greenf = greenl + greenm + greenh;  
float bluef = bluel + bluem + blueh;

gl\_FragColor = vec4(redf, bluef, greenf, texcolor.a);  
}

The code brings down the framerate by around 5-10% for me.

**EDIT:**

 ![](https://blenderartists.org/uploads/default/original/3X/3/3/3388bc0ebc7ddead1d969c3cd570cd1f60838887.jpg)  

 ![](https://blenderartists.org/uploads/default/original/3X/5/f/5fff016ce2b7ac04ced8f9ceb38175d5fe9ff4c2.jpg)

---

<div class="post-metadata">

**Author:** ![krystof](https://blenderartists.org/user_avatar/blenderartists.org/krystof/32/13157_2.png) [@krystof](https://blenderartists.org/u/krystof)\
**Post date:** [January 4, 2013, 12:27pm UTC](https://blenderartists.org/t/bge-color-correction/561252/2 "2013-01-04T12:27:19Z")

</div>

This is really useful, thanks man 🙂
