Wrong colours when rendering SKTexture

I am generating an SKTexture with a GKNoiseMap. When I look at the texture in a swift playground, it has the expected colours. But when I apply the texture to a material and render it in a SCNView, the colours are different (colours appear too bright). What am I doing wrong?

import GameKit
import SpriteKit
import PlaygroundSupport

let source = GKPerlinNoiseSource()
let noise = GKNoise(source)
noise.gradientColors = [-1: #colorLiteral(red: 0.7537418008, green: 0.4404714704, blue: 0.2776784003, alpha: 1) , 1: #colorLiteral(red: 0.2008953691, green: 0.186568588, blue: 0.2595013976, alpha: 1)]
let map = GKNoiseMap(noise, size: vector2(1.0, 1.0), origin: vector2(0.0, 0.0), sampleCount: vector2(Int32(256), Int32(256)), seamless: false)
let texture = SKTexture(noiseMap: map )


let ball = SCNSphere(radius: 1)
let materials = SCNMaterial()
materials.diffuse.contents = texture
ball.materials = [materials]
var node = SCNNode(geometry: ball)


var sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
var scene = SCNScene()
sceneView.scene = scene
PlaygroundPage.current.liveView = sceneView

var cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = SCNVector3(x: 0, y: 0, z: 2.1)
scene.rootNode.addChildNode(cameraNode)
scene.rootNode.addChildNode(node)


Too bright ?

How does this translate in color rob and alpha ?
Use Digital color meter to compare both.

I've noticed this as well and filed a bug report to Apple exactly 6 months ago, still without answer. It is easily reproducible with this code:

        let url = Bundle.main.url(forResource: "art.scnassets/texture.png", withExtension: nil)!
        plane1.firstMaterial!.diffuse.contents = url.path
        let node1 = SCNNode(geometry: plane1)
        node1.position.x = -5
        scene.rootNode.addChildNode(node1)

        let plane2 = SCNPlane(width: 10, height: 10)
        plane2.firstMaterial!.diffuse.contents = SKTexture(image: NSImage(byReferencing: url))
        let node2 = SCNNode(geometry: plane2)
        node2.position.x = 5
        scene.rootNode.addChildNode(node2)

I've noticed this as well and filed a bug report to Apple

What was your bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Since this issue is still happening 3 years later on macOS 14.6.1, I stumbled again on this post and I see only now that you asked for the bug number, but unfortunately I didn't subscribe to this post back then and wasn't notified of your reply. It's FB8979522.

Wrong colours when rendering SKTexture
 
 
Q