love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.7k stars 384 forks source link

WCG/HDR color space support #1877

Open shakesoda opened 1 year ago

shakesoda commented 1 year ago

It'd be really nice to have access to wider color gamuts than sRGB, particularly of interest being display p3, bt2020, bt2100 (i.e. bt2020 + pq transfer function, aka hdr10). API-wise I'd just like to be able to request a color space (preferably not only at window creation time, but whenever!) and query the one the surface is actually using later, so I can use the appropriate render path. It might be worth including conversion functions in love.math and shaders for linear sRGB <-> display p3/rec2020 (essentially just a mat3 mul) and PQ curve (forward + inverse). It's useful to be able to query display nominal (SDR white) and peak luminance values for HDR, but these things can be handled on user-side too, so it's not a prerequisite.

on Metal at least the configuration for rec2100/hdr is pretty straightforward, just needs bgr10a2unorm backbuffer with wantsExtendedDynamicRangeContent flag set and color space ITUR_2100_PQ. On Vulkan the surface color space can be set to HDR10_ST2084_EXT.

I believe it's useful for all of them larger than sRGB to bump the backbuffer color depth to at least bgr10a2.

slime73 commented 1 year ago

I think (unless I'm misunderstanding the purpose) this SDL feature request would be helpful for that: https://github.com/libsdl-org/SDL/issues/6587

shakesoda commented 1 year ago

Yes, that'd be very useful, without that you need to make some assumptions by default and offer some manual knobs for the users' display for appropriate HDR brightness - games do this, but it's a bit inconvenient.