Real-Time Hair Reede Gondering On The GPU - Nvidia

Transcription

Real-Time HairRenderinge de g onothe GPUSarah TariqNVIDIA

Motivation AcademiaA d i andd theh moviei iindustrydhhave bbeensimulating and rendering impressive andrealistic hair for a long time We have demonstrated realistic real timeresults [Nalu, 2003] GPU iis powerfulf l andd programmablebl enoughhto do all simulation/rendering

Results 166 simulated strands 0.99 Million triangles Stationary: 64 fps Moving:g 41 fpsp 8800GTX, 1920x1200, 8XMSAA

Results 166 simulatedi l t d strandst d 2.1Million triangles 24fps 8800GTX, 1280x1024 8xMSAA 2xSSAA with 5 taps

InI thishi talklk I willill cover onlyl hhairi renderingd i Real Time Hair Simulation and Rendering onthe GPUSession: Lets get physicalThursday Room 502B. 1:45-3:30

Import Guide HairSimulate GuideHairTessellate andInterpolate GuideHairRender Final Hair

Tessellation andI tInterpolationl ti

TessellationSimulated VerticesSmoothly Tessellated Hair

Tessellation WeW use B-SplinesB S li– Uniform cubic b-splines Pre-compute and storepartial results– Automatically handlecontinuity– Do not interpolateendpoints So we repeat end pointsx (t ) 1[P06P1P2 1 3 3 3 6 0P3 ] 3 3 3 00 11 t 3 4 t 2 1 t 0 1

InterpolationMulti Strand InterpolationClump Based Interpolation

Interpolation ClumpClBBasedd IInterpolationtl ti– Each interpolated strand is defined by 2D offset that is added to the guide strand in the direction of itscoordinate frame. Pre-computed and stored in constants ClumpClradiusdi whichhi h changeshalongltheh llengthh off theh guideidstrand Multi Strand Interpolation– Each strand is defined by 3D weights which we use tocombine the 3 guide strands

InterpolationMulti strand InterpolationClump Based InterpolationCombination

InterpolationMulti strand InterpolationClump Based InterpolationCombination

Modulate density across scalp Red: Local density of hair For example in this demo– Multi strand based hair has higherdensity near the center of the headMulti StrandInterpolationClump Based

Process CreateC t a ttessellatedll t d ddummy hhairi andd renderd it Ntimes, where N is the number of final hairs In the VS,, load from Buffers storingg simulatedstrand attributes– Constant attributes: strand texcoordstexcoords, lengthlength, width etc– Variable attributes: vertex positions, coordinate frames

Process StreamStoutt theth datad t afterft eachh stagettot minimizei i ire-computation– Tessellate the simulated strands and Stream out– Interpolate the tessellated strands and Stream out– Render final hair to shadow map– Render final hair for rendering Each stage uses data computed and streamedout from previous stage

Final HairNNNNBBIndirectionBuffer

Using Dx11esse at oTessellationEngine

Tessellation Pipelinet3D11 extendst d Dit3D10 withith DiDirect3D11Direct3D10support for programmable tessellationInput AssemblerVertex ShaderHull Shader Two new shader stages:– Hull Shader (HS)– Domain Shader (DS) One fixed function stage:– Tessellator (TS)TSDomain ShaderGeometry ShaderSetup/Raster

ISO Lines OutputOfromftheh tessellationll i enginei willill bbe aset lines of equal number of segments We can either render these directly Or we can expand these to triangles in theGS

ISO Lines InputIt an arbitrarybitpatcht h For each patch output a number of lines withgpper linemanyy segments– The number of lines output per patch and the numbergpper line are user controlled and can beof segmentsdifferent per patch– The ppositions of the vertices of the line segmentsgareshader evaluated

Interpolating and Tessellating hair WithWi h TTessellationll i enginei we can createtessellated and interpolated hair on the fly Benefits:– Easy and intuitive– More programmable Can create geometry only where needed Reduce detail where not needed– Continuous LOD

topologyCalculatevertexattributesExpandlines toquadsShadeTessellated, Interpolated,Rendered HairPatch of SimulatedGuide Hair

Clump Based Hair Tessellationand sInput Patch(sub set of guide hair)HullLine Density Line DetailTSDomainLineiDetaililLine DensitySingle Pass on GPU

