<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/using-system-tone-mapping-on-video-content",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Using system tone mapping on video content"
}
-->

# Using system tone mapping on video content

Use EDR metadata to apply the default system tone mapping to a layer.

## Discussion

When processing video content, you usually want to work in a linear color space. You also want to display content that’s consistent with how playback would appear in AVFoundation or other playback mechanisms. To create content in your app that is consistent with the system behavior, create a Metal layer with a linear color space and attach an <doc://com.apple.documentation/documentation/QuartzCore/CAEDRMetadata> object defining how the system should tone map the video content.

The code below creates a Metal layer with an extended linear BT.2020 color space and metadata that applies an HDR10 tone mapping based on the reference display.

```swift
let metalLayer = CAMetalLayer()
metalLayer.wantsExtendedDynamicRangeContent = true
metalLayer.pixelFormat = .rgba16Float

let name = CGColorSpace.extendedLinearITUR_2020
metalLayer.colorspace = CGColorSpace(name: name)

let edrMetadata = CAEDRMetadata(minLuminance: 0.5, maxLuminance: 1000, opticalOutputScale: 100)
metalLayer.edrMetadata = edrMetadata
```

Your rendering code needs to generate pixel values consistent with the EDR metadata object. For example, in the above code, the `opticalOutputScale` was set to `100`, so a pixel value of `1.0` corresponds to `100` nits. For more information, see <doc://com.apple.documentation/documentation/QuartzCore/CAEDRMetadata>.

---

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)