Real-Time Rendering——6.8.1 Parallax Occlusion Mapping视差遮挡贴图

Bump mapping does not modify texture coordinates based on the heightfield; it varies only the shading normal at a location. Parallax mapping provides a simple approximation of the effect of the heightfield, working on the assumption that the height at a pixel is about the same as the heights of its neighbors. This assumption can quickly break down. Bumps can also never occlude one another, nor cast shadows. What we want is what is visible at the pixel, i.e., where the view vector first intersects the heightfield.

凹凸贴图不会根据高度场修改纹理坐标;它仅改变某个位置的明暗度法线。视差贴图提供了高度场效果的简单近似,它基于一个像素的高度与其相邻像素的高度大致相同的假设。这种假设很快就会被打破。颠簸也不会互相遮挡,也不会产生阴影。我们想要的是在像素处可见的东西,也就是视图向量第一次与高度场相交的地方。

To solve this in a better way, several researchers have proposed to use ray marching along the view vector until an (approximate) intersection point is found. This work can be done in the pixel shader where height data can be accessed as textures. We lump the research on these methods into a subset of parallax mapping techniques, which exploit ray marching in one way or another

为了以更好的方式解决这个问题,一些研究人员已经提出使用沿着视图向量行进的射线,直到找到(近似的)交点。这项工作可以在像素着色器中完成,其中高度数据可以作为纹理进行访问。我们把对这些方法的研究归为视差贴图技术的一个子集,视差贴图技术以这样或那样的方式利用光线行进

These types of algorithms are called parallax occlusion mapping (POM) or relief mapping methods, among other names. The key idea is to first test a fixed number of heightfield texture samples along the projected vector. More samples are usually generated for view rays at grazing angles, so that the closest intersection point is not missed. Each three-dimensional location along the ray is retrieved,transformed into texture space, and processed to determine if it is above or below the heightfield. Once a sample below the heightfield is found, the amount it is below, and the amount the previous sample is above, are used to find an intersection location.See Figure 6.39. The location is then used to shade the surface, using the attached normal map, color map, and any other textures. Multiple layered heightfields can be used to produce overhangs, independent overlapping surfaces, and two-sided reliefmapped impostors; see Section 13.7. The heightfield tracing approach can also be used to have the bumpy surface cast shadows onto itself, both hard [1171, 1424] and soft [1742, 1743]. See Figure 6.40 for a comparison.

这些类型的算法被称为视差遮挡映射(POM)或浮雕映射方法,以及其他名称。主要思想是首先沿着投影向量测试固定数量的高度场纹理样本。通常为掠射角的视线生成更多的样本,从而不会错过最近的交点。沿着射线的每个三维位置被检索,转换到纹理空间,并被处理以确定它是在高度场之上还是之下。一旦发现高度场下方的样本,其下方的量和前一个样本上方的量用于找到交叉点位置。参见图6.39。然后,使用附加的法线贴图、颜色贴图和任何其他纹理,使用该位置对表面进行着色。多层高度场可用于产生突出物、独立的重叠表面和双面浮雕贴图的视点替用特效;参见第13.7节。heightfield跟踪方法也可以用于使凹凸不平的表面将阴影投射到自身上,包括硬的[1171,1424]和软的[1742,1743]。比较见图6.40。

Figure 6.39. The green eye ray is projected onto the surface plane, which is sampled at regular intervals (the violet dots) and the heights are retrieved. The algorithm finds the first intersection of the eye ray with the black line segments approximating the curved height field. 

图6.39。绿色视线投射到表面平面上,表面平面以规则的间隔采样(紫色点),并检索高度。该算法找到视线与近似弯曲高度场的黑色线段的第一个交点。

Figure 6.40. Parallax mapping without ray marching (left) compared to with ray marching (right).On the top of the cube there is flattening when ray marching is not used. With ray marching,selfshadowing effects are also generated. (Images courtesy of Manuel M. Oliveira and Fabio Policarpo.) 

图6.40。不带光线行进的视差贴图(左)与带光线行进的视差贴图(右)。当不使用光线行进时,立方体的顶部是扁平的。使用光线行进,还会产生自阴影效应。(图片由Manuel M. Oliveira和Fabio Policarpo提供。)

There is a wealth of literature on this topic. While all these methods march along a ray, there are several differences. One can use a simple texture to retrieve heights,but it is also possible to use a more advanced data structure and more advanced rootfinding methods. Some techniques may involve the shader discarding pixels or writing to the depth buffer, which can hurt performance. Below we summarize a large set of methods, but remember that as GPUs evolve, so does the best method. This “best” method depends on content and the number of steps done during ray marching.

