Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rendering hair with graphics hardware Tae-Yong Kim Rhythm & Hues Studios

Similar presentations


Presentation on theme: "Rendering hair with graphics hardware Tae-Yong Kim Rhythm & Hues Studios"— Presentation transcript:

1 Rendering hair with graphics hardware Tae-Yong Kim Rhythm & Hues Studios tae@rhythm.com

2 Overview State of the Art in Hair Rendering and Modeling Issues in Hardware Hair Rendering Line drawing with Graphics Hardware Illumination and Hardware Shader Shadows

3 Hair representation Hair is not a single entity – always consider hair volume a a whole Surface (polygons, nurbs, etc.) Line (guide hair, curve, polyline..) Volumetric representation (implicit surface, 3D texture, tubes, …)

4 Representation - Polygons ATI2004 - Polygonal Model ( from SIGGRAPH Sketch by Thorsten Scheuermann) Real-time rendering Suited for existing artists asset Limited hairstyle Animation difficult

5 Representation - Lines nVidia – Line representation (from Matthias Wloka’s Eurographics 2004 tutorial) Dynamic hair No restriction in hairstyle Advanced rendering possible No standard modeling technique Can be time consuming to render

6 Model Generation Use control tools to generate bunch of hairs Control curves (guide hairs) Cylinders – single level/multi level Fluid flow, 3D vector field Automated methods emerging

7 Guide hair Small number of guide hairs control hair shape Interpolation generates whole instances of hairs to render Properties like density, length can be controlled with maps

8 Other guide objects (fluid) Create vector fields (e.g. with fluid dynamics) hairs through 3D vector filed Each hair is instanced through fluid control Hadap and Nadia M. Thalmann Eurographics 2001

9 Other guide objects (cylinders) Cylinders to shape hair Instance hairs inside each tube Multi-layered control of cylinders Kim and Neumann SIGGRAPH 2002

10 Emerging techniques Hair modeling from photographs Directly recover hair geometry from images S. Paris, H. Briceno, F. Sillion SIGGRAPH 2004

11 Hair as line drawing 100-150k hair per human scalp >100 lines per each hair > millions of lines (micro polygons) typical in production hair render Use of graphics hardware

12 Hair segment as a GL line DrawHairLine(p s, p e, c s, c e ) { glBegin(GL_LINES) glColor3fv(c s ); glVertex3fv(p s ); glColor3fv(c e ); glVertex3fv(p e ); glEnd() }

13 Hair as GL lines DrawHair(p 0,p 1,..,p n-1,c 0,c 1,….c n-1 ) { glBegin(GL_LINE_STRIP) glColor3fv(c 0 ); glVertex3fv(p 0 ); glColor3fv(c 1 ); glVertex3fv(p 1 ); … glColor3fv(c n-1 ); glVertex(p n-1 ); glEnd() }

14 Are we done? DrawHair(p 0,p 1,..,p n-1,c 0,c 1,….c n-1 ) { glBegin(GL_LINE_STRIP) glColor3fv(c 0 ); glVertex3fv(p 0 ); glColor3fv(c 1 ); glVertex3fv(p 1 ); … glColor3fv(c n-1 ); glVertex(p n-1 ); glEnd() } Algorithm1 For each hair, call this function!

15 Not quite..

16 Point samples Computed sample color True sample The aliasing problem

17 Compare this..

18 Remedies  Increase sampling rate ( large image size, accumulation buffer)  Image quality depends on number of samples at a slow convergence rate  Required sampling rate is above 10,000 x 10,000 pixel resolution  Thinner (smaller) hairs require even higher sampling rate

19 Remedies  Hardware antialiasing of line drawing  GL_LINE_SMOOTH  Thickness control with alpha blending

20  =0.09 0.25 0.60 1.0 Thickness control with alpha blending

21 Correct Visibility order is important correct wrong

22 Hair as visibility ordered lines Algorithm 2 1. Compute color for each end point of the lines (shading, shadowing) 2. Compute the visibility order 3. Draw lines sorted by the visibility order

