本文主要是介绍Real-Time Rendering——6.4 Texture Animation纹理动画 6.5 Material Mapping材料映射,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
6.4 Texture Animation纹理动画
The image applied to a surface does not have to be static. For example, a video source can be used as a texture that changes from frame to frame.
应用于表面的图像不必是静态的。例如,视频源 可用作逐帧变化的纹理。
The texture coordinates need not be static, either. The application designer can explicitly change the texture coordinates from frame to frame, either in the mesh’s data itself or via functions applied in the vertex or pixel shader. Imagine that a waterfall has been modeled and that it has been textured with an image that looks like falling water. Say the v-coordinate is the direction of flow. To make the water move, one must subtract an amount from the v-coordinates on each successive frame.Subtraction from the texture coordinates has the effect of making the texture itself appear to move forward.
纹理坐标也不必是静态的。应用程序设计人员可以在网格数据本身中或通过顶点或像素着色器中应用的函数来显式地更改帧与帧之间的纹理坐标。想象一下,一个瀑布已经被建模,并且已经用看起来像正在下落的水的图像对其进行了纹理处理。假设v坐标是流动的方向。要让水流动,必须在每一个连续的帧上从v坐标中减去一个量。从纹理坐标中减去具有使纹理本身看起来向前移动的效果。
More elaborate effects can be created by applying a matrix to the texture coordinates.In addition to translation, this allows for linear transformations such as zoom,rotation, and shearing [1192, 1904], image warping and morphing transforms [1729],and generalized projections [638]. Many more elaborate effects can be created by applying functions on the CPU or in shaders.
通过将矩阵应用于纹理坐标,可以创建更精细的效果。除了平移,这允许线性变换,例如缩放、旋转和剪切[1192,1904],图像扭曲和变形变换[1729],以及广义投影[638]。通过在CPU或着色器中应用函数,可以创建更多精细的效果。
By using texture blending techniques, one can realize other animated effects. For example, by starting with a marble texture and fading in a flesh texture, one can make a statue come to life [1215].
通过使用纹理混合技术,可以实现其他动画效果。例如,从大理石纹理开始,然后淡入肉色纹理,就可以让雕像栩栩如生[1215]。
6.5 Material Mapping材料映射
A common use of a texture is to modify a material property affecting the shading equation. Real-world objects usually have material properties that vary over their surface. To simulate such objects, the pixel shader can read values from textures and use them to modify the material parameters before evaluating the shading equation.The parameter that is most often modified by a texture is the surface color. This texture is known as an albedo color map or diffuse color map. However, any parameter can be modified by a texture: replacing it, multiplying it, or changing it in some other way. For example, in Figure 6.25 three different textures are applied to a surface,replacing the constant values.
纹理的一个常见用途是修改影响着色方程的材质属性。现实世界中的物体通常具有随其表面而变化的材料属性。为了模拟这样的对象,像素着色器可以从纹理中读取值,并在评估着色方程之前使用它们来修改材质参数。纹理最常修改的参数是表面颜色。这种纹理被称为反照率颜色贴图或漫反射颜色贴图。然而,任何参数都可以被纹理修改:替换它,乘以它,或者以其他方式改变它。例如,在图6.25中,三种不同的纹理被应用到一个表面,取代了常量值。
Figure 6.25. Metallic bricks and mortar. On the right are the textures for surface color, roughness (lighter is rougher), and bump map height (lighter is higher). (Image from three.js example webgl tonemapping [218].)
图6.25。金属砖和灰浆。右边是表面颜色、粗糙度(越浅越粗糙)和凹凸贴图高度(越浅越高)的纹理。(图片来自three.js示例webgl色调映射[218])。)
The use of textures in materials can be taken further. Instead of modifying a parameter in an equation, a texture can be used to control the flow and function of the pixel shader itself. Two or more materials with different shading equations and parameters could be applied to a surface by having one texture specify which areas of the surface have which material, causing different code to be executed for each. As an example, a metallic surface with some rusty regions can use a texture to indicate where the rust is located, conditionally executing the rusty part of the shader based on that texture lookup and otherwise executing the shiny metal shader (Section 9.5.2).
材质的使用可以更进一步。纹理可以用来控制像素着色器本身的流程和功能,而不是修改方程中的参数。通过让一个纹理指定表面的哪些区域具有哪种材料,可以将具有不同着色方程式和参数的两种或多种材料应用于表面,从而为每个区域执行不同的代码。例如,具有一些生锈区域的金属表面可以使用纹理来指示生锈的位置,根据纹理查找有条件地执行着色器的生锈部分,否则执行闪亮金属着色器(第9.5.2节)。
Shading model inputs such as surface color have a linear relationship to the final color output from the shader. Thus, textures containing such inputs can be filtered with standard techniques, and aliasing is avoided. Textures containing nonlinear shading inputs, such as roughness or bump mapping (Section 6.7), require a bit more care to avoid aliasing. Filtering techniques that take account of the shading equation can improve results for such textures. These techniques are discussed in Section 9.13.
着色模型输入(如表面颜色)与着色器的最终颜色输出具有线性关系。因此,包含这种输入的纹理可以用标准技术过滤,并且避免了锯齿。包含非线性阴影输入的纹理,如粗糙度或凹凸贴图(6.7节),需要多加小心以避免走样。考虑到着色方程的过滤技术可以改善这种纹理的结果。这些技术将在9.13节中讨论。
这篇关于Real-Time Rendering——6.4 Texture Animation纹理动画 6.5 Material Mapping材料映射的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!