关于这个主题有大量的文献。虽然所有这些方法都沿着一条射线前进,但有几个不同之处。可以使用简单的纹理来检索高度,但也可以使用更高级的数据结构和更高级的寻根方法。一些技术可能涉及着色器丢弃像素或写入深度缓冲区,这会影响性能。下面我们总结了一大套方法,但是要记住,随着GPU的进化,最好的方法也在进化。这种“最佳”方法取决于射线行进过程中的内容和步骤数。

The problem of determining the actual intersection point between the two regular samples is a root-finding problem. In practice the heightfield is treated more as a depthfield, with the rectangle’s plane defining the upper limit of the surface. In this way, the initial point on the plane is above the heightfield. After finding the last point above, and first point below, the heightfield’s surface, Tatarchuk [1742, 1743] uses a single step of the secant method to find an approximate solution. Policarpo et al. [1424] use a binary search between the two points found to hone in on a closer intersection.Risser et al. [1497] speed convergence by iterating using a secant method. The tradeoff is that regular sampling can be done in parallel, while iterative methods need fewer overall texture accesses but must wait for results and perform slower dependent texture fetches. Brute-force methods seem to perform well overall [1911].

确定两个规则样本之间的实际交点的问题是一个求根问题。实际上,高度场更多地被视为深度场,矩形平面定义了表面的上限。这样,平面上的初始点就在高度场之上。在找到上面的最后一点和下面的第一点(heightfield曲面)后,塔塔丘克[1742,1743]使用割线法的一个步骤来寻找近似解。Policarpo等人【1424】在发现的两点之间使用二分搜索法,以锁定更近的交点。Risser等人[1497]通过使用割线法迭代来加速收敛。代价是常规采样可以并行进行,而迭代方法需要较少的整体纹理访问,但必须等待结果并执行较慢的相关纹理提取。蛮力方法似乎总体表现良好[1911]。

It is critical to sample the heightfield frequently enough. McGuire and McGuire [1171] propose biasing the mipmap lookup and using anisotropic mipmaps to ensure correct sampling for high-frequency heightfields, such as those representing spikes or hair. One can also store the heightfield texture at higher resolution than the normal map. Finally, some rendering systems do not even store a normal map, preferring to derive the normal on the fly from the heightfield using a cross filter [40]. Equation 16.1 on page 696 shows the method.

对高度场进行足够频繁的采样是至关重要的。McGuire和McGuire [1171]建议对小中见大贴图查找进行偏置,并使用各向异性小中见大贴图来确保对高频高度场(如代表尖峰或毛发的高度场)进行正确采样。你也可以用比普通贴图更高的分辨率来存储高度场纹理。最后,一些渲染系统甚至不存储法线贴图,更倾向于使用十字滤镜从高度场动态导出法线[40]。696页的方程16.1给出了这种方法。

Another approach to increasing both performance and sampling accuracy is to not initially sample the heightfield at a regular interval, but instead to try to skip intervening empty space. Donnelly [367] preprocesses the height field into a set of voxels, storing in each voxel how far away it is from the heightfield surface. In this way,intervening space can be rapidly skipped, at the cost of higher storage for each heightfield. Wang et al. [1844] use a five-dimensional displacement mapping scheme to hold distances to the surface from all directions and locations. This allows complex curved surfaces, self-shadowing, and other effects, at the expense of considerably larger amounts of memory. Mehra and Kumar [1195] use directional distance maps for similar purposes. Dummer [393] introduces, and Policarpo and Oliveira [1426] improve upon,the idea of cone step mapping. The concept here is to also store for each heightfield location a cone radius. This radius defines an interval on the ray in which there is at most one intersection with the heightfield. This property allows rapid skipping along the ray without missing any possible intersections, though at the cost of needing dependent texture reads. Another drawback is the precomputation needed to create the cone step map, making the method unusable for dynamically changing heightfields. Schroders and Gulik [1581] present quadtree relief mapping, a hierarchical method to skip over volumes during traversal. Tevs et al. [1760] use “maximum mipmaps” to allow skipping while minimizing precomputation costs. Drobot [377] also uses a quadtree-like structure stored in mipmaps to speed up traversal, and presents a method to blend between different heightfields, where one terrain type transitions to another.

