Search code examples
iosswiftscenekitmetal

SceneKit background too bright when applying camera frame MTLTexture as a background


Washed out SceneKit texture

I'm trying to convert a camera frame to a MTLTexture and then use it as a SceneKit background. The texture is created successfully, and looks like it should when inspecting it. However, when I set the following:

scene.background.contents = texture

It appears too bright / washed out. Any ideas how to fix this?

Update 1: Gist here


Solution

  • It turns out what was causing the washed out effect in the texture was the pixel format. It should be .bgra8Unorm_srgb (not .bgra8Unorm).