2d filter - built-in filters

in these papers you can find more information on my works on blender game engine

Blender Game Engine » 2D Filter » Other Filters

Menu

Links







Built-In 2D Filters

Built-In 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.

Blur, Sharpen, Dilation, Erosion, Laplacian, Sobel, Prewitt, Gray Scale, Sepia, 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 and controller
  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 and controller
  2. Create a "2D Filter" actuator
  3. Select "Remove Filter"
  4. Set the pass number you want to disable the filter on it 

To disable a filter on a specific pass:

  1. Create appropriate sensor and controller
  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 and controller
  2. Create a "2D Filter" actuator
  3. Select "Enable Filter"
  4. Set the pass number you want to disable the filter on it

Fig 4. represent the rendering architecture of these filters.

 

Fig 4. Rendering Architecture


The cube in Fig 4. represent the main rendering process  and each plane in Fig 4. is a 2d filter affect on main rendering process. maximum number of plains is 100(i.e. we can use only 100 2d filter applied on main rendering result). Each filter can be applied using a pass number that is the order of applying filters.


Example 1: we set a 2d filter on pass number 0:

 

Fig 5. Example 1

 

Example 2: set 2 filters, blur and sharpen, one on pass 1 and other on pass 5:

 


 Fig 6. Example 2


Note: In the above example we only use pass number 1 and 5, empty passes do nothing, so main render result will be affected first by blur and second by sharpen.

Note: Order of using  filters will affected  in the final result, for example in Fig 7. we use first dilation and then sharpen, and in Fig 8. we use first sharpen and then dilation:


Fig 7. First Dilation then Sharpen

 

Fig 8. First Sharpen then Dilation

 

These filters use fragment shader, so when a filter activated on a pass using a "2d Filter" actuator, on the first render after filter activation its shader compiles and links that takes time, use combination of "Enable Filter" and "Disable Filter" with your filter to initial it at game startup. Use 2d filter at startup and then disable it, so when you need it to be activated, just enable 2d filter for that pass.

If you want to remove a filter from a pass use "Remove Filter' on that pass.


Fig 9. Initialize a filter at startup