提高性能和采样精度的另一种方法是最初不以规则的间隔对高度场进行采样,而是尝试跳过中间的空白空间。Donnelly [367]将高度场预处理成一组体素,在每个体素中存储它离高度场表面有多远。这样,可以快速跳过中间空间,代价是每个高度场需要更大的存储空间。Wang等人[1844]使用五维位移映射方案来保持从所有方向和位置到表面的距离。这允许复杂的曲面、自阴影和其他效果,代价是相当大的内存量。Mehra和Kumar [1195]将方向距离图用于类似目的。Dummer [393]引入了锥形步长映射的概念,Policarpo和Oliveira [1426]对其进行了改进。这里的概念是也为每个高度场位置存储一个圆锥半径。这个半径定义了射线上的一个区间,在这个区间内,与高度场至多有一个交点。这个属性允许快速跳过光线而不会错过任何可能的交点,尽管代价是需要依赖纹理读取。另一个缺点是创建锥形台阶图所需的预计算,这使得该方法不能用于动态改变高度场。Schroders和Gulik [1581]提出了四叉树浮雕映射,这是一种在遍历期间跳过体积的分层方法。Tevs等人[1760]使用“最大mipmaps”来允许跳过,同时最小化预计算成本。Drobot [377]还使用存储在mipmaps中的类似四叉树的结构来加速遍历,并提出了一种在不同高度场之间混合的方法,其中一种地形类型过渡到另一种。

One problem with all the methods above is that the illusion breaks down along the silhouette edges of objects, which will show the original surface’s smooth outlines. See Figure 6.41. The key idea is that the triangles rendered define which pixels should be evaluated by the pixel shader program, not where the surface actually is located. In addition, for curved surfaces, the problem of silhouettes becomes more involved. One approach is described and developed by Oliveira and Policarpo [1325, 1850], which uses a quadratic silhouette approximation technique. Jeschke et al. [824] and Dachsbacher et al. [323] both give a more general and robust method (and review previous work) for dealing with silhouettes and curved surfaces correctly. First explored by Hirche [750],the general idea is to extrude each triangle in the mesh outward and form a prism.Rendering this prism forces evaluation of all pixels in which the heightfield could possibly appear. This type of approach is called shell mapping, as the expanded mesh forms a separate shell over the original model. By preserving the nonlinear nature of prisms when intersecting them with rays, artifact-free rendering of heightfields becomes possible, though expensive to compute. An impressive use of this type of technique is shown in Figure 6.42.

上述所有方法的一个问题是,沿着物体的轮廓边缘会出现错觉,这将显示原始表面的平滑轮廓。参见图6.41。关键的想法是,渲染的三角形定义了哪些像素应该由像素着色器程序进行评估,而不是表面的实际位置。此外,对于曲面,轮廓问题变得更加复杂。Oliveira和Policarpo [1325,1850]描述并开发了一种方法,该方法使用二次轮廓近似技术。Jeschke等人【824】和Dachsbacher等人【323】都给出了一种更通用、更稳健的方法(并回顾了之前的工作),用于正确处理轮廓和曲面。最早由Hirche [750]探索,总体思路是将网格中的每个三角形向外挤压,形成一个棱柱。渲染该棱柱会强制评估可能出现高度场的所有像素。这种方法称为壳贴图,因为扩展的网格在原始模型上形成一个单独的壳。通过保持棱镜与光线相交时的非线性性质,高度场的无伪影渲染成为可能,尽管计算起来很昂贵。这种技术的一个令人印象深刻的应用如图6.42所示。

Figure 6.41. Normal mapping and relief mapping. No self-occlusion occurs with normal mapping. Relief mapping has problems with silhouettes for repeating textures, as the rectangle is more of a view into the heightfield than a true boundary definition. (Images courtesy of NVIDIA Corporation.) 

图6.41。法线贴图和浮雕贴图。法线贴图不会发生自遮挡。浮雕贴图对于重复纹理的轮廓有问题,因为矩形更像是高度场的视图,而不是真正的边界定义。(图片由英伟达公司提供。)

Figure 6.42. Parallax occlusion mapping, a.k.a. relief mapping, used on a path to make the stones look more realistic. The ground is actually a simple set of triangles with a heightfield applied. (Image from “Crysis,” courtesy of Crytek.) 

图6.42。视差遮挡贴图,又称浮雕贴图,用于路径上,使石头看起来更真实。地面实际上是一组简单的应用了高度场的三角形。(图片来自《孤岛危机》,由Crytek提供。)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

椰子糖莫莫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值