图形学书籍 Real-Time Rendering 3.6 The Tessellation Stage 曲面细分阶段(根据谷歌翻译修改)

3.6 The Tessellation Stage 曲面细分阶段

The tessellation stage allows us to render curved surfaces. The GPU’s task is to take each surface description and turn it into a representative set of triangles. This stage is an optional GPU feature that first became available in (and is required by) DirectX 11. It is also supported in OpenGL 4.0 and OpenGL ES 3.2.

曲面细分阶段允许我们渲染曲面。 GPU 的任务是获取每个表面描述并将其转化为一组具有代表性的三角形。 此阶段是一项可选的 GPU 功能,它首先在 DirectX 11 中可用(并且是 DirectX 11 所必需的)。OpenGL 4.0 和 OpenGL ES 3.2 也支持它。

There are several advantages to using the tessellation stage. The curved surface description is often more compact than providing the corresponding triangles themselves. Beyond memory savings, this feature can keep the bus between CPU and GPU from becoming the bottleneck for an animated character or object whose shape is changing each frame. The surfaces can be rendered efficiently by having an appropriate number of triangles generated for the given view. For example, if a ball is far from the camera, only a few triangles are needed. Up close, it may look best represented with thousands of triangles. This ability to control the level of detail can also allow an application to control its performance, e.g., using a lower-quality mesh on weaker GPUs in order to maintain frame rate. Models normally represented by flat surfaces can be converted to fine meshes of triangles and then warped as desired [1493], or they can be tessellated in order to perform expensive shading computations less frequently [225].

使用曲面细分阶段有几个优点。 曲面描述通常比提供相应的三角形本身更紧凑。 除了节省内存之外,此功能还可以防止 CPU 和 GPU 之间的总线成为每帧形状都在变化的动画角色或对象的瓶颈。 通过为给定视图生成适当数量的三角形,可以有效地渲染表面。 例如,如果球离相机很远,则只需要几个三角形。 近距离观察,它可能看起来最好用数千个三角形来表示。 这种控制细节级别的能力还可以让应用程序控制其性能,例如,在较弱的 GPU 上使用较低质量的网格以保持帧速率。 通常由平面表示的模型可以转换为精细的三角形网格,然后根据需要进行变形 [1493],或者可以对它们进行镶嵌以减少执行昂贵的着色计算的频率 [225]。

The tessellation stage always consists of three elements. Using DirectX’s terminology, these are the hull shader, tessellator, and domain shader. In OpenGL the hull shader is the tessellation control shader and the domain shader the tessellation evaluation shader, which are a bit more descriptive, though verbose. The fixed-function tessellator is called the primitive generator in OpenGL, and as will be seen, that is indeed what it does.

镶嵌阶段总是由三个元素组成。 使用 DirectX 的术语,这些是外壳着色器、曲面细分器和域着色器。 在 OpenGL 中,外壳着色器是曲面细分控制着色器,域着色器是曲面细分评估着色器,它们的描述性更强一些,但很冗长。 固定功能曲面细分器在 OpenGL 中称为图元生成器,正如将会看到的那样,这确实是它的作用。

How to specify and tessellate curves and surfaces is discussed at length in Chapter 17. Here we give a brief summary of each tessellation stage’s purpose. To begin, the input to the hull shader is a special patch primitive. This consists of several control points defining a subdivision surface, Bézier patch, or other type of curved element. The hull shader has two functions. First, it tells the tessellator how many triangles should be generated, and in what configuration. Second, it performs processing on each of the control points. Also, optionally, the hull shader can modify the incoming patch description, adding or removing control points as desired. The hull shader outputs its set of control points, along with the tessellation control data, to the domain shader. See Figure 3.9.

第 17 章详细讨论了如何指定和细分曲线和曲面。这里我们简要总结每个细分阶段的目的。 首先,外壳着色器的输入是一个特殊的补丁图元。 这由几个定义细分曲面、贝塞尔面片或其他类型的弯曲元素的控制点组成。 船体着色器有两个功能。 首先,它告诉曲面细分器应该生成多少个三角形,以及以何种配置生成。 其次,它对每个控制点进行处理。 此外,可选地,外壳着色器可以修改传入的补丁描述,根据需要添加或删除控制点。 外壳着色器将其控制点集连同曲面细分控制数据一起输出到域着色器。 见图 3.9。

图形学书籍 Real-Time Rendering 3.6 The Tessellation Stage 曲面细分阶段(根据谷歌翻译修改)_第1张图片

Figure 3.9. The tessellation stage. The hull shader takes in a patch defined by control points. It sends the tessellation factors (TFs) and type to the fixed-function tessellator. The control point set is transformed as desired by the hull shader and sent on to the domain shader, along with TFs and related patch constants. The tessellator creates the set of vertices along with their barycentric coordinates. These are then processed by the domain shader, producing the triangle mesh (control points shown for reference).
图 3.9。 细分阶段。 船体着色器接受由控制点定义的补丁。 它将细分因子 (TF) 和类型发送到固定功能细分器。 控制点集根据外壳着色器的需要进行转换,并与 TF 和相关的补丁常量一起发送到域着色器。 曲面细分器创建顶点集及其重心坐标。 然后这些由域着色器处理,生成三角形网格(显示控制点以供参考)。

