Hello, I’ve noticed in most of the samples the MTKView
default pixel format of .bgra8Unorm
is used with the colorspace of nil (which means no color matching by the compositor). In contrast The official Metal examples from all set MKTView
colorPixelFormat
to .bgraunorm8_srgb
This results is that the samples render darker than I believe is intended because most displays are natively an sRGB format and the lack of color matching means the linear color space used in the samples is being treated as sRGB values by the display. E.g. a value of .5 is relatively bright in linear space but darker in sRGB space.
I recommend one of two things to improve how the samples look:
- set
MTKView
colorPixelFormat
to.bgraunorm8_srgb
like Apple does in their examples, or - set
MTKView
colorspace
toCGColorSpace(name: CGColorSpace.linearSRGB)
so that the compositor know what space your output is in and can handle converting it to whatever the display expected.
(1) works well enough in most cases, but I believe (2) is technically more correct and can also pair well with (1) in more advanced use cases.
Compare these screenshots from the deferred rendering chapter. the left is from the default sample and the right is with colorspace set to linear:
Viewing the train model in the Xcode editor makes me think it is not intended to be so dark:
Thoughts?