From BlenderWiki

Jump to: navigation, search

Filter 2D Actuator

2D Filters are image filtering actuators, that apply on final render of objects.

Filter 2D Type

Select the type of 2D Filter required.
Edit Object actuator
Custom Filter
Invert
Sepia
Gray Scale
Prewitt
Sobel
Laplacian
Erosion
Dilation
Sharpen
Blur
Motion Blur
Remove Filter
Disable Filter
Enable Filter
Only one parameter is required for all filters
Pass Number
The pass number for which this filter is to be used.
Details of the filters are given in the descriptive text below.


Motion Blur

Motion Blur is a 2D Filter that needs previous rendering information to produce motion effect on objects. Below you can see Motion Blur filter in Blender window, along with its logic bricks:

2D Filters: Motion Blur.
2D Filters: Game Logic.

To enable this filter:

  1. Add appropriate Sensor(s) and Controller(s).
  2. Add a 2D Filter Actuator.
  3. Select Motion Blur in the drop-down list.
  4. Set Motion Blur Value (Factor).

And for disabling this filter:

  1. Add appropriate Sensor(s) and Controller(s).
  2. Add a 2D Filter Actuator.
  3. Select Motion Blur.
  4. Toggle Enable button to go to disabled mode.

You can enable Motion Blur filter using a Python controller:

from bge import render
render.enableMotionBlur(0.85)

And disable it:

from bge import render
render.disableMotionBlur()
Note
Your graphic hardware and OpenGL driver must support accumulation buffer (glAccum function).


Built-In 2D Filters

All 2D filters you can see in 2D Filter actuator have the same architecture, all built-in filters use fragment shader to produce final render view, so your hardware must support shaders.

2D Filters: Motion Blur.
2D Filters: Sepia.
2D Filters: Sobel.

Blur, Sharpen, Dilation, Erosion, Laplacian, Sobel, Prewitt, Gray Scale, Sepia and Invert are built-in filters. These filters can be set to be available in some passes.

To use a filter you should:

  1. Create appropriate sensor(s) and controller(s).
  2. Create a 2D Filter actuator.
  3. Select your filter, for example Blur.
  4. Set the pass number that the filter will be applied.

To remove a filter on a specific pass:

  1. Create appropriate sensor(s) and controller(s).
  2. Create a 2D Filter actuator.
  3. Select Remove Filter.
  4. Set the pass number you want to remove the filter from it.

To disable a filter on a specific pass:

  1. Create appropriate sensor(s) and controller(s).
  2. Create a 2D Filter actuator.
  3. Select Disable Filter.
  4. Set the pass number you want to disable the filter on it.

To enable a filter on a specific pass:

  1. Create appropriate sensor(s) and controller(s)
  2. Create a 2D Filter actuator.
  3. Select Enable Filter.
  4. Set the pass number you want to enable the filter on it.


Custom Filters

2D Filters: Custom Filter.

Custom filters give you the ability to define your own 2D filter using GLSL. Its usage is the same as built-in filters, but you must select Custom Filter in 2D Filter actuator, then write shader program into the Text Editor, and then place shader script name on actuator.

Blue Sepia Example:

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);
}