13.07.2015 Views

What is path rendering?

What is path rendering?

What is path rendering?

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Mark KilgardPrincipal System Software EngineerOpenGL driver and API evolutionCg (“C for graphics”) shading languageGPU-accelerated <strong>path</strong> <strong>rendering</strong>OpenGL Utility Toolkit (GLUT) implementerAuthor of OpenGL for the X Window SystemCo-author of Cg Tutorial


GamesBattlefield 3, EA


Data v<strong>is</strong>ualization


Product designCatia


Physics simulationCUDA N-Body


Interactive ray tracingOptiX


Training


Molecular modelingNCSA


Impressive stuff


<strong>What</strong> about advancing 2D graphics?


Can GPUs render & improve the immersive web?


<strong>What</strong> <strong>is</strong> <strong>path</strong> <strong>rendering</strong>?A <strong>rendering</strong> approachResolution-independent two-dimensionalgraphicsOcclusion & transparency depend on <strong>rendering</strong>orderSo called “Painter’s Algorithm”Basic primitive <strong>is</strong> a <strong>path</strong> to be filled or strokedPath <strong>is</strong> a sequence of <strong>path</strong> commandsCommands are– moveto, lineto, curveto, arcto, close<strong>path</strong>,etc.StandardsContent: PostScript, PDF, TrueType fonts,Flash, Scalable Vector Graphics (SVG), HTML5Canvas, Silverlight, Office drawingsAPIs: Apple Quartz 2D, Khronos OpenVG,Microsoft Direct2D, Cairo, Skia, Qt::QPainter,Anti-grain Graphics


Seminal Path Rendering PaperJohn Warnock & Douglas Wyatt, Xerox PARCPresented SIGGRAPH 1982Warnock founded Adobe months laterJohn WarnockAdobe founder


Path Rendering StandardsDocumentPrinting andExchangeResolution-IndependentFontsImmersiveWebExperience2D GraphicsProgrammingInterfacesOfficeProductivityApplicationsOpenTypeFlashJava 2DAPIQtGuiAPITrueTypeScalableVectorGraphicsMac OS X2D APIAdobe IllustratorOpen XMLPaper (XPS)HTML 5Khronos APIInkscapeOpen Source


Live DemoClassic PostScript contentComplex text <strong>rendering</strong>Flash contentYesterday’s New York Times rendered fromits resolution-independent form


Last Year’s SIGGRAPH Results in Real-timeRon Maharik, Mikhail Bessmeltsev,Alla Sheffer, Ariel Shamir andNathan CarrSIGGRAPH 2011, July 2011“Girl with Words in Her Hair” scene591 <strong>path</strong>s338,507 commands1,244,474 coordinates


3D Rendering vs. Path RenderingCharacter<strong>is</strong>tic GPU 3D <strong>rendering</strong> Path <strong>rendering</strong>Dimensionality Projective 3D 2D, typically affinePixel mapping Resolution independent Resolution independentOcclusion Depth buffering Painter’s algorithmRendering primitives Points, lines, triangles PathsPrimitive constituents Vertices Control pointsConstituents per primitive 1, 2, or 3 respectively UnboundedTopology of filled primitives Always convex Can be concave, self-intersecting, and have holesDegree of primitives 1 st order (linear) Up to 3 rd order (cubic)Rendering modes Filled, wire-frame Filling, strokingLine properties Width, stipple pattern Width, dash pattern, capping, join styleColor processing Programmable shading Painting + filter effectsText <strong>rendering</strong> No direct support (2 nd class support) Omni-present (1 st class support)Raster operations Blending Brushes, blend modes, compositingColor model RGB or sRGB RGB, sRGB, CYMK, or grayscaleClipping operations Clip planes, sc<strong>is</strong>soring, stenciling Clipping to an arbitrary clip <strong>path</strong>Coverage determination Per-color sample Sub-color sample


CPU vs. GPU atRendering Tasks over Time100%100%90%90%80%80%70%70%60%60%50%40%GPUCPU50%40%GPUCPU30%30%20%20%10%10%0%1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012Pipelined 3D Interactive Rendering0%1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012Path RenderingGoal of NV_<strong>path</strong>_<strong>rendering</strong> <strong>is</strong> to make <strong>path</strong> <strong>rendering</strong> a GPU taskRender all interactive pixels, whether 3D or 2D or web content with the GPU


<strong>What</strong> <strong>is</strong> NV_<strong>path</strong>_<strong>rendering</strong>?OpenGL extension to GPU-accelerate <strong>path</strong> <strong>rendering</strong>Uses “stencil, then cover” (StC) approachCreate a <strong>path</strong> objectStep 1: “Stencil” the <strong>path</strong> object into the stencil bufferGPU provides fast stenciling of filled or stroked <strong>path</strong>sStep 2: “Cover” the <strong>path</strong> object and stencil test against its coverage stenciled by theprior stepApplication can configure arbitrary shading during the stepMore details laterSupports the union of functionality of all major <strong>path</strong> <strong>rendering</strong> standardsIncludes all stroking embell<strong>is</strong>hmentsIncludes first-class text and font supportAllows functionality to mix with traditional 3D and programmable shading


1100x1100ConfigurationGPU: GeForce 480 GTX (GF100)CPU: Core i7 950 @ 3.07 GHzNV_<strong>path</strong>_<strong>rendering</strong>Compared to AlternativesWith Release 300 driver NV_<strong>path</strong>_<strong>rendering</strong>Alternative APIs <strong>rendering</strong> same content2,000.002,000.001,800.001,600.001,400.001,800.001,600.001,400.001,200.001,000.00800.00600.00CairoQtSkia BitmapSkia Ganesh FBO (16x)Skia Ganesh Aliased (1x)Direct2D GPUDirect2D WARP400.00200.00--100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x1000Frames per second1,200.001,000.00800.00600.0016x8x4x2x1xAlternative approachesare all much slower400.00200.00100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100Frames per secondWindow Resolution in PixelsWindow Resolution in Pixels


Detail on AlternativesSame results, changed Y Ax<strong>is</strong>250.00200.00150.00100.0050.00-100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100CairoQtSkia BitmapSkia Ganesh FBO (16x)Skia Ganesh Aliased (1x)Direct2D GPUDirect2D WARPFrames per secondAlternative APIs <strong>rendering</strong> same content2,000.001,800.001,600.001,400.001,200.001,000.00800.00600.00400.00200.00Window Resolution in Pixels-1 0 0 x 1 0 02 0 0 x 2 0 03 0 0 x 3 0 04 0 0 x 4 0 05 0 0 x 5 0 06 0 0 x 6 0 07 0 0 x 7 0 08 0 0 x 8 0 09 0 0 x 9 0 01 0 0 0 x 1 0 0 0F r a m e s p e r s e c o n d1 1 0 0 x 1 1 0 0ConfigurationGPU: GeForce 480 GTX (GF100)CPU: Core i7 950 @ 3.07 GHzCairoQtSkia BitmapSkia Ganesh FBO (16x)Skia Ganesh Aliased (1x)Direct2D GPUDirect2D WARPWindow Resolution in PixelsFast, but unacceptablequality


100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100Cougartiger_clipped_by_heAcross an range of scenes…Release 300 GeForce GTX 480 Speedups over AlternativestigerWelsh_dragonYokozawaCeltic_round_dogsbutterfly spikesAmerican_Samoacowboy Buonaparte Embrace_the_World 100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x11001000.00NVpr16/CairoNVpr16/SkiaBitmapNVpr16/SkiaGaneshNVpr16/Direct2D GPU100.00NVpr16/Direct2D WARP10.001.000.10Y ax<strong>is</strong> <strong>is</strong> logarithmic—shows how many TIMES faster NV_<strong>path</strong>_<strong>rendering</strong> <strong>is</strong> that competitor


GeForce 650 (Kepler) Results0.101.0010.00100.00100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100100x100200x200300x300400x400500x500600x600700x700800x800900x9001000x10001100x1100TigerWelsh_dragonCeltic_round_dogs butterfly spikes American_Samoa cow boy BuonaparteEmbrace_the_WorldYokozaw aCougartiger_clipped_by_hearNVpr16/CairoNVpr16/SkiaBitmapNVpr16/SkiaGaneshNVpr16/D2DNVpr16/WARP


Tiger Scene on GeForce 650Absolute Frames/Second on GeForce 650Frames per second500.0450.0400.0350.0300.0250.0200.0150.0NVpr “peaks” at1,800 FPS at 100x100NV_<strong>path</strong>_<strong>rendering</strong> (16x)CairoQtSkia BitmapSkia Ganesh FBOSkia Ganesh 1x (aliased)Direct2D GPUDirect2D WARPpoor quality100.050.00.0100x100 200x200 300x300 400x400 500x500 600x600 700x700 800x800 900x900 1000x1000 1100x1100Window resolution


NV_<strong>path</strong>_<strong>rendering</strong> <strong>is</strong> more than justmatching CPU vector graphics3D and vector graphics mixSuperior qualityGPU CPUCompetitors2D in perspective <strong>is</strong> freeArbitrary programmable shader on <strong>path</strong>s—bump mapping


Partial Solutions Not EnoughPath <strong>rendering</strong> has 30 years of heritage and h<strong>is</strong>toryCan’t do a 90% solution and Software to changeTrying to “mix” CPU and GPU methods doesn’t workExpensive to move software—needs to be an unambiguous winMust surpass CPU approaches on all frontsPerformanceQualityFunctionalityConformance to standardsMore power efficientEnable new applicationsJohn WarnockAdobe founderInspiration: Perceptive Pixel


Path Filling and Strokingjust fillingjust strokingfilling + stroke =intended content


Dashing Content ExamplesFrosting on cake <strong>is</strong> dashedelliptical arcs with roundend caps for “beaded” look;flowers are also dashingSame cakem<strong>is</strong>sing dashedstroking detailsArt<strong>is</strong>t made windowswith dashed linesegmentTechnical diagramsand charts often employdashingAll content shown<strong>is</strong> fully GPU renderedDashing character outlines for quilted look


Excellent Geometric Fidelity for StrokingCorrect stroking <strong>is</strong> hardLots of CPU implementationsapproximate strokingGPU-accelerated stroking avoidssuch short-cutsGPU has FLOPS to compute truestroke point containmentGPU-acceleratedCairoOpenVG referenceQtStroking with tight end-point curve


The ApproachStep 1StencilrepeatStep 2:Cover“Stencil, then Cover” (StC)Map the <strong>path</strong> <strong>rendering</strong> task from a sequentialalgorithm……to a pipelined and massively parallel taskBreak <strong>path</strong> <strong>rendering</strong> into two stepsFirst, “stencil” the <strong>path</strong>’s coverage into stencil bufferSecond, conservatively “cover” <strong>path</strong>Test against <strong>path</strong> coverage determined in the 1 st stepShade the <strong>path</strong>And reset the stencil value to render next <strong>path</strong>


Pixel pipelineVertex pipelinePath pipelineApplicationPath specificationPixel assembly(unpack)transformfeedbackVertex assemblyVertex operationsPrimitive assemblyTransform <strong>path</strong>Pixel operationsPrimitive operationsFill/StrokeCoveringPixel packRasterizationreadbackApplicationTexturememoryFragment operationsRaster operationsFill/StrokeStencilingFramebufferD<strong>is</strong>play


Key Operations for RenderingPath ObjectsStencil operationonly updates stencil bufferglStencilFillPathNV, glStencilStrokePathNVCover operationglCoverFillPathNV, glCoverStrokePathNVrenders hull polygons guaranteed to “cover” region updated bycorresponding stencilTwo-step <strong>rendering</strong> paradigmstencil, then cover (StC)Application controls cover stenciling and shading operationsGives application considerable controlNo vertex, tessellation, or geometry shaders active duringstepsWhy? Paths have control points & rasterized regions, not vertices,triangles


Path Rendering Example (2 of 3)InitializationClear the stencil buffer to zero and the color buffer to blackglClearStencil(0);glClearColor(0,0,0,0);glStencilMask(~0);glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);Specify the Path's TransformglMatrixIdentityEXT(GL_PROJECTION);glMatrixOrthoEXT(GL_MODELVIEW, 0,200, 0,200, -1,1); // uses DSA!Nothing really specific to <strong>path</strong> <strong>rendering</strong> hereDSA = OpenGL’s Direct State Access extension (EXT_direct_state_access)


Path Rendering Example (3 of 3)Render star with non-zero fill styleStencil <strong>path</strong>glStencilFillPathNV(<strong>path</strong>Obj, GL_COUNT_UP_NV, 0x1F);Cover <strong>path</strong>glEnable(GL_STENCIL_TEST);glStencilFunc(GL_NOTEQUAL, 0, 0x1F);glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);glColor3f(0,1,0); // greenglCoverFillPathNV(<strong>path</strong>Obj, GL_BOUNDING_BOX_NV);Alternative: for even-odd fill styleJust program glStencilFunc differentlyglStencilFunc(GL_NOTEQUAL, 0, 0x1); // alternative masknon-zero fill styleeven-odd fill style


“Stencil, then Cover”Path Fill StencilingSpecify a <strong>path</strong>Specify arbitrary <strong>path</strong> transformationProjective (4x4) allowedDepth values can be generated fordepth testingSample accessibility determinedAccessibility can be limited by anyor all ofSc<strong>is</strong>sor test, depth test, stenciltest, view frustum, user-definedclip planes, sample mask, stipplepattern, and window ownershipWinding number w.r.t. thetransformed <strong>path</strong> <strong>is</strong> computedAdded to stencil value ofaccessible samplesstencil fill<strong>path</strong> commandper-<strong>path</strong>fill regionoperationsper-sampleoperationsFillstencilingspecific<strong>path</strong>front-endprojectivetransformclipping &sc<strong>is</strong>soringwindow, depth& stencil tests<strong>path</strong> windingnumbercomputationstencilupdate:+, -, or invert<strong>path</strong>objectsampleaccessibilitystencilbuffer


“Stencil, then Cover”Path Fill CoveringSpecify a <strong>path</strong>Specify arbitrary <strong>path</strong>transformationProjective (4x4) allowedDepth values can be generated fordepth testingSample accessibility determinedAccessibility can be limited by anyor all ofSc<strong>is</strong>sor test, depth test, stenciltest, view frustum, user-definedclip planes, sample mask, stipplepattern, and window ownershipConservative covering geometryuses stencil to “cover” filled <strong>path</strong>Determined by prior stencil stepcover fill<strong>path</strong> commandper-<strong>path</strong>fill regionoperationsper-sampleoperationsper-fragment orper-sampleshadingcolorbuffer<strong>path</strong>front-endprojectivetransformclipping &sc<strong>is</strong>soringwindow, depth& stencil testsstencilupdatetypically zeroprogrammable<strong>path</strong>shading<strong>path</strong>objectsampleaccessibilitystencilbuffer


Adding Stroking to the StarAfter the filling, add a stroked “rim”to the star like th<strong>is</strong>…Set some stroking parameters (one-time):glPathParameterfNV(<strong>path</strong>Obj, GL_STROKE_WIDTH_NV, 10.5);glPathParameteriNV(<strong>path</strong>Obj, GL_JOIN_STYLE_NV, GL_ROUND_NV);non-zero fill styleStroke the starStencil <strong>path</strong>glStencilStrokePathNV(<strong>path</strong>Obj, 0x3, 0xF); // stroked samples marked“3”Cover <strong>path</strong>glEnable(GL_STENCIL_TEST);glStencilFunc(GL_EQUAL, 3, 0xF); // update if sample marked “3”glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);glColor3f(1,1,0); // yellowglCoverStrokePathNV(<strong>path</strong>Obj, GL_BOUNDING_BOX_NV);even-odd fill style


“Stencil, then Cover”Path Stroke StencilingSpecify a <strong>path</strong>Specify arbitrary <strong>path</strong> transformationProjective (4x4) allowedDepth values can be generated fordepth testingSample accessibility determinedAccessibility can be limited by anyor all ofSc<strong>is</strong>sor test, depth test, stenciltest, view frustum, user-definedclip planes, sample mask, stipplepattern, and window ownershipPoint containment w.r.t. the stroked<strong>path</strong> <strong>is</strong> determinedReplace stencil value of containedsamplesstencil stroke<strong>path</strong> commandper-<strong>path</strong>fill regionoperationsper-sampleoperationsStrokestencilingspecific<strong>path</strong>front-endprojectivetransformclipping &sc<strong>is</strong>soringwindow, depth& stencil testsstrokepointcontainmentstencilupdate:replace<strong>path</strong>objectsampleaccessibilitystencilbuffer


“Stencil, then Cover”Path Stroke CoveringSpecify a <strong>path</strong>Specify arbitrary <strong>path</strong>transformationProjective (4x4) allowedDepth values can be generated fordepth testingSample accessibility determinedAccessibility can be limited by anyor all ofSc<strong>is</strong>sor test, depth test,stencil test, view frustum,user-defined clip planes,sample mask, stipple pattern,and window ownershipConservative covering geometryuses stencil to “cover” stroked <strong>path</strong>Determined by prior stencil stepcover stroke<strong>path</strong> commandper-<strong>path</strong>fill regionoperationsper-sampleoperationsper-fragment orper-sampleshadingcolorbuffer<strong>path</strong>front-endprojectivetransformclipping &sc<strong>is</strong>soringwindow, depth& stencil testsstencilupdatetypically zeroprogrammable<strong>path</strong>shading<strong>path</strong>objectsampleaccessibilitystencilbuffer


First-class, Resolution-independentFont SupportFonts are a standard, first-class part of all <strong>path</strong> <strong>rendering</strong> systemsForeign to 3D graphics systems such as OpenGL and Direct3D, but natural for<strong>path</strong> <strong>rendering</strong>Because letter forms in fonts have outlines defined with <strong>path</strong>sTrueType, PostScript, and OpenType fonts all use outlines to specify glyphsNV_<strong>path</strong>_<strong>rendering</strong> makes font support easyCan specify a range of <strong>path</strong> objects withA specified fontSequence or range of Unicode character pointsNo requirement for applications use font API to load glyphsYou can also load glyphs “manually” from your own glyph outlinesFunctionality provides OS portability and meets needs of applicationswith mundane font requirements


Handling Common Path RenderingFunctionality: FilteringGPUs are highly efficient at image filteringFast texture mappingMipmappingAn<strong>is</strong>otropic filteringWrap modesCPUs aren't really QtMoiréartifacts GPU Cairo


Handling Uncommon Path RenderingFunctionality: ProjectionProjection “just works”Because GPU does everythingwith perspective-correctinterpolation


Projective Path Rendering Support Compared GPUflawless Skiayes, but bugs Cairounsupported Qtunsupportedcorrectcorrectcorrectwrongunsupportedunsupportedunsupportedunsupported


Path Geometric QueriesglIsPointInFillPathNVdetermine if object-space (x,y) position <strong>is</strong> inside or outside <strong>path</strong>, givena winding number maskglIsPointInStrokePathNVdetermine if object-space (x,y) position <strong>is</strong> inside the stroke of a <strong>path</strong>accounts for dash pattern, joins, and capsglGetPathLengthNVreturns approximation of geometric length of a given sub-range of <strong>path</strong>segmentsglPointAlongPathNVreturns the object-space (x,y) position and 2D tangent vector a givenoffset into a specified <strong>path</strong> objectUseful for “text follows a <strong>path</strong>”Queries are modeled after OpenVG queries


Accessible Samples of a Transformed PathWhen stenciled or covered, a <strong>path</strong> <strong>is</strong> transformed by OpenGL’scurrent modelview-projection matrixAllows for arbitrary 4x4 projective transformMeans (x,y,0,1) object-space coordinate can be transformed to have depthFill or stroke stenciling affects “accessible” samplesA samples <strong>is</strong> not accessible if any of these apply to the sampleclipped by user-defined or view frustum clip planesd<strong>is</strong>carded by the polygon stipple, if enabledd<strong>is</strong>carded by the pixel ownership testd<strong>is</strong>carded by the sc<strong>is</strong>sor test, if enabledd<strong>is</strong>carded by the depth test, if enabledd<strong>is</strong>placed by the polygon offset from glPathStencilDepthOffsetNVd<strong>is</strong>carded by the depth test, if enabledd<strong>is</strong>carded by the (implicitly enabled) stencil testspecified by glPathStencilFuncNVwhere the read mask <strong>is</strong> the bitw<strong>is</strong>e AND of the glPathStencilFuncNV readmask and the bit-inversion of the effective mask parameter of the stencilingoperation


Mixing Depth Buffering andPath RenderingPostScript tigers surrounding Utah teapotPlus overlaid TrueType font <strong>rendering</strong>No textures involved, no multi-pass


Demo


3D Path Rendering DetailsStencil step usesGLfloat slope = -0.05;GLint bias = -1;glPathStencilDepthOffsetNV(slope, bias);glDepthFunc(GL_LESS);glEnable(GL_DEPTH_TEST);Stenciling step usesglPathCoverDepthFuncNV(GL_ALWAYS);ObservationStencil step <strong>is</strong> testing—but not writing—depthStencil won’t be updated if stencil step fails depth test at a sampleCover step <strong>is</strong> writing—but not testing—depthCover step doesn’t need depth test because stencil test would only pass if prior stencilstep’s depth test passedTricky, but neat because minimal mode changes involved


Without glPathStencilDepthOffsetBad Things HappenEach tiger <strong>is</strong> layered 240 <strong>path</strong>sWithout the depth offset during the stencil step, all the—essentially co-planar—layers wouldZ-fight as shown belowterrible z-fighting artifacts


Path Transformation ProcessPathobjectobject-space coordinates(x,y,0,1)color/fog/texcoordinatesObject-spacecolor/fog/texgenerationModelviewmatrixeye-space coordinates(xe,ye,ze,we) + attributescolor/fog/tex coords.Eye-spacecolor/fog/texgenerationUser-definedclip planesclipped eye-space coordinates(xe,ye,ze,we) + attributesProjectionmatrixclip-space coordinates(xc,yc,zc,wc) + attributesView-frustumclip planesclipped clip-spacecoordinates(xc,yc,zc,wc) + attributesto <strong>path</strong>stencilingor covering


Clip Planes Work with Path RenderingScene showing a Welsh dragon clipped to all 64 combinations of 6 clip planesenabled & d<strong>is</strong>abled


Path Rendering Works withSc<strong>is</strong>soring and Stippling tooScene showing a tigersc<strong>is</strong>soring into 9 regionsTiger with two differentpolygon stipple patterns


Rendering Paths Clipped toSome Other Arbitrary PathExample clipping the PostScript tiger to a heart constructed fromtwo cubic Bezier curvesunclipped tigertiger with pink background clipped to heart


Complex Clipping Exampletiger <strong>is</strong> 240 <strong>path</strong>scowboy clip <strong>is</strong>the union of 1,366 <strong>path</strong>sresult of clipping tigerto the union of all the cowboy <strong>path</strong>s


Arbitrary Programmable GPU Shading withPath RenderingDuring the “cover” step, you can do arbitrary fragment processingCould beFixed-function fragment processingOpenGL assembly programsCg shaders compiled to assembly with Cg runtimeOpenGL Shading Language (GLSL) shadersYour pick—they all work!Remember:Your vertex, geometry, & tessellation shaders ignored during cover step(Even your fragment shader <strong>is</strong> ignored during the “stencil” step)


Example of Bump Mapping onPath Rendered TextPhrase “Brick wall!” <strong>is</strong> <strong>path</strong> rendered and bump mapped with a Cgfragment shaderlight source position


Anti-aliasing D<strong>is</strong>cussionGood anti-aliasing <strong>is</strong> a big deal for <strong>path</strong> <strong>rendering</strong>Particularly true for font <strong>rendering</strong> of small point sizesFeatures of glyphs are often on the scale of a pixel or lessNV_<strong>path</strong>_<strong>rendering</strong> uses multiple stencil samples per pixel for reasonableantialiasingOtherw<strong>is</strong>e, image quality <strong>is</strong> poor4 samples/pixel bare minimum8 or 16 samples/pixel <strong>is</strong> pretty sufficientBut 16 requires expensive 2x2 supersampling of 4x mult<strong>is</strong>ampling16x <strong>is</strong> extremely memory intensiveAlternative: quality vs. performance tradeoffFast enough to render multiple passes to improve qualityApproachesAccumulation bufferAlpha accumulation


Anti-aliasing Strategy BenefitsBenefits from GPU’s ex<strong>is</strong>tinghardware AA strategiesMultiple color-stencil-depthsamples per pixel4, 8, or 16 samples per pixelRotated grid sub-positionsFast downsampling by GPUAvoids conflating coverage &opacityMaintains d<strong>is</strong>tinct color sampleper sample locationCentroid samplingFast enough for temporalschemes>>60 fps means multi-passimproves qualityartifactsGPUrenderedcoverage NOTconflated withopacityCairo, Qt, Skia,and Direct2Drenderedshows darkcracks artifactsdue to conflatingcoverage withopacity, noticebackgroundbleeding


RealFlashScenesame scene, GPU-renderedwithout conflationconflationartifacts abound,rendered by Skiaconflation <strong>is</strong> aliasing &edge coverage percentsare un-predicable in general;means conflated pixelsflicker when animated slowly


GPU AdvantagesFast, quality filteringMipmapping of gradient color ramps essentially freeIncludes an<strong>is</strong>otropic filtering (up to 16x)Filtering <strong>is</strong> post-conversion from sRGBFull access to programmable shadingNo fixed palette of solid color / gradient / pattern brushesBump mapping, shadow mapping, etc.—it’s all available to youBlendingSupports native blending in sRGB color spaceBoth colors converted to linear RGBThen result <strong>is</strong> converted stored as sRGBFreely mix 3D and <strong>path</strong> <strong>rendering</strong> in same framebufferPath <strong>rendering</strong> buffer can be depth tested against 3DSo can 3D <strong>rendering</strong> be stenciled against <strong>path</strong> <strong>rendering</strong>Obviously performance <strong>is</strong> MUCH better than CPUs


Improved Color Space:sRGB Path RenderingModern GPUs have native support forperceptually-correct forsRGB framebuffer blendingsRGB texture filteringNo reason to tolerate uncorrected linear RGBcolor artifacts!More intuitive for art<strong>is</strong>ts to controlNegligible expense for GPU to performsRGB-correct <strong>rendering</strong>However quite expensive for software <strong>path</strong>renderers to perform sRGB <strong>rendering</strong>Not done in practiceRadial color gradient examplemoving from saturated red to blue linear RGBtransition between saturatedred and saturated blue hasdark purple region sRGBperceptually smoothtransition from saturatedred to saturated blue


Trying Out NV_<strong>path</strong>_<strong>rendering</strong>Operating system support2000, XP, V<strong>is</strong>ta, Windows 7, Linux, FreeBSD, and Solar<strong>is</strong>Unfortunately no Mac supportGPU supportGeForce 8 and up (Tesla and beyond)Most efficient on Fermi and Kepler GPUsCurrent performance can be expected to improveShipping since NVIDIA’s Release 275 driversAvailable since summer 2011New Release 300 drivers have remarkable NV_<strong>path</strong>_<strong>rendering</strong> performanceTry it, you’ll like it


Learning NV_<strong>path</strong>_<strong>rendering</strong>White paper + source code available“Getting Started with NV_<strong>path</strong>_<strong>rendering</strong>”ExplainsPath specification“Stencil, then Cover” API usageInstanced <strong>rendering</strong> for text and glyphs


NV_<strong>path</strong>_<strong>rendering</strong> SDK ExamplesA set of NV_<strong>path</strong>_<strong>rendering</strong> examples of varying levels of complexityMost involved example <strong>is</strong> an accelerated SVG viewerNot a complete SVG implementationCompiles on Windows and LinuxStandard makefiles for LinuxUse V<strong>is</strong>ual Studio 2008 for Windows


Whitepapers“Getting Started with NV_<strong>path</strong>_<strong>rendering</strong>”


Whitepapers“Mixing 3D and Path Rendering”


SDK Example Walkthrough (1)pr_basic—simplest exampleof <strong>path</strong> filling & strokingpr_hello_world—kerned, underlined,stroked, and linear gradient filled textpr_welsh_dragon—filled layerspr_gradient—<strong>path</strong> with holes with texture applied


SDK Example Walkthrough (2)pr_font_file—loading glyphs from a font filewith the GL_FONT_FILE_NV targetpr_korean—<strong>rendering</strong> UTF-8 string of Koreacharacterspr_shaders—use Cg shadersto bump map text withbrick-wall texture


SDK Example Walkthrough (3)pr_text_wheel—render projected gradienttext as spokes of a wheelpr_tiger—classic PostScript tiger renderedas filled & stroked <strong>path</strong> layerspr_warp_tiger—warp the tigerwith a free projective transformclick & drag the bounding rectanglecorners to change the projection


SDK Example Walkthrough (4)pr_tiger3d—multiple projected and depth testedtigers + 3D teapot + overlaid textpr_svg—GPU-accelerated SVG viewerpr_pick—test points to determine if theyare in the filled and/or stroked region of acomplex <strong>path</strong>


ConclusionsGPU-acceleration of 2D resolution-independent graphics <strong>is</strong> comingHTML 5 and low-power requirementsare demanding it“Stencil, then Cover” approachVery fastQuality, functionality, and featuresAvailable today through NV_<strong>path</strong>_<strong>rendering</strong>Shipping todayNV_<strong>path</strong>_<strong>rendering</strong> resources available


Questions?


More InformationBest drivers: OpenGL 4.3 beta driverwww.nvidia.com/driversGrab the latest Beta drivers for your OS & GPUDeveloper resourceshttp://developer.nvidia.com/nv-<strong>path</strong>-<strong>rendering</strong>Whitepapers, FAQ, specificationNVprSDK—software development kitNVprDEMOs—pre-compiled Windows demosOpenGL Extension Wrangler (GLEW) has API supportEmail: nvpr-support@nvidia.com


Don’t Forget the 20 th Anniversary PartyDate: August 8th 2012 ( today! )Location: JW Marriott Los Angeles at LA LiveVenue: Gold Ballroom – Salon 1


Other OpenGL-relatedNVIDIA Sessions at SIGGRAPHGPU Ray Tracing and OptiXWednesday in West Hall 503, 3:50 PM - 4:50 PMDavid McAll<strong>is</strong>ter, OptiX Manager, NVIDIAPhillip Miller, Director, Workstation Software Product Management, NVIDIAVoxel Cone Tracing & Sparse Voxel Octree for Real-time Global IlluminationWednesday in NVIDIA Booth, 3:50 PM - 4:50 PMCyril Crassin, Postdoctoral Research Scient<strong>is</strong>t, NVIDIA ResearchOpenSubdiv: High Performance GPU Subdiv<strong>is</strong>ion Surface DrawingThursday in NVIDIA Booth, 10:00 AM - 10:30 AMPixar Animation Studios GPU Team, PixarnvFX : A New Scene & Material Effect Framework for OpenGL and DirectXThursday in NVIDIA Booth, 2:00 PM - 2:30 PMTr<strong>is</strong>tan Lorach, Developer Relations Senior Engineer, NVIDIA

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!