ColorWeb-CG icon indicating copy to clipboard operation
ColorWeb-CG copied to clipboard

WebGPU, WCG and HDR

Open tidoust opened this issue 3 years ago • 7 comments

The newly created GPU for the Web Working Group develops the WebGPU API, a more modern version of WebGL (raised in #2). The draft spec does not mention "color spaces". Possibly relevant bits of info:

tidoust avatar Aug 25 '20 09:08 tidoust

Thanks for raising this, @tidoust

Agree that no mention of the colorspace is a big issue. Is it assumed to be the native display colorspace, so you get different colors on different screens? Surely not.

However, one nice thing I noticed straight away

dictionary GPUColorDict {
    required double r;
    required double g;
    required double b;
    required double a;
};
typedef (sequence<double> or GPUColorDict) GPUColor;

so compared to Canvas or the CSS Object Model or the HTML "simple color" (all of which are still stuck in 8 bits per component) using double is a big win there. Enough space for the precision requirements of WCG and probably, depending on how it is defined, HDR as well.

But it does need to be defined:

  • what is the range? Nominal 0 to 1 for SDR?
  • what is the colorspace (rgbw chromaticities)?
  • what is the transfer function ( gamma-encoded or linear)?
  • if media (diffuse) white is 1.0 1.0 1.0 then where is highlight white?

How do those colors get mapped to eventual display coordinates for SDR and for HDR displays?

svgeesus avatar Aug 29 '20 16:08 svgeesus

The section in the report needs to be expanded.

palemieux avatar Jan 11 '21 21:01 palemieux

I expect that https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md will be updated to include this soon (some preliminary notes are at https://docs.google.com/presentation/d/1rvCYKq6T4koS0yRd_C91se6v1h2YJF32pPHtPtBo-R8/edit?usp=sharing).

ccameron-chromium avatar Jan 26 '21 09:01 ccameron-chromium

The presentation today by @ccameron-chromium was very informative regarding the "raw pixel values, do conversion yourself" aspect of WebGPU (and WebGL) compared to the "signal the colorspace for each command, the whole thing is color managed" aspect of 2D Canvas.

svgeesus avatar Jan 26 '21 23:01 svgeesus

Updating this with the planned API. WebGPU has the GPUSwapChainDescriptor dictionary currently

dictionary GPUSwapChainDescriptor {
    required GPUDevice device;
    required GPUTextureFormat format;
    GPUTextureUsageFlags usage = 0x10;  // GPUTextureUsage.RENDER_ATTACHMENT
    GPUCanvasCompositingAlphaMode compositingAlphaMode = "opaque";
    GPUExtent3D size;
};

We would just add a PredefinedColorSpace to this.

ccameron-chromium avatar Jul 19 '21 20:07 ccameron-chromium

Has there been any updates on this?

DamonPalovaara avatar Mar 24 '23 02:03 DamonPalovaara

I am working on a revised HDR Canvas strawman based on the feedback I have seen so far:

https://github.com/w3c/ColorWeb-CG/pull/95

The revised proposal focuses on adding baseline support for HDR imagery to Canvas, without precluding future optimizations and extensions. It does so by adding support for HLG and PQ color spaces (which are in widespread use) and 16-bit float samples (which are necessary for HDR).

I would think the same approach could apply to WebGPU (support for HLG and PQ color spaces and bitdepth > 8 bits).

palemieux avatar Mar 24 '23 04:03 palemieux