GLSL Color Correction in the bge?????

Hey everybody…
I have a question. Is there a way to do some color correction with the bge?
I know there are some 2D filter. And it would be awesome to have something similiar to the photoshop rgb curves, to adjust die color/mood of the overall scene.

For example to export the rgb curve nodes of the blender compositor to glsl code, and then put it in as a custom filter…

Has anyone experience with this? I think this would be an awesome feature for the bge!!!
This way it will be much easier to create different moods very quick!

LOL ur ques. always make me feel guilty why i forgot all python i had learned. :stuck_out_tongue:
Try this:

uniform sampler2D bgl_RenderedTexture;
void main(void)
  vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
  float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
  gl_FragColor = vec4(gray * vec3(0.8, 1.0, 1.2), texcolor.a);

This is a very simple example which I got from wiki but you can do alot with 2d filters.
Maybe someone with better knowledge of GLSL would be able to help you more.
happy blending :wink:

1 Like

mohd.itqan is correct - the BGE currently has support for 2D filters. For example, here is one that desaturates - sorry for the overall junky code indentation - pasteall messed with it. You would create a custom 2D filter actuator, and then use the script in the 2dfilter.shaderText property. You can also adjust the strength of the desaturation filter using the ‘percent’ property (in the script).

There’s a new option called “Colour Correction” in the Render Settings of 2.58 bge. i don’t know if that’s what you are lookin for. i have also heard about tweaking the Ambient Occlusion for changing overall mood/tone of the game in a video tutorial.

hey… thank you all for your help!!
I am writing my own shader right now… woohoo!!! it is a simple color correction with colortinting and contrast adjustments :smiley:
but it works! I still need to tweak it a bit!

Why can’t blender export glsl code created with nodematerials? this would be sooooo awesome!! :smiley:

Ok… I’ve finished my first simple screen shader.
I can adjust the rgb values via variables… that way I can tint the image!
I have a value vor saturation, one value for contrast and one for brightness…

If anyone is interested I can publish this shader

You may find this blog post I had found recently interesting:

It has various photoshop functions converted to GLSL.