Real-Time Rendering——6.7 Bump Mapping凹凸贴图

This section describes a large family of small-scale detail representation techniques that we collectively call bump mapping. All these methods are typically implemented by modifying the per-pixel shading routine. They give a more three-dimensional appearance than texture mapping alone, but without adding any additional geometry.

本节描述了一个大家族的小比例细节表现技术,我们统称为凹凸贴图。所有这些方法通常都是通过修改每像素着色例程来实现的。它们比单独的纹理映射提供了更三维的外观,但是没有添加任何额外的几何体。

Detail on an object can be classified into three scales: macro-features that cover many pixels, meso-features that are a few pixels across, and micro-features that are substantially smaller than a pixel. These categories are somewhat fluid, since the viewer may observe the same object at many distances during an animation or interactive session.

物体上的细节可以分为三种尺度:覆盖许多像素的宏观特征、几个像素宽的中观特征和远小于一个像素的微观特征。这些类别有些不固定,因为在动画或交互式会话期间,观众可能在许多距离处观察到同一物体。

Macrogeometry is represented by vertices and triangles, or other geometric primitives.When creating a three-dimensional character, the limbs and head are typically modeled at a macroscale. Microgeometry is encapsulated in the shading model, which is commonly implemented in a pixel shader and uses texture maps as parameters.The shading model used simulates the interaction of a surface’s microscopic geometry,e.g., shiny objects are microscopically smooth, and diffuse surfaces are microscopically rough. The skin and clothes of a character appear to have different materials because they use different shaders, or at least different parameters in those shaders.

宏观几何由顶点和三角形或其他几何图元表示。当创建三维角色时,肢体和头部通常以宏观尺度建模。微几何封装在着色模型中,着色模型通常在像素着色器中实现,并使用纹理贴图作为参数。使用的着色模型模拟表面微观几何图形的相互作用,例如,有光泽的对象微观上是平滑的,而漫射表面微观上是粗糙的。角色的皮肤和衣服似乎具有不同的材质,因为它们使用不同的着色器,或者至少在这些着色器中使用不同的参数。

Meso-geometry describes everything between these two scales. It contains detail that is too complex to efficiently render using individual triangles, but that is large enough for the viewer to distinguish individual changes in surface curvature over a few pixels. The wrinkles on a character’s face, musculature details, and folds and seams in their clothing, are all mesoscale. A family of methods collectively known as bump mapping techniques are commonly used for mesoscale modeling. These adjust the shading parameters at the pixel level in such a way that the viewer perceives small perturbations away from the base geometry, which actually remains flat. The main distinctions between the different kinds of bump mapping are how they represent the detail features. Variables include the level of realism and complexity of the detail features. For example, it is common for a digital artist to carve details into a model,then use software to convert these geometric elements into one or more textures, such as a bump texture and perhaps a crevice-darkening texture.

介观几何描述了这两个尺度之间的一切。它包含的细节过于复杂,无法使用单个三角形进行有效渲染,但对于观察者来说,这些细节足够大,可以在几个像素内区分表面曲率的单个变化。角色脸上的皱纹、肌肉细节、衣服上的褶皱和接缝都是中尺度的。统称为凹凸贴图技术的一系列方法通常用于中尺度建模。这些在像素级别调整着色参数,使观察者感觉到远离基本几何体的小扰动,基本几何体实际上保持平坦。不同种类的凹凸贴图之间的主要区别在于它们如何表示细节特征。变量包括细节特征的真实程度和复杂性。例如,数字艺术家通常将细节雕刻到模型中,然后使用软件将这些几何元素转换为一种或多种纹理,如凹凸纹理,或许还有裂隙变暗纹理。

Blinn introduced the idea of encoding mesoscale detail in a texture in 1978 [160].He observed that a surface appears to have small-scale detail if, during shading, we substitute a slightly perturbed surface normal for the true one. He stored the data describing the perturbation to the surface normal in the array.

Blinn在1978年引入了在纹理中编码中尺度细节的想法[160]。他观察到,如果在着色过程中,我们用一个轻微扰动的表面法线代替真正的法线,那么一个表面看起来具有小尺度的细节。他将描述曲面法线扰动的数据存储在数组中。

The key idea is that, instead of using a texture to change a color component in the illumination equation, we access a texture to modify the surface normal. The geometric normal of the surface remains the same; we merely modify the normal used in the lighting equation. This operation has no physical equivalent; we perform changes on the surface normal, but the surface itself remains smooth in the geometric sense.Just as having a normal per vertex gives the illusion that the surface is smooth between triangles, modifying the normal per pixel changes the perception of the triangle surface itself, without modifying its geometry.

关键的想法是,我们访问纹理来修改表面法线,而不是使用纹理来改变照明方程中的颜色分量。曲面的几何法线保持不变;我们只是修改了照明等式中使用的法线。该操作没有物理等效物;我们在曲面法线上执行更改,但是曲面本身在几何意义上保持平滑。正如每个顶点都有一个法线会使三角形之间的曲面看起来很平滑一样,修改每个像素的法线会改变三角形曲面本身的感觉,而不会修改其几何体。

For bump mapping, the normal must change direction with respect to some frame of reference. To do so, a tangent frame, also called a tangent-space basis, is stored at each vertex. This frame of reference is used to transform the lights to a surface location’s space (or vice versa) to compute the effect of perturbing the normal. With a polygonal surface that has a normal map applied to it, in addition to a vertex normal,we also store what are called the tangent and bitangent vectors. The bitangent vector is also incorrectly referred to as the binormal vector [1025].

