mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-09 01:01:05 +00:00
Fix washed out colors in Vulkan HDR mode
This commit is contained in:
parent
d2f8c57136
commit
37039721bd
2 changed files with 9 additions and 14 deletions
|
@ -250,7 +250,7 @@ void VulkanSwapChain::CreateViews()
|
||||||
|
|
||||||
bool VulkanSwapChain::IsHdrModeActive() const
|
bool VulkanSwapChain::IsHdrModeActive() const
|
||||||
{
|
{
|
||||||
return swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT || swapChainFormat.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
|
return swapChainFormat.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanSwapChain::SelectFormat()
|
void VulkanSwapChain::SelectFormat()
|
||||||
|
@ -276,16 +276,6 @@ void VulkanSwapChain::SelectFormat()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For older drivers that reported the wrong colorspace
|
|
||||||
for (const auto &format : surfaceFormats)
|
|
||||||
{
|
|
||||||
if (format.format == VK_FORMAT_R16G16B16A16_SFLOAT && format.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT)
|
|
||||||
{
|
|
||||||
swapChainFormat = format;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &format : surfaceFormats)
|
for (const auto &format : surfaceFormats)
|
||||||
|
|
|
@ -31,9 +31,14 @@ vec4 Dither(vec4 c)
|
||||||
return vec4(floor(c.rgb * ColorScale + threshold) / ColorScale, c.a);
|
return vec4(floor(c.rgb * ColorScale + threshold) / ColorScale, c.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 sRGBtoLinear(vec4 c)
|
vec3 sRGBtoLinear(vec3 c)
|
||||||
{
|
{
|
||||||
return vec4(mix(c.rgb / 12.92, pow((c.rgb + 0.055) / 1.055, vec3(2.4)), step(c.rgb, vec3(0.04045))), c.a);
|
return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(vec3(0.04045), c));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 sRGBtoscRGBLinear(vec3 c)
|
||||||
|
{
|
||||||
|
return pow(c, vec3(2.2)) * 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 ApplyHdrMode(vec4 c)
|
vec4 ApplyHdrMode(vec4 c)
|
||||||
|
@ -41,7 +46,7 @@ vec4 ApplyHdrMode(vec4 c)
|
||||||
if (HdrMode == 0)
|
if (HdrMode == 0)
|
||||||
return c;
|
return c;
|
||||||
else
|
else
|
||||||
return sRGBtoLinear(c);
|
return vec4(sRGBtoscRGBLinear(c.rgb), c.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
Loading…
Reference in a new issue