SCNView shows pale textures

Hi guys,


I am creating MTL Textures from CIImages. Everything is sRGB, but when it shows up in Scene Kit it looks white too pale, like the data is used as RGB.

I am using no lights nothing in the scene, it's purely a scene with SCNPlanes having the textures as diffuse material and a camera that is it. No lights nothing.


Any Ideas what I can do to get a normal representation?
(Below a picture of the CIImage in the small window and in SCNView




All the best

Christoph


I can convert my sRGB CIImage into an RGB Image before I used it as MTLTexture, BUT where is the proof that I should do so? How can I know this is compatible with all hardware and future and past macOS version? This is a "works for me" solution wich I don't want to ship :-(

Do the CIImages have a colorspace, or are they just sRGB data? If there's a colorspace, is it preserved through the conversion to textures?

I had the same problem with you. As my texture's data is in RGB format, and SCNView's colorPixelFormat is sRGB, then the output looks pale. my solution is


material.diffuse.contents = [rgbTexture newTextureViewWithPixelFormat:MTLPixelFormatBGRA8Unorm_sRGB];


So, I think your texture's data is actually in RGB format, not sRGB format, so you should set its pixelFormat to MTLPixelFormatBGRA8Unorm. Then to avoid the color conversion from RGB to sRGB, you set the material's contents a new texture which treats the data as sRGB.

This will turn the pale color output from a MTLTexture back to normal saturation. Example from Xcode default Metal project at line 178 in Renderer.swift, I've added an SCNView to my Storyboard for testing the output in the scnView.

 if let texture = renderPassDescriptor.colorAttachments[0].texture { scnView.scene?.background.contents = texture.makeTextureView(pixelFormat: .bgra8Unorm_srgb) }

SCNView shows pale textures
 
 
Q