Starting in GLSL ( Contrast Control Shader )

Hello everyone

Well, I’m starting to study the implementation of the Blender GLSL Shaders. I have many questions… :smiley:

First I would like to know about a bug and I’m q … The effect of the Motion Blur Filter 2D actuator does not work. Why?

The Bloom shader that at some resources of the Apricot project does not work too.

My VGA is a ATI X800GTO and i have the all newest drives for it.


This, I think.

It will be interesting to see what you will accomplish in GLSL

Is there a problem in ATI and BGE GLSL ?
I’m starting now, will not be big thinks for some time I believe rsrsrs

Beyond Shadows, Normal maps, Spec Maps, and such. If you want a “custom” glsl shader in the GE. Such as one you wrote yourself or if you find one online, you must put the GLSL script in the python script. Here is a tutorial:


Hope that Helps!

Didn’t ATI just release new drivers that ‘fixes’ the OpenGL support? One in this thread said Blender is now fast and smooth with ATI.

I’m no expert on Blender Game Engine shaders, but I’ll give it a go.

From what I understand, you can use shaders in two distinct ways in the Blender Game Engine.

There are fullscreen 2D shaders, which can affect all of the pixels on the entire screen.

And material shaders, which only affect pixels/vertices of objects that the shader is applied. For example, if you have a cube with a material shader in a scene, only the pixels/vertices of the cube will be affected by the shader on the cube.

There are also two types of shaders defined by GLSL, fragment shaders (modify pixels), and vertex shaders (modify vertices).

Fullscreen 2D shaders can be controlled by the 2D filter actuator, and you can set this actuator to use a custom GLSL fragment shader that you wrote, though there are a number of great built-in shaders. The Fullscreen 2D shader must a fragment shader, not a vertex shader.

Material shaders can be controlled by many different factors. Most common shaders are available for use right in the material buttons themselves. You can set a texture as a “Nor” map, and blender will use it’s own normal map shader without you having to know anything about GLSL code. If you don’t know how to set a “Nor” map for the game engine, it’s the same material setup for if you were going to make a normal blender render.

For more complex shaders, you may use material nodes with the node window to create shaders that will run in the Blender Game Engine, and will also affect blender renders.

For even more complex shaders, you can in fact code them in GLSL yourself, and apply them in Python to an object’s material.

For material shaders, you can write Fragment and Vertex shaders.

Currently I know how to use all shaders more “simple” of BGE, including using node editor (fresnel water created by me ) My interest is really more sophisticated shaders to implement both the level of object when the level of filtro2D

I understand how these shaders are applied in Blender but I can not understand how the scripts work, how to access a vertex or pixel … or mostly how “translate” or use a shader writing to the RenderMonkey in a Blender…

I am particularly interested in implementing shaders as Fur (for grass), Motion Blur, DOF, HDR or Bloom, AmbientOclusion (Real Time), CubeMap Real Time ( Videotexture provide only FlatReflecions ), Refractions… etc

I´m using this drive, Catalyst 9.1 … and problems remain…

the question is? What the limitations or differences q I have to take into consideration when writing a shader to run on the BGE? I can use all the features of GLSL OpenGL 2.1 or 2.0?

OBS: The documentation for GLSL in BGE is poor! Very Poor!

Yes, I agree that the documentation is very poor. The main problem is that the shaders are not optimized. Nonetheless good luck!

Got a very simple test based on an old script of Toon Shader, I am beginning to understand how some information is passed from the scene into the shader and interfere in some variables. But there is still much work to do to be set up something really good… Enjoy


ToonShader.blend (55.5 KB)

It’s good you are interested in increasing the BGE’s hardcoded graphical abilities, but first you should consider how to make the current real-time rendering as fast as it can possibly go, this’ll give designers more FPS to play with to add more advanced effects, an artist can’t have real-time AO if it makes the game real slow.

I really would like to improve the FPS GameEngine. But that is far above of my ability in programming. Maybe i can programming a shader. But work on source code Blender already exceeds my abilities =/.
This is a work for a “Super Ben” xD

I developed a fix for the shader contrast, to make the games more like the BGE that use the Unreal 3. (I believe they have a shader like this). Below is my castle scene with and without the filter. Unfortunately the loss of FPS is still substantial (I see that the integration of 2D filter shaders in blender is extremely slow, no matter how simple is the shader) I hope that this can be fixed soon …

// ################
// #       Vitor Balbio 
// #  Contrast fix Filter
// ######################
uniform sampler2D bgl_RenderedTexture;
float val = 0.1; // control valor
void main(void)
     vec4 texcolor = texture2D(bgl_RenderedTexture,gl_TexCoord[0].st);
    gl_FragColor = vec4((texcolor.rgb * texcolor.rgb)+val,texcolor.a)  ;



I just downloaded and played it. for some reason I have white artifacts around the edges of everything that has an alpha map.