Screen Distortion And Blur

Screen distortion and local blur
To create a screen distortion or blur effect, create a Texture object in the map editor and choose the right blendMode. The colours of your texture determine the strength of the effect. Here's what the colours do for the various relevant blendModes:

SCREEN_EFFECT_DISTORTION:


 * Red: horizontal distortion
 * Green: vertical distortion
 * Blue: levels effect
 * Alpha: ignored

SCREEN_EFFECT_BLUR:


 * Red: horizontal blur strength
 * Green: vertical blur strength
 * Blue: levels effect
 * Alpha: ignored

SCREEN_EFFECT_BLUR_AND_DISTORTION:


 * Red: horizontal distortion
 * Green: vertical distortion
 * Blue: levels effect
 * Alpha: blur strength (both horizontal and vertical)

Usage notes:


 * Distortion is neutral at colour 127 (grey). Below that is distortion to the left/bottom, above it is distortion to the right/top.
 * If you want to fade a distortion out towards the edges, you need to fade the colour in the texture towards 127, not towards 0.
 * The Levels effect is controlled by the "levelsBrightnesses" setting in the F1/F3 editor. This setting works similarly to how dragging the Levels arrows in Photoshop works. The blue colour of the texture determines the strength of the levels effect, so 0 means no effect.

Performance
Screen distortion and local blur are very expensive effects. Do not use them for subtle, hardly visible effects. Some performance rules/guidelines:


 * The strength of the distortion or blur hardly influences performance. A subtle distortion is as costly as a strong one. Only the size of the Texture matters for performance, and how many of such Textures are in view at the same time.
 * A blur effect becomes very costly when it covers a large portion of the screen.

Create distortion textures
The easiest way to create distortion textures is by creating a greyscale heightmap in Photoshop (black is low, white is high) and then running Photoshop's normal map generator. Finally, throw away the blue channel since a normal map uses one channel more than our distortion textures.