Version: 2020.3

Mesh.RecalculateNormals

切换到手册
public void RecalculateNormals (Rendering.MeshUpdateFlags flags= MeshUpdateFlags.Default);

参数

flags 控制函数行为的标志,请参阅 MeshUpdateFlags

描述

从三角形和顶点重新计算网格的法线。

修改顶点之后,更新法线以反映更改会十分有用。法线从所有共享的顶点进行计算。

导入的网格有时不共享所有顶点。例如,UV 接缝处的顶点会拆分为两个顶点,因此 RecalculateNormals 函数会创建在 UV 接缝处不平滑的法线。

Note that RecalculateNormals does not generate tangents automatically, to do that use RecalculateTangents.

using UnityEngine;

public class Example : MonoBehaviour { void Start() { Mesh mesh = GetComponent<MeshFilter>().mesh; mesh.RecalculateNormals(); } }

RecalculateNormals converts Mesh vertex position data to VertexAttributeFormat.Float32 format, if the format is different.

See Also: RecalculateTangents.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961