procedural shaders: a feature animation...
TRANSCRIPT
![Page 1: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/1.jpg)
Procedural Shaders: A Feature Animation Perspective
Hector Yee, Rendering Specialist, PDI/DreamWorksDavid Hart, Senior FX Developer, PDI/DreamWorksArcot J. Preetham, Senior Engineer, ATI Research
![Page 2: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/2.jpg)
Motivation
• Movies still look better• Up visual bar with programmable
graphics hardware• Borrow techniques from Feature
Animation for use in Real Time
![Page 3: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/3.jpg)
Motivation – get from hereJak 2 (2003)PS 2Naughty Dog
![Page 4: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/4.jpg)
… to hereShrek 4D(2003)FilmPDI/DreamWorks
![Page 5: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/5.jpg)
Talk Outline
• Technological similarities & differences
• Techniques from feature animation
• Techniques from real-time rendering
![Page 6: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/6.jpg)
Technological Aspects
• Outline of pipelines• ‘Typical’ scenes and values• Similarities• Differences
– Pipeline, Geometry, Rendering, Shading– Other
![Page 7: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/7.jpg)
Programmable Pipeline
• Vertex operations– Shade & transform vertices– Interpolate vertex data
• Pixel operations– Shade pixels– Discard (Alpha, Z, stencil, clip)– Output fragment color– Frame buffer blends
![Page 8: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/8.jpg)
Feature Animation Pipeline• Generate geometry
• Tessellate, displace, dice
• Discard (visibility)
• Shade micro-polygon
• Filter micro-polygons
• Frame buffer operations
![Page 9: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/9.jpg)
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 10: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/10.jpg)
“Typical” Shrek frame
![Page 11: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/11.jpg)
Shrek 4D
![Page 12: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/12.jpg)
Similarities
32 (internal float)8 (RGB 8:8:8)
32 (internal float)4-8 (YUV 4:2:2)
Bits per channel
640 x 4801024 x 7681280 x 1024
720 x 486 (NTSC)1828 x 1102 (Academy 1.66)
Resolution
RealtimeRendering
Feature AnimationTechnology
![Page 13: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/13.jpg)
Differences (Pipeline)
Interpolate vertex shading
Constant shaded micro-polygons
ShadingInterpolation
Z-test after vertex shading
Z-test before shading
Visibility
~25~0.1 (!)Pixels per Polygon
RealtimeRendering
FeatureAnimation
Technology
![Page 14: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/14.jpg)
Differences (Geometry)
1324 mat/bone
350CPU proc.
Bones & Skinning
20.1M - 1M100 MPolys / frame
60.015 secs8000 secsTime per frame
Order of Magnitude
RealtimeRendering
FeatureAnimation
Technology
![Page 15: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/15.jpg)
Geometric Resolution
• Feature Animation– Mostly procedural geometry– NURBS, NUBS or subdivision surfaces
• Realtime– Usually triangles and quads– Recently N-patches or RT-patches
![Page 16: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/16.jpg)
Differences (Rendering)
~1 - 21 – 16 r. grid64 QMCAnti-aliasing
31 (depth map)
1000 (soft shadows)
Shadow samples ppix
25 - 10100Number of Lights
60.015 secs7000 secsTime per frame
Order of Magnitude
RealtimeRendering
FeatureAnimation
Technology
![Page 17: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/17.jpg)
Differences (Shading)
Shader network for Shrek’s body
![Page 18: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/18.jpg)
Differences (Shading)
1.564 MB1545 MBTexture RAM
1~10~100Shader Parameters
41001 MShader ops per pixel
Order of Magnitude
RealtimeRendering
FeatureAnimation
Technology
![Page 19: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/19.jpg)
Other Differences
• Texture Filtering– Analytic vs Trilinear Mipmap (Dave)
• Shader Environment– P, dPdUV, N vs streams (Dave)
• Shading Language– C/C++ vs HLSL/GLSL (Preetham)
• Color Calibration
![Page 20: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/20.jpg)
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!
![Page 21: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/21.jpg)
Shader Environment
By shader I mean pluginCompiled .dso (.dll) written in CMaterials, 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 22: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/22.jpg)
Shader Environment
P, N, Ng, UV, dPd[UV], ref[PN], etc...
These data come in both singles & tuplesSingles = data at the poly centerTuples = data at poly vertices
(e.g. vertex normals, vertex UVs, etc...)
![Page 23: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/23.jpg)
Polygon
Texture
![Page 24: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/24.jpg)
Anti-aliasing
No-one wants aliasing, but in reality…Hardware supportPerformance
features / quality / speed
No aliasing allowed (noise is not OK)Fortunately, we (FA) have lots of time
![Page 25: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/25.jpg)
Image mapping for RT
Input UV is a single
Tri-linear MIPMAP interpolation
MIPMAP is point-sampled using single (face) UV
![Page 26: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/26.jpg)
Image mapping for FA
Input UV is tuple
Integrate filteredtexels in tuple
Quality knob chooses MIPMAP level(e.g. GL_TEXTURE_LOD_BIAS_EXT in openGL)
![Page 27: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/27.jpg)
Brick Shader
Use uv tuple polygonFind fully & partly
enclosed bricksFully enclosed =
average color Partly enclosed =
clip & evaluate
![Page 28: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/28.jpg)
Brick Shader
![Page 29: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/29.jpg)
Env mapping
Function maps (I,N) to UVUsing reflection vector R
Builds on Image mappingTuple UVs computed with
tuple N & PUV tuple is passed on to
image map
![Page 30: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/30.jpg)
Env mapping
Tuple UVs might cross seams, so subdivide tuple UV polygon
Each tuple polygon is evaluated by image map shader.
![Page 31: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/31.jpg)
Env mapping
Singleseval
Tupleseval
![Page 32: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/32.jpg)
Env mapping
![Page 33: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/33.jpg)
Procedural noise
We use noise heavilyMany different types
gradient, cell, convolution, turbulence, marble, worley1d,2d,3d,4d…
Fractal noise anti-aliasingEvaluate frequency in ‘octaves’Only evaluate the frequencies that are below Nyquist limit
![Page 34: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/34.jpg)
Shading Models
Wide range of complex modelsDefault material has standard terms:
Ambient, Diffuse, SpecularAnd some non-standard terms:
Shadowing, Directional ambient, Directional diffuse, Retro-reflection, Fresnel reflectivity, transparency…
Not just surface materials:Maps, Fabric, Fur, Particles, Volumes,
![Page 35: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/35.jpg)
Fur Shader
Shading model for curves [Kajiya ’89]
![Page 36: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/36.jpg)
Shrek 4D
![Page 37: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/37.jpg)
Shrek 4D
![Page 38: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/38.jpg)
Shrek 4D
![Page 39: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/39.jpg)
Shrek 4D
![Page 40: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/40.jpg)
Shrek 4D
![Page 41: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/41.jpg)
Shrek 4D
![Page 42: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/42.jpg)
Shrek 4D
![Page 43: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/43.jpg)
Shading Languages
• Movies– RenderMan ® Shading Language– C/C++ Libraries
• Games– Assembly Language– HLSL, GLSL
![Page 44: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/44.jpg)
Shading Blocks
• Offline Shaders– Light, Surface, Volume, Displacement
shaders.
• Real-time Shaders– Vertex & Pixel shaders.
![Page 45: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/45.jpg)
Shading on Graphics Hardware
• Instruction set– Limited Control Flow– No Bitwise operators
• Resources– Limited Registers (Temps, Interpolators,
Constants)
![Page 46: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/46.jpg)
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
![Page 47: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/47.jpg)
Multipassing
• Interactive multi-pass programmable shading, Siggraph 2000 - 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 48: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/48.jpg)
Offline vs Real-time Shading
• Goals are completely different.– Movies: Quality.– Games: Speed.
![Page 49: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/49.jpg)
Noise
• Widely used in movies.• Popular implementation
– Perlin noise
• GLSL & HLSL shading languages have noise functions.
![Page 50: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/50.jpg)
Procedural Noise
• Disadvantages: Computationally expensive.
• Advantages: Smooth function. • Perlin noise implementation on GPU.
– float noise(vector ) - 56 alu, 16 tex.– color noise(vector ) - 172 alu, 48 tex.
![Page 51: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/51.jpg)
Texture Noise
• Real time demos use textures for noise.• Advantages: Fast.• Disadvantages: Repeat, memory
expensive, linear filtering.
![Page 52: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/52.jpg)
Worley Noise
A Cellular Texture Basis Function, Siggraph1996 - Steven Worley.
Jitterfeaturepoints
Findnearestfeaturepoint
![Page 53: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/53.jpg)
Worley Noise (cont’d)void voronoi_f1f2(point P; float jitter;
output float f1; output point pos1; output float f2; output point pos2; )
{
point thiscell = point (floor(xcomp(P))+0.5,floor(ycomp(P))+0.5,floor(zcomp(P))+0.5);
f1 = f2 = 1000;
float i, j;
for (i = -1; i <= 1; i += 1) {
for (j = -1; j <= 1; j += 1) {
point testcell = thiscell + vector(i,j,0);
point pos = testcell + jitter(P) * (vector cellnoise (testcell) - 0.5);
vector offset = pos - P;
float dist = offset . offset; /* actually dist^2 */
if (dist < f1) {
f2 = f1; pos2 = pos1;
f1 = dist; pos1 = pos;
} else if (dist < f2) {
f2 = dist; pos2 = pos;
}
}
}
f1 = sqrt(f1); f2 = sqrt(f2);
}
pos1
f1
f2 pos2
P
![Page 54: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/54.jpg)
Worley Shader (cont’d)
surface Foo()
{
float f1, f2;
point pos1, pos2;
point T = point(s, t, 0);
voronoi_f1f2(T, 0.5, f1, pos1, f2, pos2); Ci = color cellnoise(pos1);
}
- Translates to ~150 pixel shader instructions.
![Page 55: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/55.jpg)
Worley Shader (cont’d)
surface Foo()
{
float f1, f2;
point pos1, pos2;
point T = point(s, t, 0);
voronoi_f1f2(T, 0.5, f1, pos1, f2, pos2); Ci = color(f1);
}
- Translates to ~135 pixel shader instructions.
![Page 56: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/56.jpg)
Worley Shader (cont’d)
surface Foo()
{
float f1, f2;
point pos1, pos2;
point T = point(s, t, 0);
voronoi_f1f2(T, 0.5, f1, pos1, f2, pos2); Ci = color(step(0.1, f2-f1));
}
- Translates to ~190 pixel shader instructions.
![Page 57: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/57.jpg)
Worley Noise Demo
![Page 58: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/58.jpg)
Fur
Screen shot from movie “Shrek”
![Page 59: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/59.jpg)
Fur Geometry• Vertex data
– position, tangent, radius, tex coordinate, base position.
• Parameters - width & length scale.
![Page 60: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/60.jpg)
Fur Shading
Kajiya’s lighting model(Siggraph 1989)
Shadowing
Indirect Lighting
Translucency
Feature animation shader
Real time shader
User Interface
![Page 61: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/61.jpg)
Fur Real-Time Shadervoid main(){
// Incident direction.vec3 I = Inc;
/* Hair direction */vec3 hair_direction = normalize(Nor);
/* Accumulate color */vec4 C = vec4(0, 0, 0, 0);
/* ambient */C = mat_ambient;
/* Texture coordinate along hair */float t = UV;
/* combine all attributes to final colors */vec4 diffuse, specular, ddcolor;interpolate_colors(t, diffuse, specular, ddcolor);
vec3 light_hair_direction = hair_dire ction;
vec3 L = lightdir1;vec4 Cl = lightcolor1 * intensity1;
vec3 dir_factor = compute_directional_factor(light_hair_direction, L, I);
C += compute_diffuse(light_hair_direction, L, Cl, 1.0, dir_factor, diffuse);
C += compute_specular(light_hair_direction, L, Cl, I, 1.0, dir_factor, specular, ddcolor);
gl_FragColor = C;}
vec4compute_specular(vec3 hair_direction, vec3 L, vec4 Cl, vec3 I, float factor, vec3 dir_factor, vec4 specular, vec4 ddcolor){ float tmp, hd_dot_h, sin_hd_h; int show_dd. show_sp; vec3 h;
/* half vector */ h = normalize(L + I); hd_dot_h = dot(h, hair_direction); sin_hd_h = 1.0 - (hd_dot_h * hd_dot_h);
vec4 color = vec4(0, 0, 0, 0); if (mat_show_dd) { /* directional diffuse */ tmp = pow(sin_hd_h, mat_ddshininess) * factor; color += ddcolor * Cl * tmp * dir_factor; } if (mat_show_specular) { /* specular */ tmp = pow(sin_hd_h, mat_shininess) * factor; color += specular* Cl * tmp * dir_factor; } return color;}
vec4compute_diffuse(vec3 hair_direction, vec3 L, vec4 Cl, float factor, vec3 dir_factor, vec4 diffuse){ float tmp, hd_dot_l, sin_hd_l; vec4 result = vec4(0, 0, 0, 0); if (mat_show_diffuse > 0) { hd_dot_l = dot(hair_direc tion, L); tmp = 1.0 - hd_dot_l * hd_dot_l; sin_hd_l = (tmp < 0) ? 0 : sqrt(tmp); tmp = factor * sin_hd_l; result = diffuse * Cl * tmp * dir_factor; } return result;}
vec3compute_directional_factor(vec3 hair_direction, vec3 L, vec3 I){ float kappa; vec3 hd_cross_l; vec3 hd_cross_i; float front_factor, back_factor; hd_cross_l = cross(hair_direction, L); hd_cross_i = cross(hair_direction, I); kappa = dot(hd_cross_l, hd_cross_i) / (length(hd_cross_l) *
length(hd_cross_i)); front_factor = (1 + kappa) / 2; back_factor = (1 - kappa) / 2; vec3 dir_factor = front_factor * mat_reflect + back_factor * mat_transmit; return dir_factor;}
voidinterpolate_colors(float t, out vec4 diffuse, out vec4 specular,
out vec4 ddcolor){ /* diffuse */ vec4 tmp = mix(mat_diffuse_surf_base, mat_diffuse_surf_tip, t); diffuse = mat_diffuse_hair * mat_diffuse_col * tmp;
/* specular */ tmp = mix(mat_specular_surf_base, mat_specular_surf_tip, t); specular = mat_specular_hair * mat_specular_col * tmp;
/* directional diffuse */ ddcolor = mix(diffuse, specular, mat_ddcolor); ddcolor *= mat_ddamount;}
// vertex to fragment shader iovarying vec3 Inc;varying vec3 Nor;varying float UV;
// material.uniform vec4 mat_ambient;uniform vec4 mat_reflect;uniform vec4 mat_transmit;
uniform vec4 mat_diffuse_hair;uniform vec4 mat_diffuse_col;uniform vec4 mat_diffuse_surf_base;uniform vec4 mat_diffuse_surf_tip;uniform float mat_show_diffuse;
uniform vec4 mat_specular_hair;uniform vec4 mat_specular_col;uniform vec4 mat_specular_surf_base;uniform vec4 mat_specular_surf_tip;uniform float mat_show_specular;
uniform float mat_show_dd;uniform float mat_ddamount;uniform float mat_ddcolor;uniform float mat_shininess;uniform float mat_ddshininess;
// lights.uniform vec4 lightcolor1;uniform float intensity1;uniform vec3 lightdir1;
![Page 62: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/62.jpg)
Fur Demo
![Page 63: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/63.jpg)
Conclusion
Cinematic quality in real time ?
Still a long way to go.
![Page 64: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/64.jpg)
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, Derek Whiteman, Pierre Boudier, Axel Mamode, Raja Koduri.
![Page 65: Procedural Shaders: A Feature Animation Perspectivedeveloper.amd.com/wordpress/media/2012/10/GDC04_Yee_Hart_Pre… · – Pentium 4 @ 2.8 GHz • Typical values for DX 9 part –](https://reader033.vdocuments.us/reader033/viewer/2022052012/6028d2571384e03f7e601d11/html5/thumbnails/65.jpg)
Questions?
hyee @ pdi.com
dahart @ pdi.com
preetham @ ati.com