The tessellator is a fixed-function stage in the pipeline, only used with tessellation shaders. It has the task of adding several new vertices for the domain shader to process. The hull shader sends the tessellator information about what type of tessellation surface is desired: triangle, quadrilateral, or isoline. Isolines are sets of line strips, sometimes used for hair rendering [1954]. The other important values sent by the hull shader are the tessellation factors (tessellation levels in OpenGL). These are of two types: inner and outer edge. The two inner factors determine how much tessellation occurs inside the triangle or quadrilateral. The outer factors determine how much each exterior edge is split (Section 17.6). An example of increasing tessellation factors is shown in Figure 3.10. By allowing separate controls, we can have adjacent curved surfaces’ edges match in tessellation, regardless of how the interiors are tessellated. Matching edges avoids cracks or other shading artifacts where patches meet. The vertices are assigned barycentric coordinates (Section 22.8), which are values that specify a relative location for each point on the desired surface.

细分器是管道中的固定功能阶段,仅与细分着色器一起使用。 它的任务是为域着色器添加几个新的顶点来处理。 外壳着色器向细分器发送有关所需细分曲面类型的信息:三角形、四边形或等值线。 等值线是一组线带,有时用于头发渲染 [1954]。 外壳着色器发送的其他重要值是镶嵌因子(OpenGL 中的镶嵌级别)。 这些有两种类型:内部边缘和外部边缘。 这两个内部因素决定了三角形或四边形内部会出现多少镶嵌。 外部因素决定了每个外部边缘被分割的程度(第 17.6 节)。 图 3.10 显示了增加镶嵌因子的示例。 通过允许单独的控件,我们可以让相邻曲面的边缘在细分中匹配,而不管内部是如何细分的。匹配边缘避免了补丁相遇处的裂缝或其他阴影伪影。 顶点被分配了重心坐标(第 22.8 节),这些值指定了所需表面上每个点的相对位置。

图形学书籍 Real-Time Rendering 3.6 The Tessellation Stage 曲面细分阶段(根据谷歌翻译修改)_第2张图片

Figure 3.10. The effect of varying the tessellation factors. The Utah teapot is made of 32 patches. Inner and outer tessellation factors, from left to right, are 1, 2, 4, and 8. (Images generated by demo from Rideout and Van Gelder [1493].)
图 3.10。 改变镶嵌因子的效果。 犹他茶壶由 32 个补丁组成。 内部和外部镶嵌因子从左到右分别为 1、2、4 和 8。(图像由 Rideout 和 Van Gelder [1493] 的演示生成。)

The hull shader always outputs a patch, a set of control point locations. However, it can signal that a patch is to be discarded by sending the tessellator an outer tessellation level of zero or less (or not-a-number, NaN). Otherwise, the tessellator generates a mesh and sends it to the domain shader. The control points for the curved surface from the hull shader are used by each invocation of the domain shader to compute the output values for each vertex. The domain shader has a data flow pattern like that of a vertex shader, with each input vertex from the tessellator being processed and generating a corresponding output vertex. The triangles formed are then passed on down the pipeline.

船体着色器总是输出一个补丁,一组控制点位置。 但是,它可以通过向细分器发送零或更小(或非数字,NaN)的外部细分级别来表示要丢弃补丁。 否则,曲面细分器生成一个网格并将其发送到域着色器。 域着色器的每次调用都使用来自外壳着色器的曲面控制点来计算每个顶点的输出值。 域着色器具有类似于顶点着色器的数据流模式,来自曲面细分器的每个输入顶点都经过处理并生成相应的输出顶点。 形成的三角形然后沿着管道向下传递。

While this system sounds complex, it is structured this way for efficiency, and each shader can be fairly simple. The patch passed into a hull shader will often undergo little or no modification. This shader may also use the patch’s estimated distance or screen size to compute tessellation factors on the fly, as for terrain rendering [466]. Alternately, the hull shader may simply pass on a fixed set of values for all patches that the application computes and provides. The tessellator performs an involved but fixed-function process of generating the vertices, giving them positions, and specifying what triangles or lines they form. This data amplification step is performed outside of a shader for computational efficiency [530]. The domain shader takes the barycentric coordinates generated for each point and uses these in the patch’s evaluation equation to generate the position, normal, texture coordinates, and other vertex information desired. See Figure 3.11 for an example.

虽然这个系统听起来很复杂,但它的结构是为了提高效率,而且每个着色器都可以相当简单。 传递到外壳着色器的补丁通常会进行很少的修改或不进行修改。 该着色器还可以使用补丁的估计距离或屏幕尺寸来动态计算曲面细分因子,如地形渲染 [466]。 或者,外壳着色器可以简单地为应用程序计算和提供的所有补丁传递一组固定值。 曲面细分器执行一个复杂但功能固定的过程,即生成顶点、为它们指定位置并指定它们形成的三角形或线。 这个数据放大步骤是在着色器之外执行的,以提高计算效率 [530]。 域着色器获取为每个点生成的重心坐标,并在补丁的评估方程中使用这些坐标来生成位置、法线、纹理坐标和其他所需的顶点信息。 有关示例,请参见图 3.11。

图形学书籍 Real-Time Rendering 3.6 The Tessellation Stage 曲面细分阶段(根据谷歌翻译修改)_第3张图片

Figure 3.11. On the left is the underlying mesh of about 6000 triangles. On the right, each triangle is tessellated and displaced using PN triangle subdivision. (Images from NVIDIA SDK 11 [1301] samples, courtesy of NVIDIA Corporation, model from Metro 2083 by 4A Games.)
图 3.11。 左边是大约 6000 个三角形的底层网格。 在右侧,使用 PN 三角形细分对每个三角形进行细分和置换。 (图片来自 NVIDIA SDK 11 [1301] 样本,由 NVIDIA Corporation 提供,模型来自 4A Games 的 Metro 2083。)

你可能感兴趣的:(Real-Time,Rendering,谷歌翻译,图形渲染,几何学,着色器)