23 r o k a d b c e g f v s u p t q m h i j l n k,l,m d,e c f,g,h i,j n,o,p,q r,s,t u,v b a A simple visibility ordering scheme Drawing order: a, b, c, d, e, f, g, h, I, j, k, l, m, n, o, p, q, r, s, t, u, v

24 A simple visibility ordering scheme  Efficient (700K lines per second on 700Mhz CPU)  Approximate, but works well for small line fragments

25 CorrectCached Coherence of visibility ordering  Visibility ordering can be cached and reused (useful for interactive application)

26 Hair shading model  Describes the amount of reflected/scattered light toward the viewing direction  Kajiya-Kay (1989)  Marschner et al. (2003)

27 L V T Kajiya-Kay model

28 L V T H

29 Example cg program

30

31

32 Real-time hair shading Hair as set of unstructured lines Sort visibility of hair lines line render with vertex shader

33 Shadow2Color2Tangent2Pos2 Shadow1Color1Tangent1Pos1 Data structure  Position: comes from modeling, animation  Tangent : computed from position  (Unshadowed) Color: shaded with either CPU/ or Vertex Shader  Shadow: computed with opacity shadow maps  Sort each line with visibility order

34 .. ShadowNColorN Tangent N PosNN.. Shadow4Color4Tangent4Pos44 Shadow3Color3Tangent3Pos33 Shadow2Color2Tangent2Pos22 1 Index Shadow1Color1Tangent1Pos1 ShadowColorTangentPos Vertex table N-1.. 4 3 2 1 V1 NM.. 54 43 32 21 V2Index Line table Data structure

35  A shading model describes the amount of reflected light when hair is fully lit  Most hair receives attenuated light due to self-shadowing  Crucial for depicting volumetric structure for hair Self-shadows

36 No shadows With shadows Self-shadows

37 Front lighting Back lighting Self-shadows

38  Shadow is a fractional visibility function  How many hairs between me and the light?  What percentage of light is blocked? Self-shadows

39  Shadow is a fractional visibility function Self-shadows

40 Opacity shadow maps [Kim and Neumann EGRW 2001] Fast approximation of the deep shadowing function Idea: use graphics hardware as much as possible

41 Ω(l) l Transmittance Opacity Monotonically increasing Self-shadows

42 Opacity Shadow Maps

43 Opacity Shadow Maps - Algorithm for (1  i  N) Determine the opacity map’s depth D i from the light for each shadow sample point p j in P (1  j  M) Find i such that D i-1  Depth(p j ) < D i Add the point p j to P i. Clear the alpha buffer and the opacity maps B prev, B current. for (1  i  N) Swap B prev and B current. Render the scene clipping it with D i-1 and D i. Read back the alpha buffer to B current. for each shadow sample point p k in P i Ω prev = sample(B prev, p k ) Ω current = sample(B current, p k ) Ω = interpolate (Depth(p k ), D i-1, D i, Ω prev, Ω current ) τ(p k ) = e -κΩ Φ(p k ) = 1.0 - τ(p k )

44 Uniform slicing1D BSPNonlinear spacing How many opacity maps?

45 Opacity Shadow Maps - Algorithm for (1  i  N) Determine the opacity map’s depth D i from the light for each shadow sample point p j in P (1  j  M) Find i such that D i-1  Depth(p j ) < D i Add the point p j to P i. Clear the alpha buffer and the opacity maps B prev, B current. for (1  i  N) Swap B prev and B current. Render the scene clipping it with D i-1 and D i. Read back the alpha buffer to B current. for each shadow sample point p k in P i Ω prev = sample(B prev, p k ) Ω current = sample(B current, p k ) Ω = interpolate (Depth(p k ), D i-1, D i, Ω prev, Ω current ) τ(p k ) = e -κΩ Φ(p k ) = 1.0 - τ(p k )

