Title: ?????? ?? ???? ????? ???????Pipeline
1 ?? ??? ????? ???
2 ?????? ?? ???? ????? ???????Pipeline
3(No Transcript)
4????? ? ?????
- ????? ? ??? ????
- ?? ???? ??? ???? ???????
- ????? ?????
- ????? ????? ????
- http//www.tochalco.com/blog
5??????? ?????
- ????? ??? ?????? ????? ?????
- ????? ??? ????? ?? DirectX10/11
- ????? ??? Deferred Rendering
- ???
6??????? ?????????
- ????? ????? ?? ????
- Deferred Rendering
- DirectX 10/11 API
7????? ??????
- ?????
- ??? ??????? ????? ??? ???? (????? 75) ???????
AAA ???? ?? ????? ????? ????? ??? ??? (??????? ?
??????? ??? ????? ?? ????? ????? ????? ???) - ??? ???????? ????? ??????? ?????? ?????
- ?????
- ???? ? ????? ????
- ???? ????? ????
- ??? ???? ???? ? ????? ????
????? ?????? ?????? ?????? ??? ????
8Deferred Rendering?
- ?????
- ?????? ???? ????? ????? ??? ???????
- ???? ????? ?????? ??????? ?? ??? ??????
- ???? ??????? ???? ???? ????? ???? ???? ??? Post
Process (Depth of Field, SSAO? Motion Blur? Soft
Particles) ?? ??? ???? Gbuffer - ???? ???? ????? ??? ?? ???? ????? ?????
- O Number of Objects
- L Number of Lights
- Forward (OL) Draws, example 1000 objects 20
lights 20000 draw calls - Deferred (O L) Draws, example 1000 objects
20 lights 1020 draw calls - ???? ???? ?? ???? pixel processing ?? ?????
?????? ??? ??? ????????? ?? ???? ?????? - ???? ???????? ???? ?? ??? ?????? deferred
??????? ?? ???? - CryEngine2, Rockstar RAGE (GTA4, Red dead
redemption), X-Ray engine (Stalker), Metro2033,
Dead Space engine, KillZone2, 3, and the list
is growing.
9Deferred Rendering?
- ?????
- ???? ?? Fill-rate ???? ?? ??? ???? ????? GBuffer
????? ?? ???? ??? ???? ??? ???? - ??? ??????? ?? ???? ????? ???? (Transparency)
- ?????? ?? Anti Aliasing
- ??? ?????? ????? ?? ???? ??????
- ?? ?? ??? ????? ????? ? ????? ??? ???? ?? ????
??? ?? ?????? ??? ???????? ??????? ? ?????? ?
??????? ???? API ?? (????? DirectX 10) ?????
??? ??? ???? ?? ??? ? ????? ?? ???? ?? ??????
???.
10DirectX 10?
- ?????
- Multi-Threaded Rendering
- ?????? fallback ??? ??? ???????? ????? ??
(Feature Level) - New texture compression formats
- Hardware Tessellation
- New helpful shader instructions (SampleCmpLevel,
Load, Gather, Bitwise, ) - New Render target formats, UINT (Raw)
- Geometry Shaders (Cubemap rendering)
- Compute Shaders (PostProcessing, GPU computing)
- Cleaner and Faster API
- Texture Arrays
11DirectX 10?
- ?????
- ??? ???????? ?? ????? ???? ??? ????? ?? ?? Vista
Windows - ??? ???????? ?? ??? ???????? ????? ??
- ???? ?? (???? ?? ??) ??? ?????? ????? (??? ????
?? ????? ???? ??? ????)
12DirectX 10?
- ?????
- ???? ?? ???? Steam http//store.steampowered.c
om/hwsurvey/
?? ???? ????? ??? ???? ?? ???? ????? ????? ???
??????? ? ????? ???? ???? ???? ?????? ?????? ???
? ?????? ????? ??? ??? API ???? ????? ???? ???.
13?????? ???? ??? ????
- ???????? ??? ?????? ???? ??? ????
- Big, Dynamic, Interactive worlds
- Per-Pixel lighting, Diffuse, Normal, Specular,
Ambient, Illumination, Reflection, Displacement
Maps - HDR Tonemapping, Bloom
- Motion Blur
- Depth of Field
- Skeletal, Morph animation
- Shadows
- Effects Decals, Particles, Water,
14Shaders
- ????? Fixed Pipeline ??????? ????? ???
- D3D10 ??? ?? ?????? ???????? ?? ???
- ???? ???? ??? ??????? ??? ??? ???? ???? ????
????? ???? ?? ????? - ?????? ???? ?? ?????? ? ???????? ?????? ??????
????? ????? (ShaderFX, Mental Mill, FXComposer,
RenderMonkey) - Pipeline ?? ? ???????? ??????? ???? ?????? ??????
? ????? ?????? ?? ?? ??? ????? ???????? ????
15???? ??? ?? ????? Pipeline
- ???? ?????? ????? ?? ??? ???????? ????? ?????? ??
???? (3dsmax, maya,) ?? ????? ???? - ????? ? ???? ???? ???? ????? ??? ????? ? ???
????? ?? ???? - ?? ???? ?? ???????? ???? ???? ?????? ??? ? ??????
????? ???? ?? ???? ??? ???????? ???? ???????
????? ??? - ???? ?????? ???? ?????? ?? ??? ????? ????? ??
?????? ?????? ????? ? ?????? ?????? ???? ????
(?????? ?? ????? ????? ????) - ???? ?????? ?? ????? ????? ??? ?? ???? ?? ???? ??
????? ?????? ????? ?? ??? ????? ???? (WYSIWYG) - ?????? ????? ????????? ????? ???? ?? ???? ??????
?? ?? ???? ?? Pipeline ????? ???? - ?????? ???? ???? ? ??????? ???? ??? ?? Pipeline
?? ????? ???? ???? ???? - ????? ?????? ??????? ???? ?????? ?????? ????? ??
??? ????? ?? ???? ?? ????? ??????
16?????? ????? ?????
- ?? ??? ???? (Deferred? Forward? Forward3dsmax)
- ShaderAuthor tool
- Shader Repository
- 3dsmax Exporter ???? ???? ?? ???? ??? ????? ????
- ???????? ?? COLLADA ? ???? ?????? ?????
- ??? ??????? ?? ?? ??? ???????? ?? ???? ???? ??
???? ?? ????? ????? ???? ??? WYSIWYG - ????? ???? ????? ?????? ??????? ???? 3dsmax ?
????? ?????? (FX material) - ?????? ??????? ????? ???? ????? ? ??????? ??????
(????????...) ????? Export ?? ???? ??????
17?????? ????? ?????
18?????? ????? ?????
19?????? ????? ?????
20?????? ????? ?????
21Exporting Solutions
- ??? ?? ? ???? ??? ?????? (FBX? Collada?x mesh...)
- ??????
- Game /GPU Friendly ????? ??? ??????
- ???? ??????? ????? ????? ????
- ???? ?? ?????? ???? ???? ????? ??? ?? ???? ??????
???? - ??? ???? ?????? ????
- ?????? ????? ?? ?????? ?????? ??? ????? ?? ???? ?
???????? ???? ?? ???? - ???? ???????? ???? ???? ??? ??? ?? ?????
- ???? ????? ?? Pipleline ????? ???? Exporter
?????? ? ????? ????? ???
22Tochal Exporter
- ????? ???? ????? ???? ??????? ???? ?? max ? ?????
(GPU Friendliness) - ???? ??? ????? ??? ???? ????? ? ???????? ?? ????
???? xml ? ?????? - ?????? ????? ??????? ?? ???? dds ?? ????? ????
??? ????? - ?????? ?????? ??????? ????? ????? ??? (POSITION,
NORMAL, TEXCOORD,) - ?????? ????? ???? Skin ? Bone? Hierarchy
- ????? ???? ?????? ? ?????????? ???? ???????
- ?????? ????? ?????? ??? ???? ?? ????? ???? ?????
????? - ????? ? ????? ?????? ??? (???????? ????? ??????
Mesh, Skin? ??? ???? ????? ?...)
23Tochal Exporter
- Artists work with common image formats like TGA,
PNG, JPG, - Texture Compression
- Diffuse (No alpha) BC1 (DXT1), 61 RGB
- Diffuse (With Alpha) BC2 (DXT3) / BC3(DXT5), 41
(RGBA) - Normal BC5 (ATI2N) (D3D10 hw only), 41 (RG)
- Specular BC4 (ATI1N) (D3D10 hw only), 41 (R)
- Ambient BC4 (ATI1N) (D3D10 hw only), 41 (R)
24Deferred Rendering - GBuffer
Depth
Normals
Material (Not viewable)
Color
25Deferred Rendering Gbuffer 2
- Depth Depth Buffer - D32 (FLOAT)
- Read depth value from depth buffer (zbuffer)
- Reconstruct position (view space) from depth
- Normals R16_G16 gt X,Y (FLOAT)
- Read Normal(x,y)
- Normal.z sqrt(1.0f xx yy)
- Color R8_G8_B8 (Albedo), A8 (Specular
Intensity) - Materials Encoded UINT32
26Deferred Rendering Materials
- Material UINT32
- Bits (1631) Material Id
- Bits(915) Ambient Multiplier
- Bits(08) Reserved !
- We have bitwise operations in D3D10 ?
Gbuffer (Material)
AmbientColor SpecularColor SpecularFallout Illumin
ation
Materials
Material Id
(Lighting Phase)
- Get Material Id
- Read back from Materials
- Maximum 4096 mtls (16bit)
- Read from tbuffer (Fast!)
(Draw phase)
Mesh
27Deferred Rendering - Transparency
- Impossible with deferred rendering
- Render alpha blended objects with conventional
forward rendering. - Transparency rendering is a hack afterall!
- Sort from back to front
- DepthEnable TRUE
- DepthWriteEnable FALSE
- Draw()
- Exciting !!! Fast Order independent transparency
(true transparency) possible with D3D11 CS - http//developer.amd.com/gpu_assets/OIT20and20In
direct20Illumination20using20DX1120Linked20Li
sts_forweb.ppsx - In near future Icy caves, translucent creatures,
glass houses, .
28Deferred Rendering - AA
- MSAA Deferred Rendering not possible with D3d9,
used edge detecting/bluring post process effects,
which is lame and slow ! - Possible with D3d10 but still tricky
- Better and faster with D3d10.1
- Draw Gbuffer to multiple MSAA render targets
- Use geometry shader edge detection or centeroid
sampling - Mark edges
- In lighting phase, for each marked edge,
calculate 2x/4x/8x samples. For none marked edge,
calculate for 1 sample. - We are still working on it !
29Deferred Rendering - Lighting
- Tile based deferred lighting
- Andrew Lauritzen - http//visual-computing.intel-r
esearch.net/art/publications/deferred_rendering/la
uritzen_deferred_shading_siggraph_2010.pptx - Divide screen in tiles
- Cull screen space lights with each tile
- Do deferred lighting
- Repeat for next tile
30 Deferred Rendering - Performance
- Scene 350k triangles PSSM Shadows
- Intel Core2 E5300 (low-end)
- ATI 4850 (mid-range)
- 200 Lights - 1024x768 133fps
- 100 Lights 1024x768 200fps
- 1000 Lights 1024x768 31 fps
- 1 Light (sun) 1024x768 302 fps
- Still room for more optimization
- Isnt it NICE ?!
- Throw dynamic lights everywhere. Explosions, gun
fire, car head lights, city lights, etc.
31Shadows - PSSM
- PSSM is just Cascaded shadow maps with efficient
frustum spliting scheme - Split view frustum in N parts with PSSM splitting
scheme - Adjust imaginary sun position on the bounding
sphere of the world - Detect shadow caster/receiver objects in each
split from lights point of view - Draw shadow maps for each split (total N shadow
maps) - When rendering objects, read back from proper
shadow map within position range
32Shadows PSSM 2
PSSM Frustum splitting scheme
- Reference Fan Zhang, Haniqiu Sun, Oskari Nyman,
GPU Gems 3 Chapter 10 - Fan Zhang PSSM Page http//appsrv.cse.cuhk.edu.h
k/fzhang/pssm_project/
33Shadows PSSM 3
- PROS
- Best looking shadows on big outdoor environments
- Preseves shadow quality within the whole view
range - Used in many big games Red dead redemption,
Assassins Creed, KillZone2, Battlefield2, - CONS
- Very GPU/CPU intensive (usually 3-4 big shadow
map renders, and 3-4 shadow map read backs with
branching, culling, etc.)
34Shadows PSSM Speed Problem
- Here comes D3D10 !
- Used methods presented in GPU Gems 3
- Using D3D10 specific stuff
- Texture Arrays, SampleCmpLevelZero()
- Geometry shaders
- D3D10 Instancing
- Branching (also applicable to D3d9 sm3.0 hw)
- With the help of D3D10 Generating 4 CSM shadow
maps from
80 Objects 400 Draw calls 4 Render target
changes
80 Objects 100 Draw calls 1 Render target
change 3x speed increase
D3D9
D3D10/10.1
35Shadows PSSM
36 Shadows PSSM What else ?
- Anti-Jittering we currently do additional simple
4-tap PCF sampling (not good enough). mixing with
variance shadow maps (or even MSAA shadow maps)
would be nicer. - What else needs to be done ? A lot !
- Stabilize jitters
- Better fitting of split frustums to shadow maps
- Peter-Panning, Shadow acne
- More optimization (especially on CPU side)
4-Tap PCF
Peter-Panning
37In Development
- HDR
- 64bit Float format
- Histogram generation. (Median method used in HL2)
- Tonemapping
- Bloom
- Particles
- Deferred particles (smaller buffer, less
fill-rate intensive) - Soft particles
38In Development
- Skinning/Animation
- Hardware accelerated (no actual bone limit in
D3D10) - Havok Animation
- Terrain
39Terrain
- ??? ??? ??? ???? ?? ???? ???? ?
- ???????? ???? ? LOD ????? Geo-MipMap
- ?? ????? ?? ??? ??????? ??? ?? ????? FrostBite
(BFBC, BFBC2) - ???? ????? ?????? ???? ?? ?????? ??????? Shader
Splatting ? ???????? Node Based ????? Terragen2 ?
World Machine?... ??? ?? ???? Real-time ???????
??? ???
40???
- ?????? ????
- ???? ????????
- ??? ?????
- ???????
- ???? ???
- ????? ???? ????
41?????
42??????? ?????
- ????? ????? ????
- http//www.tochalco.com/blog
- ???? ??? ???? ????? ???? ??????? ?????? ?????
????????... (???? ?? ???? ?????) - jobs_at_tochalco.com
43?????