Procedural Shaders: A Feature Animation...
Transcript of Procedural Shaders: A Feature Animation...
![Page 1: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/1.jpg)
1
Procedural Shaders: A Feature Animation Perspective
Hector Yee, Rendering Specialist, PDI/DreamWorks
David Hart, Senior FX Developer, PDI/DreamWorks
Arcot Preetham, Engineer, ATI Research
Motivation
• Movies stil l look better
• Up visual bar with programmable graphics hardware
• Borrow techniques from Feature Animation for use in Real Time
![Page 2: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/2.jpg)
2
Motivation – get from here
Jak 2
(2003)
PS 2Naughty Dog
… to here
Shrek 4D
(2003)
F i lmPDI/
DreamWorks
![Page 3: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/3.jpg)
3
Talk Outline
• Technological similarities & differences
• Techniques from feature animation
• Techniques from real-time rendering
Where we are
• Typical values for Shrek
– Typical frame
– Pentium 4 @ 2.8 GHz
• Typical values for DX 9 part
– Assuming 30 FPS
– Based on Radeon 9800
– Some values based on theoretical max
![Page 4: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/4.jpg)
4
“Typical” Shrek frame
Similarities
32 (internal float)
8 (RGB 8:8:8)
32 (internal float)
4-8 (YUV 4:2:2)
Bits per channel
4 x 48 x 8Anti- Al iasing
640 x 480
1024 x 768
1280 x 1024
720 x 486 (NTSC)
1828 x 1102 (Academy 1.66)
Resolution
Realtime
Rendering
Feature AnimationTechnology
![Page 5: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/5.jpg)
5
Differences (Geometry)
132
4 mat/bone
350
CPU proc.
Bones & Skinning
20.1M - 1M100 MPolys / frame
60.015 secs8000 secsTime per frame
Order of Magnitude
Realtime
Rendering
Feature
Animation
Technology
Geometric Resolution
• Feature Animation
– Mostly procedural geometry
– NURBS, NUBS or subdivision surfaces
• Realtime
– Usually triangles and quads
– Recently N-patches or RT-patches
![Page 6: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/6.jpg)
6
Differences (Rendering)
31 (depth map)
1000 (soft shadows)
Shadow samples
25 - 10100Number of Lights
60.015 secs7000 secsTime per frame
Order of Magnitude
Realtime
Rendering
Feature
Animation
Technology
Differences (Shading)
Shader network for Shrek’s body
![Page 7: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/7.jpg)
7
Differences (Shading)
1.564 MB1545 MBTexture R A M
2~10~100 (chained)
Shader Parameters
41001 MShader ops per pixel
Order of Magnitude
Realtime
Rendering
Feature
Animation
Technology
Other Differences
• Texture Filtering
– Analytic vs Trilinear Mipmap (Dave)
• Shader Environment
– P, dPdUV, N vs streams (Dave)
• Shading Language
– C/C++ vs Cg/HLSL/GLSL ( Preetham)
• Color Cal ibration
![Page 8: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/8.jpg)
8
Color Calibration
• Consistent view for
– Artists, content provider, consumers
• Feature Animation
– Artists calibrate, Theatres calibrate
• Realtime Rendering
– Artists calibrate (sometimes)
– Gamers turn up the gamma!
Shader Environment
By shader I mean pluginCompiled .dso (.dll) written in C
Materials, maps, lights, geometry, etc..
Shaders are (ideally) stream filters / DG nodesLook at inputs and outputs only
But we (PDI) always cheatTraversing scene, loading files, ray tracing, etc..
Full access to all app. libraries
![Page 9: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/9.jpg)
9
Shader Environment
P, N, Ng, UV, dPd[UV], ref[PN], etc...
These data come in both singles & tuples
Singles = data at the poly center
Tuples = data at poly vertices(e.g. vertex normals, vertex UVs, etc...)
Polygon
Texture
![Page 10: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/10.jpg)
10
Ant i-aliasing
N o-one wants aliasing, but in reality…
Hardware support
Performancefeatures / quality / speed
no aliasing allowed (noise is not OK)
Fortunately, we (FA) have lots of time
Image mapping for RT
Input UV is a single
Tr i- l i near MIPMAP interpolation
MIPMAP i s po in t -sampled using single (face) UV
![Page 11: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/11.jpg)
11
Image mapping for F A
Input UV is tuple
Integrate filtered
texels in tuple
Quality knob chooses MIPMAP level(e .g . GL_TEXTURE_LOD_BIAS_EXT in openGL)
Brick Shader
Use uv tuple polygon
Find fully & partly
enclosed bricks
Fully enclosed =
average color
Partly enclosed =
clip & evaluate
![Page 12: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/12.jpg)
12
Brick Shader
Env mapping
Function maps (I,N) to UV
Using reflection vector R
Builds on Image mapping
Tuple UVs computed with tuple N & P
UV tuple is passed on to image map
![Page 13: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/13.jpg)
13
Env mapping
Tuple UVs might cross seams, so subdivide tuple UV po lygon
Each tuple polygon is evaluated by image map shader.
Env mapping
Singles
eval
Tuples
eval
![Page 14: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/14.jpg)
14
Env mapping
Procedural noise
We use noise heavilyMany different types
gradient, cell, convolution,
turbulence, marble, worley
1d,2d,3d,4d…
Fractal noise anti-aliasingEvaluate frequency in ‘octaves’
Only evaluate the frequencies
that are below Nyquist limit
![Page 15: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/15.jpg)
15
Shading Models
Wide range of complex modelsDefault material has standard terms:
Ambient, Diffuse, Specular
And some non-standard terms:Shadowing, Directional ambient, Directional diffuse,
Retro-reflection, Fresnel reflectivity, transparency…
Not just surface materials:Maps, Fabric, Fur, Particles, Volumes,
Fur Shader
Shading model for curves [Kajiya ’89]
![Page 16: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/16.jpg)
16
Shrek 4D
Shrek 4D
![Page 17: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/17.jpg)
17
Shrek 4D
Shrek 4D
![Page 18: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/18.jpg)
18
Shrek 4D
Shrek 4D
![Page 19: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/19.jpg)
19
Shrek 4D
Shrek 4D
![Page 20: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/20.jpg)
20
Shrek 4D
Shading Languages
• RenderMan®
• C Libraries
• HLSL, GLSL, Cg.
• Assembly.
C P U GPU
![Page 21: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/21.jpg)
21
Shading Blocks
• On CPU
– Light, Surface, Volume shaders.
• On GPU
– Vertex & Pixel shaders.
Shading on graphics hardware
• Instruction set
– Limited Control Flow
– No Bitwise operators
• Resources
– Limited Registers (Temp, Interpolators, Constants)
• No Global Memory
![Page 22: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/22.jpg)
22
Shading on graphics hardware (cont’d)
• Finite number of instructions
PS Shader Model vs Instructions
1
10
100
1000
10000
100000
PS 1.1 PS 1.2,1.3 PS 1.4 PS 2.0 PS 2.X PS 3.0
Inst
ruct
ion
Slo
ts
Multipassing
• Interactive multi-pass programmable shading, Siggraph2000 - Peercy et al
• Efficient partitioning of fragment shaders for multi-pass rendering on programmable graphics hardware,Siggraph 2002 – Chan et al.
Chan et al, 2002.
Peercy et al, 2000.
![Page 23: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/23.jpg)
23
CPU vs GPU Shading
CPU
GPU
Quality
Speed
Shading
CPU Quality & GPU speed
• Use GPU for offl ine shaders.
– Procedural Lights.
– Complex Surfaces.
– Noise.
![Page 24: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/24.jpg)
24
Lights
• Fixed Function
– 8 lights
– Dir, Point, Spot
• Programmable
– Any number of lights
– Custom light shaders
– Eg. Windowlight
Windowlight
• Light through a window.
• Parameters:
– # horiz panes, vert panes
– from, to, up
– frame width & height
– fuzz.
![Page 25: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/25.jpg)
25
Surface Models
• Fixed Function
– Diffuse, Phone, Multi -texture
• Programmable
– Custom surface models.
– Eg. OrenNayar, Anisotropic, Fur.
Fur
• Fur geometry rendered as triangles.
• Shading uses fur tangent direction
![Page 26: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/26.jpg)
26
Noise
• Widely used in studios.
• GLSL & HLSL shading languages have noise functions.
• Popular implementation
– Perlin noise
• Eg: Ocean waves
Texture Noise
• Noise based demos used textures.
• Advantages: Fast.
• Disadvantages: Repeat, memory expensive, linear filtering
![Page 27: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/27.jpg)
27
Procedural Noise
• Advantages: No filtering artifacts.
• Disadvantages: Computationally expensive.
• Perlin noise implementation on GPU.
– float noise3d(): 56 alu, 16 tex.
– float3 noise3d(): 172 alu, 48 tex.
Conclusion
Cinematic quality in real time ?
Still a long way to go.
![Page 28: Procedural Shaders: A Feature Animation Perspectivetwvideo01.ubm-us.net/o1/vault/gdc04/slides/procedural_shaders.pdf · 4 mat/bone 350 CPU proc. Bones & Skinning Polys / frame 100](https://reader035.fdocuments.net/reader035/viewer/2022071213/6028cfecdd37aa1388536b75/html5/thumbnails/28.jpg)
28
Acknowledgements
PDI: Jonathan Gibbs, Jerry Hebert, Harry Max, Paul Rademacher, Dan Yu, Taylor Shaw, Andy Hendrickson, Rachel Falk, lighting, char TDs, FX, R&D
ATI: Avi Bleiweiss, Dominik Behr, Seth Sowerby, Pierre Boudier, Axel Mamode, Mike Huber, Raja Koduri.