<!--
{
  "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/clearcoat-swift.property",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CustomMaterialV9clearcoatAC9ClearcoatVvp"
  },
  "title" : "clearcoat"
}
-->

# clearcoat

The transparent highlights that simulate a clear, shiny coating on an
entity.

```
var clearcoat: CustomMaterial.Clearcoat { get set }
```

## Discussion

An entity in RealityKit can display a clearcoat, which is a separate
layer of transparent specular highlights used to simulate a clear
coating, like on a car or the surface of lacquered objects.

This property allows you to specify
[`clearcoat`](/documentation/RealityKit/PhysicallyBasedMaterial/clearcoat-swift.property) using a single
`Float` that applies to the entire material, or a UV-mapped grayscale
image to provide different values for different parts of an entity.

The following example specifies `clearcoat` using a single value:

```swift
material.clearcoat = .init(floatLiteral: 0.8)
```

This example shows how to specify `clearcoat` using a UV-mapped image
texture:

```swift
if let clearcoatResource = try? TextureResource.load(named:
"entity_clearcoat") {
    let clearcoatMap = MaterialParameters.Texture(clearcoatResource)
    material.clearcoat = .init(texture: clearcoatMap)
}
```

With custom materials, RealityKit doesn’t automatically use the values
you set for this property to render your entity. The values from this
property are available to the custom material’s surface shader, but it
doesn’t render a clearcoat unless the custom material’s
[`lightingModel`](/documentation/RealityKit/CustomMaterial/lightingModel-swift.property) is
[`CustomMaterial.LightingModel.clearcoat`](/documentation/RealityKit/CustomMaterial/LightingModel-swift.enum/clearcoat) and the surface
shader calls `params.surface().set_clearcoat()`.

The following Metal code demonstrates how to retrieve the scale and
texture from this property, and use them to enable clearcoat rendering.

```cpp
// Retrieve the clearcoat scale from the CustomMaterial.
float clearcoatScale = params.material_constants().clearcoat_scale();

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

// Models loaded from USDZ or .reality files use texture coordinates with a
// flipped y-axis. This compensates for that.
uv.y = 1.0 - uv.y;

// Sample the clearcoat texture using the texture coordinates.
auto tex = params.textures();
half clearcoat = tex.clearcoat().sample(textureSampler, uv).r;

// Multiply the scale and sampled value from the texture, and assign
// the result.
clearcoat *= clearcoatScale;
params.surface().set_clearcoat(clearcoat);
```

---

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)