<!--
{
  "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/Metallic-swift.struct/init(floatLiteral:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CustomMaterialV8MetallicV12floatLiteralAESf_tcfc"
  },
  "title" : "init(floatLiteral:)"
}
-->

# init(floatLiteral:)

Creates an object from a single value.

```
init(floatLiteral value: Float)
```

## Parameters

`value`

The reflectiveness value for the material.

## Discussion

In physically based rendering, the `metallic` property represents
the reflectiveness of an entity. This initializer creates a new
object that passes a single metallic value to your custom shader
functions but doesn’t pass a texture.

The following Swift code shows how to specify reflectiveness using a
single value for the entire entity:

```swift
material.roughness = PhysicallyBasedMaterial.Roughness(floatLiteral: 0.0)
```

To render an entity with reflectiveness, 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_metallic()`
from its surface shader.

The following Metal code shows how to retrieve the value set in this
initializer in your surface shader and use it:

```other
    // Retrieve the metallic scale from the CustomMaterial.
    float metallic = params.material_constants().metallic_scale();

    // Set the roughness value using the metallic scale value.
    params.surface().set_metallic(metallic);
```

For more information on creating custom materials and writing shader
functions, see
[Modifying RealityKit rendering using custom materials](/documentation/RealityKit/modifying-realitykit-rendering-using-custom-materials).

---

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)