Real-Time Rendering——6.8 Parallax Mapping视差映射

A problem with bump and normal mapping is that the bumps never shift location with the view angle, nor ever block each other. If you look along a real brick wall,for example, at some angle you will not see the mortar between the bricks. A bump map of the wall will never show this type of occlusion, as it merely varies the normal.It would be better to have the bumps actually affect which location on the surface is rendered at each pixel.

凹凸和法线贴图的一个问题是,凹凸永远不会随着视角移动位置,也不会互相遮挡。例如,如果你沿着一堵真正的砖墙看,在某个角度你将看不到砖块之间的砂浆。墙的凹凸贴图永远不会显示这种类型的遮挡,因为它只是改变了法线。更好的做法是让凸起实际影响表面上的哪个位置在每个像素处被渲染。

The idea of parallax mapping was introduced in 2001 by Kaneko [851] and refined and popularized by Welsh [1866]. Parallax refers to the idea that the positions of objects move relative to one another as the observer moves. As the viewer moves, the bumps should appear to have heights. The key idea of parallax mapping is to take an educated guess of what should be seen in a pixel by examining the height of what was found to be visible.

视差贴图的想法由Kaneko [851]在2001年提出,并由Welsh [1866]完善和推广。视差指的是当观察者移动时,物体的位置相对于彼此移动。当观察者移动时,凸起应该看起来有高度。视差贴图的关键思想是通过检查可见部分的高度,对像素中应该看到的内容进行有根据的猜测。

For parallax mapping, the bumps are stored in a heightfield texture. When viewing the surface at a given pixel, the heightfield value is retrieved at that location and used to shift the texture coordinates to retrieve a different part of the surface. The amount to shift is based on the height retrieved and the angle of the eye to the surface. See Figure 6.37. The heightfield values are either stored in a separate texture, or packed in an unused color or alpha channel of some other texture (care must be taken when packing unrelated textures together, since this can negatively impact compression quality). The heightfield values are scaled and biased before being used to shift the coordinates. The scale determines how high the heightfield is meant to extend above or below the surface, and the bias gives the “sea-level” height at which no shift takes place. Given a texture-coordinate location p, an adjusted heightfield height h, and a normalized view vector v with a height value vz and horizontal component vxy, the new parallax-adjusted texture coordinate Padj is

对于视差贴图,凹凸存储在heightfield纹理中。当在给定像素处查看表面时,heightfield值在该位置被检索,并用于移动纹理坐标以检索表面的不同部分。移动量基于检索到的高度和眼睛与表面的角度。参见图6.37。heightfield值存储在单独的纹理中,或者打包在未使用的颜色或其他纹理的alpha通道中(将不相关的纹理打包在一起时必须小心,因为这会对压缩质量产生负面影响)。heightfield值在用于移动坐标之前会进行缩放和偏移。标度决定了高度场延伸到地表之上或之下的高度,偏差给出了不发生偏移的“海平面”高度。给定纹理坐标位置p、调整后的高度场高度h以及具有高度值vz和水平分量vxy的归一化视图向量v,新的视差调整后的纹理坐标Padj是

Note that unlike most shading equations, here the space in which the computation is performed matters—the view vector needs to be in tangent space.

请注意,与大多数着色方程不同,这里执行计算的空间很重要——视图向量需要在切线空间中。

Figure 6.37. On the left is the goal: The actual position on the surface is found from where the view vector pierces the heightfield. Parallax mapping does a first-order approximation by taking the height at the location on the rectangle and using it to find a new location padj. (After Welsh [1866].) 

图6.37。左边是目标:从视图向量穿过高度场的地方找到表面上的实际位置。视差贴图通过获取矩形上位置的高度并使用它来寻找新的位置Padj来进行一阶近似。(源自威尔士语[1866年]。)

Though a simple approximation, this shifting works fairly well in practice if the bump heights change relatively slowly [1171]. Nearby neighboring texels then have about the same heights, so the idea of using the original location’s height as an estimate of the new location’s height is reasonable. However, this method falls apart at shallow viewing angles. When the view vector is near the surface’s horizon, a small height change results in a large texture coordinate shift. The approximation fails, as the new location retrieved has little or no height correlation to the original surface location.

虽然这是一个简单的近似,但如果凸起高度变化相对较慢,这种移动在实践中相当有效[1171]。附近的相邻纹理元素具有相同的高度,因此使用原始位置的高度作为新位置高度的估计值是合理的。然而,这种方法在浅视角时会失败。当视图向量靠近表面的地平线时,小的高度变化会导致大的纹理坐标偏移。近似失败,因为检索到的新位置与原始表面位置的高度相关性很小或没有。

To ameliorate this problem, Welsh [1866] introduced the idea of offset limiting. The idea is to limit the amount of shifting to never be larger than the retrieved height.The equation is then

为了改善这个问题,Welsh [1866]引入了偏移限制的概念。这个想法是限制移动的数量,使其永远不会大于检索到的高度。等式是

Note that this equation is faster to compute than the original. Geometrically, the interpretation is that the height defines a radius beyond which the position cannot shift. This is shown in Figure 6.38. 

注意,这个方程比原来的方程计算起来更快。从几何学上来说,这种解释是,高度定义了一个半径,超过这个半径,位置就不能移动。这如图6.38所示。

Figure 6.38. In parallax offset limiting, the offset moves at most the amount of the height away from the original location, shown as a dashed circular arc. The gray offset shows the original result, the black the limited result. On the right is a wall rendered with the technique. (Image courtesy of Terry Welsh.) 

图6.38。在视差偏移限制中,偏移最多移动远离原始位置的高度,显示为虚圆弧。灰色偏移显示原始结果,黑色显示有限结果。右边是一面用这种技术渲染的墙。(图片由特里·威尔士提供。)

At steep (face-on) angles, this equation is almost the same as the original, since vz is nearly 1. At shallow angles, the offset becomes limited in its effect. Visually,this makes the bumpiness lessen at shallow angles, but this is much better than random sampling of the texture. Problems also remain with texture swimming as the view changes, or for stereo rendering, where the viewer simultaneously perceives two viewpoints that must give consistent depth cues [1171]. Even with these drawbacks,parallax mapping with offset limiting costs just a few additional pixel shader program instructions and gives a considerable image quality improvement over basic normal mapping. Shishkovtsov [1631] improves shadows for parallax occlusion by moving the estimated position in the direction of the bump map normal.

 在陡峭(正面)角度时,这个方程几乎与原始方程相同,因为vz接近1。在小角度时,偏移的效果变得有限。从视觉上看,这使得浅角度的凹凸感减少,但这比纹理的随机采样好得多。当视图改变时,纹理游动也存在问题,或者对于立体渲染,其中观察者同时感知必须给出一致深度提示的两个视点[1171]。即使有这些缺点,具有偏移限制的视差贴图只需要几个额外的像素着色器程序指令,并在基本法线贴图的基础上提供了相当大的图像质量改进。Shishkovtsov [1631]通过在凹凸贴图法线方向上移动估计位置来改善视差遮挡的阴影。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

椰子糖莫莫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值