Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.12k stars 513 forks source link

Linear format when using sRGB #163

Closed oierlauzi closed 4 years ago

oierlauzi commented 4 years ago

When creating the swap-chain, a VK_FORMAT_B8G8R8A8_UNORM format (linear) is used besides an sRGB nonlinear colorspace. As stated in the documentation nonlinear color-spaces must have the appropriate EOTF applied before its presentation. As in this case, this transfer function is not applied, there is a slight color incorrection (interpreting linear RGB data as non-linear RGB data). Therefore, I think its better to use a VK_FORMAT_B8G8R8A8_SRGB format, so that the transfer function is applied automatically by Vulkan

Overv commented 4 years ago

Are you sure about this? If I use the SRGB format then the texture looks wrong (different from how it looks in image editors). Is that because the texture loading also needs to be changed?

oierlauzi commented 4 years ago

Yes, you're right. If the texture is encoded as SRGB and then interpreted as linear RGB, both errors cancel out, so there isn't any problem. In most cases this will be OK, and it will be more efficient, as the TMU does not have to do the RGB<->SRGB conversion. However if there is any blending at the scene, color mixing will be done incorrectly

Overv commented 4 years ago

Alright, I'll correct this in the tutorial as soon as possible.