Displacement 示例
This material graph sample demonstrates how to implement displacement mapping in your materials.此材质图表示例演示了如何在材质中实现置换贴图。
The Sample Texture node samples data from the tangent-space normal map taken from the normal Texture 2D node (enabling you to select a texture asset via the Parameters panel in UnigineEditor) in accordance with the default UV, normal vector components are passed to the Material node.Sample Texture 节点根据默认 UV 从法线 Texture 2D 节点获取的切线空间法线贴图中采样数据(使您可以通过 UnigineEditor 中的 Parameters 面板选择纹理资源),法线向量分量被传递到 Material 节点。
Albedo data for the material is specified directly via a Float node (casting to float3 is performed automatically).材质的反照率数据直接通过 Float 节点指定(自动转换为 float3)。
Data of a single-channel heightmap taken from the Texture 2D node and sampled by the Sample Texture node is passed via the x port adapter to the Add node which applies the displacement offset according the Offset Slider parameter node (enabling you to adjust a float value via the Parameters panel in UnigineEditor). The output is then multiplied (the Multiply node) by the displacement height value provided by the second Slider node and passed to the Tessellation Vertex Offset Tangent Space port of the material node via the 0,0,x port adapter (meaning that the value shall control displacement along the Z axis only, keeping X and Y as they are).从 Texture 2D 节点获取并由 Sample Texture 节点采样的单通道高度图的数据通过 x 传递端口适配器到 Add 节点,该节点根据 Offset Slider 参数节点应用位移偏移(使您能够通过 UnigineEditor 中的 Parameters 面板调整浮点值)。然后将输出(Multiply 节点)乘以第二个 Slider 节点提供的位移高度值,并通过 0,0,x 端口适配器传递到材质节点的 Tessellation Vertex Offset Tangent Space 端口(意味着该值应仅控制沿 Z 轴的位移,保持 X 和 Y 不变)。
Tessellation Factor for the material is specified using a Slider parameter node enabling you to adjust the value in the Parameters panel.材质的 Tessellation Factor 使用 Slider 参数节点指定,使您能够调整 Parameters 面板中的值。