gkv311 / sview

Stereoscopic media player
GNU General Public License v3.0
93 stars 34 forks source link

Add deep color (30-bit) support #105

Closed gkv311 closed 2 years ago

gkv311 commented 2 years ago

30-bit deep color (10-bit per RGB component) enhances color precision without extending color space boundaries (e.g. it is still sRGB by default). This help eliminating banding artifacts due to insufficient precision of 24-bit true color (8-bit per component) - which is most noticeable on pure gradients (like black -> white) as just 256 gray values becomes visible.

On Linux platform and compatible configuration (capable monitor + GPU + driver) 30-bit deep color can be enabled following tutorial by creating the file /etc/X11/xorg.conf.d/30bpp.conf:

Section "Screen"
  Identifier "Screen Name"
  DefaultDepth 30
EndSection

After file modifications, X server can be restarted by this command

sudo systemctl restart display-manage

On Linux platform, GLX and EGL interfaces return deep color Visual by default, so that sView automatically uses it without modifications for window content. However, offscreen OpenGL buffers (FBOs) created for stereoscopic rendering still use RGBA8 texture formats leading to color precision losses. StGLStereoFrameBuffer should be modified to use RGB10_A2 texture format (or with higher precision).

On Windows platform, 30-bit deep color can be enabled in GPU driver settings on compatible configurations. It seems that Windows itself doesn't expose this option (there is only "Use HDR" which has different meaning, although it might also activate higher color precision). WGL will still return 24-bit pixel formats by default, so that OpenGL application (sView) should be modified to request deep color format explicitly.

image image

gkv311 commented 2 years ago

Merged with 0c1a724cf9c3eb606405822803f893cb97316c82.

The simplest way to verify deep color is to open samples from openexr project like TestImages/GrayRampsDiagonal.exr. sView should show "RGB30 A2" format in About dialog on success. image

RGB24 depth (banding is visible): photo_2022-01-18_22-07-25

RGB30 depth (no banding): photo_2022-01-18_22-07-30