Programming With NV Path Rendering: N Annex To The .

3y ago
716.11 KB
7 Pages
Last View : 24d ago
Last Download : 6m ago
Upload by : Jewel Payne

Programming with NV path rendering:An Annex to the SIGGRAPH paper GPU-accelerated Path RenderingMark J. KilgardNVIDIA Corporation AbstractFor example, PostScript [Adobe Systems 1985] provides threecommands (arc, arcn, and arct) for specifying circular arcsegments. While standards developed after PostScript sought togeneralize circular arc segments to an elliptical form, our interface supports circular arc commands to match PostScript’s parameterization. So rather than require an application to convert suchPostScript circular paths into some alternate form, the circular arccommands are handled with semantics exactly matching PostScript.Likewise, OpenVG [Khronos Group 2008] has a four elliptical arcsegment commands, each expecting five coordinate values; whereasSVG has a single elliptical arc segment command with five continuous coordinate values and two Boolean coordinates.This annex provides a practical overview of the OpenGL-based programming interface described in our SIGGRAPH Asia 2012 paperGPU-accelerated Path Rendering.Keywords: NV path rendering, path rendering, vector graphics,OpenGL, stencil buffer1IntroductionOur SIGGRAPH Asia paper GPU-accelerated Path Rendering[Kilgard and Bolz 2012] describes a system for accelerating vector graphics on GPUs. NVIDIA has implemented the systemand has been shipping the functionality for its GeForce andQuadro GPUs since the summer of 2011. We refer the reader tothat paper for the motivation and technical underpinning of theNV path rendering [Kilgard 2012] OpenGL extension. In particular, that paper explains our “Stencil, then Cover” (StC) approachto filling and stenciling paths.For line segments, the general line segment command takes an(x, y) control point—but horizontal and vertical line segments takea single horizontal or vertical coordinate respectively.For Bézier curve segments, commands exist for smooth Bézier segments, matching up with the prior command’s segment to provideC1 continuity.Where appropriate, we provide relative and absolute versions of allpath commands. With relative commands, path coordinates indicating a position are relative to the end point of the prior path segment.In this annex to the forementioned paper we explain the programming interface in more detail. The intended audience forthis annex is developers evaluating and learning to programNV path rendering. You should be familiar with the OpenGL[Segal and Akeley 2012] programming interface. Familiarity withpath rendering standards such as PostScript or SVG is helpful.In addition to eliminating the semantic gap between other path standards and our interface, we note that paths can be represented withfewer path coordinates when the variety of available path commands is broad. Also, editing of the sequence of path commandsand coordinates is straightforward when each standard’s path command vocabulary is supported directly. Table 1 organizes the supported path commands.Figure 1 shows how our new path pipeline co-exists with the existing pipelines in OpenGL for pixel and vertex processing. Yourapplication can mix traditional OpenGL usage with path rendering.Path objects are specified in four ways:2Path Object Specification1. Explicitly, from a sequence of path commands and their corresponding path coordinates.Before an application can render paths, it must create a path object corresponding to each path. A path object is a container forthe sequence of path commands and corresponding coordinatesfor the path. Additionally, each path object maintains per-objectparameters (see Section 3) and the “baked” GPU-resident stateneeded to stencil and cover the path object. Like other types ofobjects in OpenGL, path objects are named by 32-bit unsigned integers. Names of path objects can be generated, tested for existence,and deleted respectively with glGenPathsNV, glIsPathNV,and glDeletePathsNV commands—matching the mechanismOpenGL uses for texture, buffer, and display list objects.2.12. From a string conforming to a standard grammar for specifying a paths. Both PostScript and SVG have standard grammars for paths—and we support both.3. From a Unicode character point of an outline font. A font canbe specified with a system name (such as Helvetica or Arial),an outline font filename, or a built-in font.4. Derived from one or more existing path objects. The newpath may be the result of an arbitrary projective transform ofan existing path, or the linear weighting of exiting paths withmatching command sequences.Path Segment Commands2.2The path commands supported by NV path rendering are theunion of path commands from all major path rendering standards.We designed NV path rendering to be a low-level interfaceupon which all major path rendering standards can be hosted. Eliminating any semantic friction between the path commands of various standards and our interface is important to us. e-mail:Explicit Path SpecificationThe commandvoid glPathCommandsNV(GLuint path,GLsizei numCmds,const GLubyte *cmds,GLsizei numCoords,GLenum coordType,const void *coords);mjk@nvidia.com1

Path elativeversionNumber of tScriptallMOVE TO NVLINE TO NVHORIZONTAL LINE NVVERTICAL LINE NVQUADRATIC CURVE TO NVCUBIC CURVE TO NVSMOOTH QUADRATIC CURVE TO NVSMOOTH CUBIC CURVE TO NVSMALL CCW ARC TO NVSMALL CW ARC TO NVLARGE CCW ARC TO NVLARGE CW ARC TO NVARC TO NVCIRCULAR CCW ARC TO NVCIRCULAR CW ARC TO NVCIRCULAR TANGENT ARC TO NVRECT NVDUP FIRST CUBIC CURVE TO NVDUP LAST CUBIC CURVE TO NVRESTART PATH NVCLOSE PATH NVTable 1: Path commands supported by NV path rendering. The character alias column provides an ASCII alias for the absolute/relativeversion of token. The “all” for origin means the path command is common to all path rendering standards.The following code fragment creates path object 42 containing thecontours of a five-point star and heart:static const GLubyte pathCommands[10] { GL MOVE TO NV, GL LINE TO NV,GL LINE TO NV, GL LINE TO NV,GL LINE TO NV, GL CLOSE PATH NV,’M’, ’C’, ’C’, ’Z’ }; // character aliasesstatic const GLshort pathCoords[12][2] { {100,180}, {40,10}, {190,120}, {10,120}, {160,10},{300,300}, {100,400}, {100,200}, {300,100},{500,200}, {500,400}, {300,300} };GLuint pathObj 42;glPathCommandsNV(pathObj, 10, pathCommands,24, GL SHORT, pathCoords);The example demonstrates how tokens or character aliases can beused interchangeably to specify a path.2.3Figure 1: High-level data flow of OpenGL showing pixel, vertex,and new path pipelines.Grammars for Path SpecificationThe commandglPathStringNV(GLuint path, GLenum format,GLsizei length, const void *pathString);specifies a new path object named path where numCmds indicates the number of path commands, read from the array commands, with which to initialize that path’s command sequence.These path commands reference coordinates read sequentially fromthe coords array. The type of the coordinates read from thecoords array is determined by the coordType parameter whichmust be one of GL BYTE, GL UNSIGNED BYTE, GL SHORT,GL UNSIGNED SHORT, or GL FLOAT. Coordinates supplied inmore compact data types allows paths to be stored more efficiently.specifies a new path object named path where format must beeither GL PATH FORMAT SVG NV or GL PATH FORMAT PS NV,in which case the length and pathString are interpreted respectively according to SVG’s grammar1 for paths or PostScript’s subgrammar for user paths. This code fragment is functionally identical to the prior explicit path specification example but uses an SVGpath string:const char *svgPathString // star"M100,180 L40,10 L190,120 L10,120 L160,10 z"// heart"M300 300 "The numCmds elements of the cmds array must be tokens (or character aliases) from Table 1. The command sequence matches the element order of the cmds array. Each command references a numberof coordinates specified by the “Number of scalar coordinates” column of Table 1, starting with the first (zero) element of the coordsarray and advancing by the coordinate count for each command.1 The Backus-Naur Form (BNF) description of the SVG path grammar is found here

"C100 400,100 200,300 100,500 200,500 400,300 300Z";glPathStringNV(pathObj, GL PATH FORMAT SVG NV,(GLsizei)strlen(svgPathString), svgPathString);GLuint pathTemplate 0; // Biggest path nameglPathCommandsNV(pathTemplate,0, NULL, 0, GL FLOAT, NULL);glPathParameterfNV(pathTemplate,GL PATH STROKE WIDTH NV, emScale*0.1f);glPathParameteriNV(pathTemplate,GL PATH JOIN STYLE NV, GL MITER TRUNCATE NV);glPathParameterfNV(pathTemplate,GL PATH MITER LIMIT NV, 1.0);// Create path object range for Latin-1 character codesGLuint glyphBase glGenPathsNV(numChars);// Typeface names in priority orderstruct {GLenum fontTarget;const char *name;} font[] {{ GL SYSTEM FONT NAME NV,"Liberation Sans" },{ GL SYSTEM FONT NAME NV,"Verdana" },{ GL SYSTEM FONT NAME NV,"Arial" },// Final standard font provides guaranteed supported{ GL STANDARD FONT NAME NV, "Sans" }};const int numFonts sizeof(font)/sizeof(font[0]);for (int i 0; i numFonts; i ) { // For each t, font[i].name, GL BOLD BIT NV,0, numChars, GL USE MISSING GLYPH NV,pathTemplate, emScale);}Creating paths from strings has proven very convenient and avoidshaving each application re-implement standard path grammarparsers.2.4Specifying Paths from Glyphs of a FontText rendering is a first-class feature in every major path rendering API and standard. Requiring applications to load outlines ofglyphs is just too common, not to mention arduous and platformdependent, so NV path rendering provides a mechanism forapplications to create path objects from glyphs—including contiguous ranges of glyphs indexed by their Unicode character NV create a sequence of path objects givena font and a range or sequence of Unicode character points for thefont. The font can be specified using a system font name (suchas “Arial” or “Helvetica” with a file name for a file in a standardfont file format such as TrueType, or a built-in font name (suchas “Sans,” “Serif,” or “Mono”) that is guaranteed to be availableon every NV path rendering implementation, regardless ofplatform.Once these path objects are populated, these glyph path objects canbe stenciled and covered, whether filled or stroked, just like anyother path object.Path objects loaded from glyphs also have associated glyph andfont metrics loaded corresponding to their character point. Thesemetrics and spacing information are discussed in Section 5.The glPathGlyphRangeNV and glPathGlyphsNV commands will only create a path object for a given path name if thatpath object name does not already correspond to an existing pathobject. This behavior is designed to populate path object rangeswith glyph outlines consistent with the font-family propertyof CSS 2.1 [CSS Working Group 2011]. An application can load asequence of fonts for a given range of path objects repeatedly knowing this will resolve to some supported set of font glyphs eventually.2.5Additional commands for specifying path objects work by generating a new path object from one or more existing path objects. TheglCopyPathNV command is the simplest and simply copies thestate of a named existing path object to another path object name.Path parameters and glyph metrics are copied by glCopyPathNV.The glPathGlyphRangeNV command has the following prototype:The glInterpolatePathsNV command takes two (source)path object names and a weighting factor and creates anew (destination) path object that is the linear interpolation based on the weighting factor of the two sourcepaths.The glWeightPathsNV command generalizes theglInterpolatePathsNV to linear combination of a specifiednumber of source path objects and corresponding weighting factors. All the path objects involved in interpolating or weightingmust have identical path command sequences and contain no circular or elliptical arc segment commands. The destination path object’s parameters are copied from the first destination path object;glyph metrics are all set invalid (to -1).void glPathGlyphRangeNV(GLuint firstPathName,GLenum fontTarget,GLconst void *fontName,GLbitfield fontStyle,GLuint firstGlyph,GLsizei numGlyphs,GLenum handleMissingGlyphs,GLuint pathParameterTemplate,GLfloat emScale);The emScale parameter allows fonts of different formats to beloaded with a consistent number of path units per em (a typographicmeasure of glyph scale). Path coordinates and glyph metrics arescaled to match the specified emScale. To ensure all path objects ina range of glyphs have a consistent set of path parameters, the pathParameterTemplate path object names a path object from which thenew glyph path objects should copy their parameters.The glTransformPathNV command take a source path objectname and generates a new named destination path object corresponding to the destination path object transformed by an affine linear transform. Path commands such as horizontal or vertical linesor circular arcs may be promoted to a more general path commandform as required to perform the transformation. Relative commandsare converted to absolute commands, transformed, and then converted back to relative commands.This example shows how a range of path objects for sans serif fontsfor the Latin-1 character range can be populated:// Constantsconst GLint numChars 256;////const GLfloat emScale 2048; ////Copied, Weighted, and Transformed PathsIf the destination path object name refers to an existing path object,that path object is replaced (implicitly deleting the old object) withthe new path object. The destination name may be one of the sourcenames.ISO/IEC 8859-18-bit rangeTrueType pathunits per emAssuming the implementation performs a lazy copy of pathcommands and coordinates, glCopyPathNV allows effi-// Create empty path object for use as parameter template3

cient rendering of a path with different stroking parameters.glInterpolatePathsNV can help implement Flash’s ShapeMorph functionality and OpenVG’s vgInterpolatePathcommand.glTransformPathNV can help implementSVG 1.2’s non-scaling stroke functionality and OpenVG’svgTransformPath.3Path ParametersEvery path object has state in addition to its sequence of path commands and coordinates.3.1Figure 2: Glyph metrics.Settable ,glPathParameterivNV, and glPathParameterfvNVcommands respectively set path parameters of a specified pathobject given integer or float data supplied by a scalar parameter orvector array.and glGetPathParameterfvNV, the dashing array withglGetPathDashArrayNV, the path command array withglGetPathCommandsNV, and path coordinate array withglGetPathCoordsNV. Additionally, computed parameters foreach path object can be queried; see Table 3.Table 2 summarizes the settable parameters. Many parameters dealwith embellishments to stroking such as the stroke width, join style,miter limit, end caps, and dash TROKE WIDTH NVJOIN STYLE NVMITER LIMIT NVINITIAL END CAP NVTERMINAL END CAP NVINITIAL DASH CAP NVTERMINAL DASH CAP NVDASH OFFSET NVDASH OFFSET RESET NVCLIENT LENGTH NVFILL MODE NVFILL MASK NVFILL COVER MODE NVSTROKE COVER MODE NVSTROKE MASK NVNameTypeInitial value 4-valued 4-valued4-valued4-valued4-valued 2-valued 4-valuedmask3-valued3-valuedmask1.0GL MITER REVERT NV4GL FLATGL FLATGL FLATGL FLAT0.0GL MOVE TO CONTINUES NV0.0GL COUNT UP NVall 1’sGL CONVEX HULL NVGL CONVEX HULL NVall 1’sTable 2: Settable path object parameters.3.2Dashing ND COUNT NVCOORD COUNT NVCOMPUTED LENGTH NVOBJECT BOUNDING BOX NVFILL BOUNDING BOX NVSTROKE BOUNDING BOX NVNN 4 4 4 Table 3: Computed path object parameters.3.4Glyph and Font MetricsPath objects created from character points from a font are taggedwith additional read-only glyph metrics. These metrics are useful for text layout. Additionally, every glyph has aggregate per-fontmetrics for its corresponding font. The metrics are obtained directlyfrom the font except for any scaling based on the emScale. TheglGetPathMetricRangeNV and glGetPathMetricsNVqueries return the glyph and per-font metrics for a range or sequence of path objects respectively.As shown in Figure 2, the glyph metrics provide each glyph’s widthand height and (x, y) bearing and advance for both horizontal andvertical layout. These metrics are expressed in path space units.Dashing is an embellishment to stroking where a repeated patternof enabled stroking and gaps in stroking is applied during stroking.The conventional glPathParameteriNV, etc. commands areill-suited to setting a variable number of dash offsets.Additional per-font metrics can be queried from any glyph belonging to a particular font. These metrics include a bounding box largeenough to contain any glyph in the font, the native number of fontunits per em, the font-wide ascender, descender, and height distances, maximum advance for horizontal and vertical layout, underline position and thickness.Instead parameters to control the dash pattern of a stroked path arespecified by the commandvoid glPathDashArrayNV(GLuint path,GLsizei dashCount,const GLfloat *dashArray);Requested metrics are specified in a bitmask and returned to anapplication-provided array of floats.where path is the name of an existing path object. A dashCountof zero indicates the path object is not dashed; in this case, thedashArray is not accessed. Otherwise, dashCount provides a countof how many float values to read from the dashArray array.43.3The mapping from path space to clip space and ultimately window space is determined by OpenGL’s standard modelview, projection, viewport, and depth range transforms. An OpenGL programmer familiar with OpenGL’s glMatrixMode, glRotatef,Rendering Paths via Stencil, then CoverOnce a path object is created, it can be rendered with the “stencil,then cover” approach.Computed Parameters and Querying StateAll settable path object state is able to be queried; this includes settable parameters with glGetPathParameterivNV4

