**对透明涂层使用双法线** 2019年4月28日 1:38 透明涂层着色模型现在可以为透明涂层以下的表面添加第二法线贴图。这样可以更精确地为复杂的材质建模,如表面与透明涂层存在几何差异的碳纤维。在下面的说明中,我们将介绍如何在 UE4 项目中打开并使用这一功能。 **第二法线贴图的作用** 在开始之前,我们先来看看添加第二法线贴图能让我们通过透明涂层着色模型实现什么。 ![Clear Coat Bottom Normal Off](./Use a double normal for the transparent coating.assets/clip_image001.jpg) **Clear Coat Bottom Normal Off** ![Clear Coat Bottom Normal On](./Use a double normal for the transparent coating.assets/clip_image002.jpg) **Clear Coat Bottom Normal On** 在上图中,您可以看到添加第二法线之后对透明涂层下的表面的光照有什么效果。左图是关闭透明涂层底面法线的效果,您会注意到虽然透明涂层下方的表面与光照有互动,但光线只会在一个方向上对表面产生影响,这是的光照效果显得有些平板。右图是开启透明涂层底面法线的效果,您会注意到光线在多个方向上对表面产生影响,而这正是我们要追求的互动结果。 **所需文件** 为重现本说明中的步骤,您需要下载并解压下列纹理文件,并将其导入 UE4。如果您不熟悉这些操作,请参考 [纹理导入指南](https://docs.unrealengine.com/latest/INT/Engine/Content/Types/Textures/Importing/) ,了解相应的详细信息。 [**所需纹理下载**](http://api.unrealengine.com/attachments/Engine/Rendering/Materials/HowTo/ClearCoatDualNormal/ClearCoatDualNormalTextures.zip) ![img](Useadoublenormalforthetransparentcoating.assets/clip_image003.jpg)](http://api.unrealengine.com/attachments/Engine/Rendering/Materials/HowTo/ClearCoatDualNormal/ClearCoatDualNormalTextures.zip) (右键 - 另存为) **启用双法线透明涂层选项** 在使用全新的双法线功能前,您需要先按下列步骤启用该功能。 \1. 在**主工具栏**中,点击 **Edit** > **Project Settings**。 ![Dual_CC_Enable_Option_00.png](file:///C:/Users/WUMING~1/AppData/Local/Temp/msohtmlclip1/01/clip_image005.jpg) \2. 在 Project Settings 中,点击 **Rendering** > **Materials** 然后勾选 **Clear Coat Enable Second Normal** 选项前的复选框,即可启用。 ![Dual_CC_Enable_Option_01.png](file:///C:/Users/WUMING~1/AppData/Local/Temp/msohtmlclip1/01/clip_image007.jpg) \3. 点击 **Restart Now** 选项重启 UE4 Editor,随后 Clear Coat Enable Second Normal 功能将被启用。 ![Dual_CC_Restart_Editor.png](./Use a double normal for the transparent coating.assets/clip_image008.jpg) **使用双法线透明涂层选项** 启用双法线透明涂层选项后,我们将创建并设置一个可以使用它的新材质。为此,请按以下步骤操作。 \1. 在 **Content Browser** 中创建一个新材质,命名为 **Dual_Normal_Clear_Coat**,然后双击将其打开。 ![Dual_CC_Create_Material.png](./Use a double normal for the transparent coating.assets/clip_image010.jpg) \2. 选择 **Main Material Node**,并在 **Details** 面板的 **Material** 部分中,更改下列选项。 · **Shading Model:**Clear Coat ![Dual_CC_Change_Shading_Model.png](./Use a double normal for the transparent coating.assets/clip_image011.jpg) · 向材质图表中添加四个**标量参数表现(Scalar Parameter Expression)**节点,名称和值如下所示。然后将其按下图连接起来。 | **材质表现类型** | **名称** | **默认值** | | ---------------- | -------------------- | ---------- | | Scalar Parameter | Base Color | 0.1225 | | Scalar Parameter | Metallic | 0.5 | | Scalar Parameter | Clear Coat | 1.0 | | Scalar Parameter | Clear Coat Roughness | 0.1225 | ![Dual_CC_Base_Nodes_Setup.png](Use a double normal for the transparent coating.assets/clip_image013.jpg)(http://api.unrealengine.com/images/Engine/Rendering/Materials/HowTo/ClearCoatDualNormal/Dual_CC_Base_Nodes_Setup.png) \4. 接下来的设置:在 Material 的 **Roughness** 部分中,向材质图表添加下列材质表现节点,并为其赋予以下值和名称。添加材质表现节点后,按下图将其连接起来。 | **材质表现类型** | **名称** | **默认值** | | ------------------ | ----------------- | ------------------ | | Scalar Parameter | Roughness Scaling | 30.0 | | Scalar Parameter | Roughness Min | 0.1 | | Scalar Parameter | Roughness Max | 3.0 | | Texture Sample | N/A | T_CarbonFiber_R_00 | | Texture Coordinate | N/A | N/A | | Linear Interpolate | N/A | N/A | ![Dual_CC_Roughness_Setup.png](file:///C:/Users/WUMING~1/AppData/Local/Temp/msohtmlclip1/01/clip_image015.jpg) \5. 由于此材质使用两个法线贴图,我们需要对该材质的两个**法线**贴图部分分别进行设置。材质的第一个法线贴图部分对应透明涂层表面,需要下列材质表现节点。添加材质表现节点后,按下图将其连接起来。 | **材质表现类型** | **名称** | **默认值** | | ------------------ | ----------------------- | --------------- | | Scalar Parameter | Surface Normal Strength | 0.98 | | Scalar Parameter | Surface Normal Scaling | 30.0 | | Texture Sample | N/A | T_CarPaint_N_00 | | Texture Coordinate | N/A | N/A | | Multiply | N/A | N/A | | FlattenNormal | N/A | N/A | ![Dual_CC_Normal_Setup.png](file:///C:/Users/WUMING~1/AppData/Local/Temp/msohtmlclip1/01/clip_image017.jpg) \6. 此**法线**贴图对应的是材质的透明涂层以下的表面,需要对材质图表添加具有如下值和名称的材质表现节点。添加完成后,按下图连接这些材质表现节点。 | **材质表现类型** | **名称** | **默认值** | | --------------------------------------------------- | ------------------ | ------------------- | | Scalar Parameter | Clear Coat Scaling | 30.0 | | Scalar Parameter | Fiber Strength | 0.98 | | Texture Sample | N/A | T_CarbonFiber_N_00' | | Texture Coordinate | N/A | N/A | | Multiply | N/A | N/A | | FlattenNormal | N/A | N/A | | ClearCoatBottomNormal (ClearCoatNormalCustomOutput) | N/A | N/A | ![](./Use a double normal for the transparent coating.assets/clip_image019.jpg) 请确保将 **ClearCoatBottomNormal** 材质表现节点添加到了材质图表中,并将需要使用的法线贴图连接到其输入。否则,您将无法在材质中看到第二法线贴图。 \7. 设置好材质的各个部分后,按下图将输出连接到主材质节点。 ![1559735811021](Use a double normal for the transparent coating.assets/1559735811021.png) \8. 最后,当材质的所有部分都连接到主材质节点的正确位置后,点击 **Apply** 按钮编译材质,然后关闭材质编辑器。 ![1559735820910](Use a double normal for the transparent coating.assets/1559735820910.png) 来自 <>