Open mvaligursky opened 9 months ago
its not necessarily srgb though right? https://ccameron-chromium.github.io/webgl-examples/p3.html. but I guess this would actually help here as we're letting the hardware do it
True, but until we implement https://github.com/playcanvas/engine/issues/5287, it's sRGB. Handling P3 is part of that issue.
Related Chromium issue I created exploring the sRGB in WebXR: https://partnerissuetracker.corp.google.com/issues/352345526?pli=1
conclusion regarding WebXR, from the issue above:
The mechanism for specifying a texture format for WebXR is the Layers API, which is not yet supported by Chrome but does have support in the Meta Quest browser. WebXR is not compatible with buffers allocated by drawingBufferStorage.
https://github.com/playcanvas/engine/pull/6838 implements support for sRGB framebuffer on WebGPU, but also support for sRGB render target on all platforms (just not the default framebuffer on WebGL), allowing linear rendering.
Update on this.
displayFormat
member of createGraphicsDevice
options
The default framebuffer WebGL uses for rendering is RGB(A)8 buffer. The values written to it are expected to be in the display color space, which typically means sRGB. As this framebuffer is created by the canvas, we have no control over it, and it is not created with sRGB (EXT_sRGB) flag. Meaning the shader writing to it needs to manually encode values from linear to sRGB space.
LDR rendering
HDR rendering
References: https://github.com/KhronosGroup/WebGL/issues/2474 https://github.com/mrdoob/three.js/issues/23019 https://stackoverflow.com/questions/51032480/how-do-you-implement-a-gamma-correct-workflow-in-webgl2 https://groups.google.com/g/angleproject/c/5ITMg4_m8Ug https://github.com/playcanvas/engine/issues/5287