<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/CustomMaterial/Normal-swift.struct/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CustomMaterialV6NormalVyAeA015PhysicallyBasedD0VADVcfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates an object containing surface details for an entity from a
custom material’s normal property.

```
init(_ value: PhysicallyBasedMaterial.Normal)
```

## Parameters

`value`

The normal object from a [`PhysicallyBasedMaterial`](/documentation/RealityKit/PhysicallyBasedMaterial).

## Discussion

This initializer creates an object by copying the normal map from
the [`normal`](/documentation/RealityKit/PhysicallyBasedMaterial/normal-swift.property) property of a
[`PhysicallyBasedMaterial`](/documentation/RealityKit/PhysicallyBasedMaterial).

*Normal mapping* is a real-time rendering technique that captures
fine surface details for a model by using a texture instead of by
increasing the number of polygons in the model. It works by storing
*surface normals*, which are vectors perpendicular to the surface of
the model, from a much higher-resolution version of the same 3D
object. A normal map stores each vector in the image by storing the
vectors’ `X`, `Y`, and `Z` values as the `R`, `G`, and `B`
components of the corresponding pixel in the UV-mapped image.

To render an entity using a normal map, set
[`lightingModel`](/documentation/RealityKit/CustomMaterial/lightingModel-swift.property) to
[`CustomMaterial.LightingModel.lit`](/documentation/RealityKit/CustomMaterial/LightingModel-swift.enum/lit) or
[`CustomMaterial.LightingModel.clearcoat`](/documentation/RealityKit/CustomMaterial/LightingModel-swift.enum/clearcoat),
and call `params.surface().set_normal()`
from its surface shader.

The following Metal code
demonstrates how to sample and use a value from the normal map in
your surface shader function:

```swift
    // Retrieve the entity's UV texture coordinates.
    float2 uv = params.geometry().uv0();

    // Models loaded from USDZ or Reality Composer use UVs that are flipped
    // on the y-axis. This compensates for that.
    uv.y = 1.0 - uv.y;

    // Sample the normal map texture based on the resulting UV coordinates.
    auto tex = params.textures();
    float3 normal = (float3)tex.normal().sample(textureSampler, uv).rgb;

    // Set the sampled value as this pixel's normal.
    params.surface().set_normal(normal);
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)