Is it possible to render an MTKView in different color spaces? For example, if I want to render it in CMYK, is there a way to adjust the colors on every frame to that colorspace before presenting it on the screen, or is that something that needs to be handled in a shader?
Render MTKView with different Colorspace
MTKView
has a colorspace
property. And to paraphrase Apple documentation :
The default value is nil, indicating that the rendered content isn’t color-matched. If you set this to a different color space, Core Animation performs any necessary color transformations when compositing the view’s contents.
Hi iPerKard, I would recommend switching to using CAMetalLayer
for your use case. MTKView
wraps a CAMetalLayer
but does not expose all advanced features. CAMetalLayer
gives you more control and allows you to set the colorspace
property on both macOS and iOS.
I do see it on MTKView
, however it seems to behave oddly. If I have my MTKView colorPixelFormat
to the default 'bgra8Unorm` (which should render to the drawable in linear color space) but set 'colorspace' to 'CGColorSpace.sRGB' the output is the same as if is 'nil'. I expected it to engamma my MTKView's output for compositing.