Upload
korhan-bircan
View
25
Download
1
Embed Size (px)
Citation preview
1
Game Programming Tricks
Part INext-Gen Shaders
Korhan BircanApril 8th, 2008
2
Shader Models
3
Post Processing EffectsBlur – Combine pixel color with surrounding pixel colorsMotion Blur – Combine current frame with previous frame(s)Depth of Field – Blur pixel based on their depth valueHDR effects – Bloom, lens flare etc.Magnify bright spots Edge Glow – Find edges and blur themParallax Mapping – improved bump mapping
4
Gaussian Blur// f(x) = a*e^-((x-b)^2)/r// a = 1; b = 0; r = radius;// f(x) = pow(e, -(x)^2/r)weights[i*width + j] = pow(E, -pow(dist, 2.0)*_1_over_r) );// usually just have a precomputed table
float4 PostProcessPS(float2 Tex : TEXCOORD0) : COLOR0{
float4 Color = 0;
for (int i = 0; i < m_KernelSize; i++){
Color += tex2D(m_SrcColor, Tex + TexelKernel[i].xy ) * weights[i];
}
return Color;}
5
Gaussian Blur
6
Radial Blur
7
Radial Blur
8
Motion Blur
9
Depth of Field
10
Depth of Field
11
Depth of Field
12
Depth of Field
13
14
Haze
15
Haze
16
Haze
17
Haze
1
32
64
96
128
18
Haze
19
Haze – Particle System
20
High Dynamic Range (HDR) Rendering
21
HDR Rendering
22
HDR Rendering
•down filter 4x
•bright pass
•bloom horizontal
•bloom vertical
•up filter 4x
•combine
23
HDR Rendering
24
Exposure Control
25
Glow
•edge detection
•down filter 4x
•blur horizontal
•blur vertical
•combine 4x
26
Light Streaks
27
Lens Flare
28
Parallax Mapping
diffuse shading bump mapping parallax mapping
29
Bump Mapping
texture map
height map
bump map
30
Parallax Mappingbump mapping:
naive parallax mapping:
31
Parallax Mapping
32
Steep Parallax Mapping
33
References•Shaders for Game Programmers and Artists, Sebastian St-Laurent
•Programming Vertex and Pixel Shaders, Wolfgang Engel
•DirectX SDK Documentation
•NVIDIA Gpu Gems Series
•Steep Parallax Mapping, Morgan McGuire, Max McGuire