对于凹凸贴图,法线必须相对于某个参照系改变方向。为此,在每个顶点存储一个切线帧,也称为切线空间基。该参考框架用于将灯光转换到表面位置的空间(反之亦然),以计算干扰法线的效果。对于应用了法线贴图的多边形曲面,除了顶点法线之外,我们还存储了所谓的切线向量和双切线向量。双切线向量也被错误地称为副法线向量[1025]。

The tangent and bitangent vectors represent the axes of the normal map itself in the object’s space, since the goal is to transform the light to be relative to the map.See Figure 6.32.

切线和双切线向量表示法线贴图本身在对象空间中的轴,因为目标是将灯光转换为相对于贴图。参见图6.32。

Figure 6.32. A spherical triangle is shown, with its tangent frame shown at each corner. Shapes like a sphere and torus have a natural tangent-space basis, as the latitude and longitude lines on the torus show. 

图6.32。显示了一个球形三角形,其切线框架显示在每个角上。像球体和圆环体这样的形状有一个自然的切线空间基础,正如圆环体上的经纬线所示。

These three vectors, normal n, tangent t, and bitangent b, form a basis matrix:

这三个向量,法线n、切线t和双切线b,构成了一个基矩阵:

This matrix, sometimes abbreviated as TBN, transforms a light’s direction (for the given vertex) from world space to tangent space. These vectors do not have to be truly perpendicular to each other, since the normal map itself may be distorted to fit the surface. However, a non-orthogonal basis introduces skewing to the texture, which can mean more storage is needed and also can have performance implications, i.e., the matrix cannot then be inverted by a simple transpose [494]. One method of saving memory is to store just the tangent and bitangent at the vertex and take their cross product to compute the normal. However, this technique works only if the handedness of the matrix is always the same [1226]. Frequently a model is symmetric: an airplane,a human, a file cabinet, and many other objects. Because textures consume a large amount of memory, they are often mirrored onto symmetric models. Thus, only one side of an object’s texture is stored, but the texture mapping places it onto both sides of the model. In this case, the handedness of the tangent space will be different on the two sides, and cannot be assumed. It is still possible to avoid storing the normal in this case if an extra bit of information is stored at each vertex to indicate the handedness.If set, this bit is used to negate the cross product of the tangent and bitangent to produce the correct normal. If the tangent frame is orthogonal, it is also possible to store the basis as a quaternion (Section 4.3), which both is more space efficient and can save some calculations per pixel [494, 1114, 1154, 1381, 1639]. A minor loss in quality is possible, though in practice is rarely seen. 

这个矩阵,有时缩写为TBN,将光线的方向(对于给定的顶点)从世界空间转换到切线空间。这些向量不必真正相互垂直,因为法线贴图本身可能会扭曲以适应表面。然而,非正交基引入了纹理倾斜,这可能意味着需要更多的存储,并且还可能具有性能影响,即,矩阵不能通过简单的转置来反转[494]。节省内存的一种方法是只存储顶点处的切线和双切线,并取它们的叉积来计算法线。然而,这种技术只有在矩阵的旋向性总是相同的情况下才有效[1226]。通常一个模型是对称的:一架飞机、一个人、一个文件柜和许多其他对象。因为纹理消耗大量内存,所以它们经常被镜像到对称模型上。因此,只存储了对象纹理的一侧,但是纹理映射将其放置在模型的两侧。在这种情况下,切线空间的旋向性在两侧将是不同的,并且不能被假定。在这种情况下,如果在每个顶点存储一个额外的信息位来表示惯用手,仍然可以避免存储法线。如果该位置位,该位用于求切线和双切线的叉积的反,以产生正确的法线。如果切线框架是正交的,也可以将基础存储为一个四元数(第4.3节),这样既可以更有效地利用空间,又可以节省每个像素的一些计算[494,1114,1154,1381,1639]。质量上的轻微损失是可能的,尽管在实践中很少见到。

The idea of tangent space is important for other algorithms. As discussed in the next chapter, many shading equations rely on only the surface’s normal direction.However, materials such as brushed aluminum or velvet also need to know the relative direction of the viewer and lighting compared to the surface. The tangent frame is useful to define the orientation of the material on the surface. Articles by Lengyel [1025] and Mittring [1226] provide extensive coverage of this area. Sch¨uler [1584] presents a method of computing the tangent-space basis on the fly in the pixel shader, with no need to store a precomputed tangent frame per vertex. Mikkelsen [1209] improves upon this technique, and derives a method that does not need any parameterization but instead uses the derivatives of the surface position and derivatives of a height field to compute the perturbed normal. However, such techniques can lead to considerably less displayed detail than using standard tangent-space mapping, as well as possibly creating art workflow issues [1639].

切空间的思想对其他算法也很重要。正如下一章所讨论的,许多着色方程只依赖于表面的法线方向。然而,像拉丝铝或天鹅绒这样的材料也需要知道观察者和灯光相对于表面的相对方向。相切框对于定义曲面上材料的方向很有用。Lengyel [1025]和Mittring [1226]的文章提供了这一领域的广泛报道。Sch uler [1584]提出了一种在像素着色器中实时计算切线空间基的方法,无需为每个顶点存储预先计算的切线帧。Mikkelsen [1209]改进了这一技术,并推导出一种不需要任何参数化的方法,而是使用表面位置的导数和高度场的导数来计算扰动法线。然而,与使用标准切线空间映射相比,这种技术会导致显示的细节明显减少,并可能产生艺术工作流程问题[1639]。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

椰子糖莫莫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值