Hi
I am working on color handling in my Metal app. I tried to understand what is said in WWDC2016 Session 605 about wide color but apparently failed. This screenshot shows the problem: I have dropped few drops of "Maraschino", "Tangerine", "Lemon" and "Lime" NSColorPanel colors. While they may appear similar, they really aren't same. Just have a look at Digital Color Meter values for "Tangerine" color in my app. It shows R: 98% G: 68% B: 3%. When I point Color Meter to little square on the left of "Tangerine" name in NSColorPanel it shows R: 100%, G: 50% B: 0%.
I set colorspace for Metal layer:
NSColorSpace * colorSpace = [ NSColorSpace extendedSRGBColorSpace ];
[ metalLayer setColorspace: [ colorSpace CGColorSpace ] ];
[ metalLayer setPixelFormat: MTLPixelFormatBGRA8Unorm_sRGB ];Take color out of NSColorPanel:
NSColor * currentColor = [ [ NSColorPanel sharedColorPanel ] color ];
currentColor = [ currentColor colorUsingColorSpaceName: NSCalibratedRGBColorSpace ];
tank->setColor(
[ currentColor redComponent ],
[ currentColor greenComponent ],
[ currentColor blueComponent ],
[ currentColor alphaComponent ]
);Color is then passed (as 3 floats, I ignore alpha component) to shader rendering to MTLPixelFormatRG11B10Float texture. Texture in question is then rendered to MTLPixelFormatBGRA8Unorm_sRGB drawable. And this is what I get.
I tried experimenting with various colorspace name combinations in both Metal layer and NSColor conversion. Best I was able to produce was result as above (or far worse). What I am doing wrong?
Thanks in advance
Michal