glTranslatef, etc. matrix commands for transforming 3D geometry uses the same commands to manipulate the transformationsof path objects.For example, the code below establishes an orthographic path-toclip-space to map the [0.500] [0.400] region used by the starand-heart path:glMatrixLoadIdentityEXT(GL PROJECTION);glMatrixLoadIdentityEXT(GL MODELVIEW);glMatrixOrthoEXT(GL MODELVIEW, 0, 500, 0, 400, -1, 1);This code demonstrates OpenGL’s selector-free matrix manipulation commands introduced by the EXT direct state access(DSA) extension [Kilgard 2009].4.1Path Rendering in Two StepsNow we can render the filled and stroked star-and-heart path. Weassume the stencil buffer has been initially cleared to zero.Figure 3: Filled and stroked path rendering result.First we stencil the filled regionof the star-and-heart path into the stencil buffer with theglStencilFillPathNV command:Stencil Step for FillingThis computes the point containment of every sample in the framebuffer w.r.t. the stroked path—and if the sample is contained in thepath’s stroke, the sample’s stencil value is set to 0x1 with a writemask of bit-inverted zero (writing all stencil bits).glStencilFillPathNV(pathObj, GL COUNT UP NV, 0x1F);The winding number of each sample in the framebuffer w.r.t. thetransformed path is added (GL COUNT UP) to the stencil value corresponding to each rasterized same. The 0x1F mask indicates thatonly the five least significant stencil bits are modified—effectivelyresulting in modulo-32 addition. More typically, this mask will be0xFF.Second we conservatively cover theprevious

GPU-accelerated Path Rendering. Keywords: NV path rendering, path rendering, vector graphics, OpenGL, stencil buffer 1 Introduction Our SIGGRAPH Asia paper GPU-accelerated Path Rendering [Kilgard and Bolz 2012] describes a system for accelerating ve

Related Documents:

this drawing is owned and/or licensed by chief architect, inc. and is solely for demonstrative . as-built rendering for illustration only remodel rendering for illustration only kitchen rendering for illustration only living room rendering for illustration only. 6050 4050 6050 7 0 1 9 5 3 1 9 2 1 0 5 0 3 0 6 8 4060 4060 4050 3068 3068 up e1 .

redraws per second. If the 3D graphics are rendered and displayed fast enough so that the user can interact with them, then it is called real time. 2.1 Software Rendering vs. Hardware Accelerated Rendering There are two main ways to render 3D graphics: Software rendering † Hardware accelerated rendering 2.1.1 Software Rendering

So, what is better with strand-based rendering? Strand based rendering, where hair fibers are modelled as individual strands, or curves, is the current state of the art when rendering hair offline. And it can look something like this image generated using Arnold. Modelling hair as strands has a lot of benefits for physics and rendering since it .

Rendering Techniques in 3D AutoCAD , Part 1 4 Rendering Basics Rendering can be a very time-consuming aspect of a project. Because of the subtleties involved, you can spend a lot of time adjusting camera positions, lighting, and materials. In the past, you might spend more time creating a rendering than you spent actually building the 3D model.

makes it possible to seamlessly mix conventional 3D GPU rendering with GPU-accelerated path rendering. The image below from the nvpr_tiger3d example shows how a 3D wire-frame teapot can be mixed with path rendered content. The “stencil, then cover” approach of NV_path_rendering makes the mixin

DAC DAC ADC ADC. X19532-062819. Figur e 2: RF-ADC Tile Structure. mX0_axis Data Path ADC VinX0 mX1_axis Data Path ADC VinX1 mX2_axisData Path ADC VinX2 mX3_axis Data Path ADCVinX3 mX3_axis mX1_axis ADC mX0_axis Data Path ADC Data Path ADC VinX_23 VinX_01 Data Path Data Path Dual RF-ADC Tile Quad RF-ADC Tile. X23275-100919. Chapter 2: Overview

GPU-accelerated path rendering OpenGL Utility Toolkit (GLUT) implementer Author of OpenGL for the X Window System Co-author of Cg Tutorial. GPUs are good at a lot of stuff. . Warnock founded Adobe months later John Warnock Adobe founder. Path Rendering Standards Document Printing and Exch

This section contains a list of skills that the students will be working on while reading and completing the tasks. Targeted vocabulary words have been identified. There are links to videos to provide students with the necessary background knowledge. There is a Student Choice Board in which students will select to complete 4 out of the 9 activities. Student answer sheets are provided for .