<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PhysicallyBasedMaterial/EmissiveColor-swift.struct/init(color:texture:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation23PhysicallyBasedMaterialV13EmissiveColorV0A3KitE5color7textureAESo7NSColorC_AA0E10ParametersV7TextureVSgtcfc::OverloadGroup"
  },
  "title" : "init(color:texture:)"
}
-->

# init(color:texture:)

Creates a color of emitted light in iOS.

```
init(color: NSColor = .black, texture: MaterialParameters.Texture? = nil)
```

## Parameters

`color`

The color of the emitted light. Defaults to black.

`texture`

An optional UV-mapped image texture.

## Discussion

This initializer creates an object from a color, an image texture, or
from both. The `color` property defaults to black, which results in no
light emissions. With custom materials, `color` and `texture` are
available as inputs in your surface shader, but your surface shader must
call `params.surface().set_emissive_color()`, otherwise RealityKit
renders no light emission.

The following Metal code demonstrates how to replicate the emissive
behavior of [`PhysicallyBasedMaterial`](/documentation/RealityKit/PhysicallyBasedMaterial) in your surface shader code:

```swift
    // Retrieve the emissive color tint from the CustomMaterial.
    half3 emissiveColorTint = (half3)params.material_constants()
                              .emissive_color_tint();

    // Retrieve the primary texture coordinates.
    float2 uv = params.geometry().uv0();

    // Flip the UV coordinate’s y-axis. You only need to do this
    // for models you load from USDZ or .reality files.
    uv.y = 1.0 - uv.y;

    auto tex = params.textures();
    half3 color = (half3)tex.emissive_color()
                  .sample(textureSampler, uv).rgb;

    // Multiply the tint and the sampled value from the texture,
    // and assign the result to the shader's emissive color
    // property.
    color *= emissiveColorTint;
    params.surface().set_emissive_color(color);
```

> Note: Unlike ``doc://com.apple.RealityKit/documentation/RealityKit/PhysicallyBasedMaterial``, ``doc://com.apple.RealityKit/documentation/RealityKit/CustomMaterial`` has no
> ``doc://com.apple.RealityKit/documentation/RealityKit/PhysicallyBasedMaterial/emissiveIntensity`` value. If you need to pass
> an emissive intensity value to your surface shader, use the
> ``doc://com.apple.RealityKit/documentation/RealityKit/CustomMaterial/custom-swift.property`` property or another unused
> attribute property.

---

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)