Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions source/MaterialXView/RenderPipelineMetal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,19 @@
{
[renderpassDesc.colorAttachments[0] setTexture:MTL(currentFramebuffer())->getColorTexture()];
}
// The Metal framebuffer stores linear color values (MTLPixelFormatRGBA16Float).
// macOS applies gamma correction when displaying linear float values, so the sRGB
// background color must be converted to linear before being set as the clear color.
// On OpenGL (Windows), the background is stored directly in a non-linear framebuffer
// and no conversion is needed.
mx::Color3 bgLinear = mx::Color3(_viewer->m_background[0],
_viewer->m_background[1],
_viewer->m_background[2]).srgbToLinear();

[renderpassDesc.colorAttachments[0] setClearColor:MTLClearColorMake(
_viewer->m_background[0],
_viewer->m_background[1],
_viewer->m_background[2],
bgLinear[0],
bgLinear[1],
bgLinear[2],
_viewer->m_background[3])];
[renderpassDesc.colorAttachments[0] setLoadAction:MTLLoadActionClear];
[renderpassDesc.colorAttachments[0] setStoreAction:MTLStoreActionStore];
Expand Down