Alternative PipelineSimulated Guide alculatevertexattributesSOGSPSTessellated Guide HairExpandlines toquadsShade

LOD CanC use ththe didistancetoff patcht h ffrom camera totdecide on the LOD– Low LOD levels would use less number of lines thicker lines less segments per line less complex shading

LOD LOD can bbe procedurald l– For LOD 0.5 render only 50% of lines in a given patch LOD can also be artist defined– Artists can create density/width maps for different LOD ofNearthe hairstyle– The Hull Shader can lerp between appropriate LODtextures to decide on the line density, and line thicknessFar

Renderinge de g

Rendering LinesLihhave iissues:– No floating point line width– No textures across line These are useful for simulating the look of many hair RenderingR d i hhairi withith complexl colorl variationsi ti Render camera facing triangle strips– Can either expand lines to strips in the GS– Or can render instanced triangle strips

Shading: Kajiya and Kay Kajiya and Kay [Rendering[R d i furf withith threethdimensionaldiil ttexturest(SIGGRAPH ’89)] Diffuse sin(Tsin(T,L)L) sqrt(1 – T . L2)Specular [T . L * T . E sin(T,L) sin(T,E)] p [T . L * T . E sqrt(1 – T . L2) sqrt(1 – T . E2)] p Ivan 2006 fake dual specular highlights– primary highlight shifted towards tip– secondarydhihighlighthli ht shiftedhift d ttowardsd roott

Tangents NeedN d tto hhave smoothth ttangentst– Calculate tessellated andinterpolated tangents Add jitter to tangents in order tobreak strong highlights– Randomly a per strand constantbias to tangents towards or awayfrom root– Add per pixel noise to tangentsx (t ) [T0 T12 0.5 1 0.5 t T2 ] 1 1 0.5 t 0 1 0.5 0

Shadows MaterialM t i lMModel:d l OOpaque hhairi Essential Requirements– No flickering, smooth shadows– Soft Shadows Do PCF with multiple taps1 tap– tShadowMap.SampleCmpLevelZero(ShadowSampler, texcoord,td z, int2(dx,i t2(d ddy));))– Helps reduce temporal/spatial aliasing– CalculateC l l t shadowsh dini VS andd interpolatei tl t across hhairilength to further reduce aliasing36 taps

Shadows MaterialMi lMModel:d l TTranslucentlHHairi If hair is semi-transparent then weneedd volumetriclt i shadowsh dOpacity Shadow maps– [Yuksel and Keyser 08], [Kim andNeuman 01], [ Lokovic and Veach 01]– discritize the space into layersDeep Shadow Maps[Images courtesy of Yuksel 08]

Shadows WeW dod absorptionbi weightedi h d PCF– Similar to [Halen 06]– Weigh the PCF sample by1 - exp(g SigmaAp(g g* d))No absorption weighting d is the difference between the depth of thecurrent shaded point and the closest point tothe lightWith absorption weighting

Antialiasing HumanHhhairi iis very thithin Typically alpha blending is used to hidealiasingli i– Requires sorting geometry which is timeNo Alpha Blendingconsuming– Can use depth peeling [Everitt 01], [Bavoiland Myers 07] Scalable: can decide to render only the first 4 depthlayers for example– Or [Sintorn and Assarsson 08]With Alpha Blending[Sintorn and Assarsson 08]

Antialiasing CanC alsol use AlAlphah TTo CCoverage– Does not require sorting– Does require MSAA– Need depth pre-pass to get earlyZ We use a combination of MSAAand SSAA– 8xMSAA8 MSAA– 2xSSAA with 5 taps

Add random deviations to hair PreP bakeb k andd storetddeviationsi tiwhichhi hare added to interpolation offsetsalong the length of the hair– Most hair deviate towards the tips– Some very deviant and thin hair Other– Taper hair width towards the hair tip– Randomize width per-hair strand

Thanka youyou!

Motivation Ad i dh iid h bAcademia and the movie industry have been simulating and rendering impressive and realistic hair for a long time We have demonstrated realistic real timeWe have demonstrated realistic real time results [Nalu, 2003] GPU i f l d bl hGPU is powerful and programmab