46  Storing all the opacity maps incur high memory usage  Sort shadow computation points based on the map’s depth P0P0 PiPi P N- 1  As soon as the current map is rendered, compute shadows for corresponding sample points. Preparing Shadow Samples

47 Opacity Shadow Maps - Algorithm for (1  i  N) Determine the opacity map’s depth D i from the light for each shadow sample point p j in P (1  j  M) Find i such that D i-1  Depth(p j ) < D i Add the point p j to P i. Clear the alpha buffer and the opacity maps B prev, B current. for (1  i  N) Swap B prev and B current. Render the scene clipping it with D i-1 and D i. Read back the alpha buffer to B current. for each shadow sample point p k in P i Ω prev = sample(B prev, p k ) Ω current = sample(B current, p k ) Ω = interpolate (Depth(p k ), D i-1, D i, Ω prev, Ω current ) τ(p k ) = e -κΩ Φ(p k ) = 1.0 - τ(p k )

48  The alpha buffer is accumulated each time the scene is drawn.  The scene is clipped with D i and D i-1  Speedup factor of 1.5 to 2.0  In very complex scenes, preorder the scene geometry so that the scene object is rendered only for a small number of maps.  More speedup and reduce memory requirement for scene graph Clipping and Culling

49 Opacity Shadow Maps - Algorithm for (1  i  N) Determine the opacity map’s depth D i from the light for each shadow sample point p j in P (1  j  M) Find i such that D i-1  Depth(p j ) < D i Add the point p j to P i. Clear the alpha buffer and the opacity maps B prev, B current. for (1  i  N) Swap B prev and B current. Render the scene clipping it with D i-1 and D i. Read back the alpha buffer to B current. for each shadow sample point p k in P i Ω prev = sample(B prev, p k ) Ω current = sample(B current, p k ) Ω = interpolate (Depth(p k ), D i-1, D i, Ω prev, Ω current ) τ(p k ) = e -κΩ Φ(p k ) = 1.0 - τ(p k )

50 Opacity Shadow Maps

51 Opacity Shadow Maps - Algorithm for (1  i  N) Determine the opacity map’s depth D i from the light for each shadow sample point p j in P (1  j  M) Find i such that D i-1  Depth(p j ) < D i Add the point p j to P i. Clear the alpha buffer and the opacity maps B prev, B current. for (1  i  N) Swap B prev and B current. Render the scene clipping it with D i-1 and D i. Read back the alpha buffer to B current. for each shadow sample point p k in P i Ω prev = sample(B prev, p k ) Ω current = sample(B current, p k ) Ω = interpolate (Depth(p k ), D i-1, D i, Ω prev, Ω current ) τ(p k ) = e -κΩ Φ(p k ) = 1.0 - τ(p k )

52 1.0 Quantization in alpha buffer limits Ω to be 1.0 at maximum κ scales the exponential function s. t. Ω value of 1.0 represents a complete opaqueness (τ = 0) κ = 5.56 for 8 bit alpha buffer (e -κ = 2 -8 ) Exponential Attenuation

53 N = 7(5secs) N = 15(7secs) N = 30(10secs) N = 60(16secs) N = 100(25secs) N = 200(46secs) N = 500(109secs) No shadow Opacity Shadow Maps

54 Hair rendering with lines in graphics hardware  Setup pass:  Compute the visibility order  Compute shadow values  Drawing pass:  For each line segment L i ordered due to the visibility order  Set thickness (alpha value)  Draw L i with programmable shader

55 Opacity Shadow Maps – Recent Extensions Whole opacity maps stored in 3D texture nVidia’s demo Koster et al., Real-Time Rendering of Human Hair using Programmable Graphics Hardware, CGI 2004 Mertens et al, A Self-Shadow Algorithm for Dynamic Hair using Density Clustering, EGSR 2004

56 Hair rendering with lines in graphics hardware Antialiasing Shading through vertex/fragment shader Shadows with opacity maps

57 Questions


Download ppt "Rendering hair with graphics hardware Tae-Yong Kim Rhythm & Hues Studios"

Similar presentations


Ads by Google