Post Processing


You can do realtime image processing for rendered picture of 3d scene.  For post processing, program first render 3d scene to a texture, then do processing on the texture by every Post in turn. A Post is similarly to a Filter in Photoshop.

Workflow:

1. Create a new material
Click the "New" button in the Material Panel. Select a D3D Effect file from Awakening's '
effects\post' folder for the new material.

2. New a post
Click the "New" button in the Post Panel. A Select Material Dialog appears, select the material created in previous step.

3. Set Material Properties
Some effects like distort and levels needs setting textures to works well. Most effects have factors, you can define a Script Variable for the material, then do dynamic changing by scripting.

Preset Effects List:


Name
Preview Explanation
original image no post processing
auto - contrast result = (source + factor - 0.5 ) X 2

Factor:
dword factor

Usage:
local factor=toDWORD('60606060')
material.setEffectDword('dwARGB',factor)

PixelShader: No

Shader File: auto_contrast.sha

brightness/contrast
Factor:
number
brightness = [ -0.5 .. 0.5 ]
number
contrast = [ 0 .. 2 ]

Usage:
post_setBrightnessContrast( material, brightness ,contrast )

PixelShader: 1.0

Shader File: brightness_contrast.sha

blur

Factor:
number
blurfactor

Usage:
post_setBlur( material,
blurfactor )

PixelShader: No

Shader File: blur.sha

blur 2x  

Factor:
number
factor1, factor2

Usage:
post_setBlur2x( material,
factor1, factor2 )

PixelShader: 1.0

Shader File: blur_2x.sha

blur 4x

 

 

Factor:
number
factor1, factor2, factor3, factor4

Usage:

post_setBlur4x( material,
factor1, factor2, factor3, factor4 )

PixelShader: 1.0

Shader File: blur_4x.sha

color change

result = source X factor

Factor:
dword colorfactor

Usage:
local
colorfactor=toDWORD('ff4040ff')
material.setEffectDword('dwARGB',
colorfactor)

PixelShader:
No

Shader File: color_change.sha

distort

Factor:
number
bumptexture

Usage:
material.setTexture(0,
bumptexture)

PixelShader:
No

Shader File: distort.sha

glow Factor:
number
blurfactor
number
blendfactor
number threshold= [ 0 .. 1 ]

Usage:
post_setGlow( material, blurfactor, blendfactor, threshold )

PixelShader: 1.4

Shader File: glow.sha

desaturate Factor:
None

Usage:
None

PixelShader: 1.4

Shader File: gray.sha

invert Factor:
None

Usage:
None

PixelShader: 1.0

Shader File: invert.sha

levels

Factor:
number
r_texture
number g_texture
number b_texture

Usage:
material.setTexture(1,
r_texture)
material.setTexture(2,
g_texture)
material.setTexture(3,
b_texture)

PixelShader:
1.4

Shader File: levels.sha

gray levels

Factor:
number
texture

Usage:

material.setTexture(1,
texture)

PixelShader:
1.4

Shader File: levels_gray.sha

threshold

if ( source > 0.5 ) then result = lightcolor
else result = darkcolor

Factor:
vec4 
lightcolor
vec4 darkcolor

Usage:

material.setEffectVector('vecLightColor'',
lightcolor)
material.setEffectVector('vecDarkColor'',darkcolor)

PixelShader: 1.4

Shader File: threshold.sha

flexible threshold   

if ( source >= threshold ) then result = lightcolor
else result = darkcolor

Factor:
vec4 
lightcolor
vec4 darkcolor
number threshold

Usage:

post_setThresholdFlexible(material,
threshold, lightcolor, darkcolor)

PixelShader:
1.4

Shader File: threshold_flexible.sha

gray threshold

1. first desaturate source color
2. if (source>0.5) then result = lightcolor
else result = darkcolor

Factor:
vec4 
lightcolor
vec4 darkcolor

Usage:

material.setEffectVector('vecLightColor'',
lightcolor)
material.setEffectVector('vecDarkColor'',
darkcolor)

PixelShader: 1.4

Shader File: threshold_gray.sha

flexible gray threshold  

1. first desaturate source color
2. if ( source >= threshold ) then result = lightcolor
else result = darkcolor

Factor:
vec4 
lightcolor
vec4 darkcolor
number threshold

Usage:

post_setThresholdFlexible(material,
threshold, lightcolor, darkcolor)

PixelShader:
1.4

Shader File: threshold_gray_flexible.sha

edge detect

1. first invert source color and output to a texture
2. Add the texture to original data

PixelShader: 1.0

Shader File: invert.sha, addtex0.sha

glow and brighter

1. first do auto - contrast and output to a texture
2. Add the texture to original data

PixelShader: No

Shader File: auto_contrast.sha, addtex0.sha

Output to Texture:
You can assign a render target to a post, so output the post result to texture, not to screen any more. Then you can reuse the texture in succeeding posts. For example, you can first use a post to output whole image to a small texture, then enlarge the small texture to full screen in succeeding post, to create a consuming blurring effect.

Custom You Own Post