简体   繁体   English

什么是 vulkan 颜色空间?

[英]What is vulkan color space?

During creation of vulkan swapchain i've stuck at imageColorSpace and imageFormat parameters in VkSwapchainCreateInfoKHR.在创建 vulkan 交换链期间,我一直停留在 VkSwapchainCreateInfoKHR 中的 imageColorSpace 和 imageFormat 参数。 I do understand that imageFormat is how actual pixel is encoded and stored in memory and if it color isn't linear then vulkan converts it to such during sampling and writing operations in shaders.我确实了解 imageFormat 是实际像素如何编码和存储在 memory 中,如果它的颜色不是线性的,那么 vulkan 在着色器中的采样和写入操作期间将其转换为这种颜色。 My hardware supports only VK_COLOR_SPACE_SRGB_NONLINEAR_KHR which i suppose means that color in swapchain image should be stored in a non-linear fashion but VK_FORMAT_B8G8R8A8_SRGB results in gamma 0.44 corected colors, while VK_FORMAT_B8G8R8A8_UNORM works fine.我的硬件仅支持 VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,我认为这意味着交换链图像中的颜色应该以非线性方式存储,但 VK_FORMAT_B8G8R8A8_SRGB 导致 gamma 0.44 校正 colors,而 VK_FORMAT_B8G8R8A8_UNORM 工作正常。 How imageFormat relates to imageColorSpace and what does imageColorSpace specify? imageFormat 与 imageColorSpace 的关系以及 imageColorSpace 指定了什么?

Vulkan is colorspace agnostic. Vulkan 与色彩空间无关。 Though at some point before the bits are converted to photons, the colorspace must become known.尽管在比特转换为光子之前的某个时刻,色彩空间必须是已知的。 That's why it is asked for in the swapchain creation.这就是为什么在交换链创建中需要它。

imageFormat specifies what the image format is (same as it does in vkCreateImage() ). imageFormat指定图像格式是什么(与vkCreateImage()中的相同)。 imageColorSpace is how the swapchain\display interprets the values when the image is presented. imageColorSpace是显示图像时 swapchain\display 解释值的方式。

So if you have UNORM , that means unspecified color space, and they are good ol' raw bits.所以如果你有UNORM ,这意味着未指定的色彩空间,它们是很好的原始位。 Or rather it means that you are in charge of the color space (if the image even stores color, and not something else entirely).或者更确切地说,这意味着您负责色彩空间(如果图像甚至存储颜色,而不是完全存储其他东西)。 If you use VK_COLOR_SPACE_SRGB_NONLINEAR_KHR with *_UNORM , it means the swapchain takes your bits and it is gonna assume it is already SRGB when presented.如果您将VK_COLOR_SPACE_SRGB_NONLINEAR_KHR*_UNORM一起使用,则意味着交换链会占用您的位,并且在出现时会假定它已经是 SRGB。 If it is *_SRGB , then that is no different for the swapchain itself, but what happens is that the created VkImage s are *_SRGB format, which means when you use them then the color is being linearized for you (same as would happen if you created a non-swapchain VkImage ).如果它是*_SRGB ,那么交换链本身没有什么不同,但是会发生什么是创建的VkImage*_SRGB格式,这意味着当使用它们时,颜色会为您线性化(与如果您创建了一个非交换VkImage )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM