facebook/igl

Why Vulkan demo color is diffrent from opengl?

vinsentli opened this issue · 3 comments

Why in the demo , the cube color on vulkan is different from opengl ?
I use IGL in my demo, the vulkan color is also different from opengl and metal.

60b68572919ca5dc80550d53a8d3ed4a
f3d3bd9f928365aaee0fd6232de5e19d
企业微信截图_26ed30c0-3c4c-4ee1-84d8-cb96d0636de4
企业微信截图_c681b166-4354-4543-b01e-373482c1cb6f

more info: @corporateshark
if i force the fragment shader ,use a alpha color , for example :
out_FragColor = vec4(1, 0, 0, 0.5);

and i open the blend mode:
graphicsDesc.targetDesc.colorAttachments[0].blendEnabled = true;
graphicsDesc.targetDesc.colorAttachments[0].srcRGBBlendFactor = igl::BlendFactor::One;
graphicsDesc.targetDesc.colorAttachments[0].srcAlphaBlendFactor = igl::BlendFactor::One;
graphicsDesc.targetDesc.colorAttachments[0].dstRGBBlendFactor = igl::BlendFactor::OneMinusSrcAlpha;
graphicsDesc.targetDesc.colorAttachments[0].dstAlphaBlendFactor = igl::BlendFactor::OneMinusSrcAlpha;

the cube color on vulkan is also different from opengl.

46db36337897d8b2df6223892385a466
d97e46a2dcb962c0d9fc7a6b57c9f44b

Should be fixed via 813589f.

Hi @vinsentli
so just to explain what this is:

igl::ColorSpace::PASS_THROUGH <-- on vulkan this will communicate with the OS color management to tell it your incoming color space (usually sRGB) and the color management will take care of converting the data from sRGB->Your Display

This feature doesn't seem to exist on OpenGL so using PASS_THROUGH bypasses the color management and pretty much acts like OpenGL which gives them both parity in theiry color output.

On Metal, we've had to do this to achieve the same thing: https://github.com/facebook/igl/blob/main/shell/mac/ViewController.mm#L187

If this doesn't help you, please let me know how you go about running the demo (I'm not very familiar with the open source version) and I'll try to reproduce and see where things aren't the same.