Generates surface normal data for the mesh based on its vertex position data.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- Model I/O
The name of the vertex attribute for storing surface normal data. If
nil, this method writes data into the
MDLVertexattribute by default.
A value between
1that determines the smoothness of normal generation between adjacent faces. Lower values interpolate sharper angles between faces into smooth surfaces, and higher values smooth only between faces that are nearly parallel. A value of
1prevents smoothing, resulting in a faceted appearance.
Model I/O calculates surface normal vectors based on vertex positions using the common definition: The surface normal to a triangle is the normalized cross product of two sides of the triangle. For this method to calculate surface normals, the mesh must contain vertex data for the
MDLVertex attribute. Calling this method on a mesh that does not contain vertex position data raises an exception.
crease parameter controls smoothing between adjacent faces. If two faces share an edge and are nearly parallel — that is, the dot product of their normal vectors is greater than the
crease value, this method generates a normal vector that interpolates between the two faces’ normal vectors. When shading with interpolated normal vectors, the two faces appear to be part of a smooth curve instead of two flat facets.
This method saves calculated normal data in the vertex attribute named in the
attribute parameter (by default, the
MDLVertex attribute). If the mesh already contains that attribute, this method overwrites the contents of the corresponding vertex buffer. If the mesh does not contain that attribute, this method creates a new attribute and updates the mesh’s
vertex object accordingly.