HDR interface: elements brighter than white

The panel is HTML drawn into a 2D canvas whose pixels are 16-bit floats in Display P3. In that canvas 1.0 is standard white and a value above 1.0 is brighter than white on an HDR screen. The badge, the focus ring and the end of the progress bar get their values from CSS colours with components above 1.0. The Deploy button and the green dot are ordinary sRGB colours that the canvas multiplies after it has drawn them. Press Deploy, tab to the text field, and move the headroom slider.

Build 4823

This text is at 0.9 of standard white. Only the marked parts go higher.

The white strip holds a word and bars written above 1.0. If you can see them, this screen shows the extra range.

 

 

Show the code float16 context, CSS colours above 1.0, a multiply pass
  1. The context. A 2D context with 16-bit float pixels in Display P3, and extended tone mapping where the browser accepts the option.
  2. The CSS route. Colours whose components are multiplied by a custom property.
  3. The markup. data-glow marks the two elements that the canvas raises.
  4. On paint. Draw the panel, raise the marked elements, then apply the chosen view.
  5. The fallback. If the float context is lost after a readback, the panel moves to a new float16 canvas and readback is switched off. After any other loss the new canvas is 8-bit.
  6. The WebGPU route: the switch. A new canvas for the panel, the device from shared/backend.js, and the list of boxes for the shader.
  7. The WebGPU route: the target. An rgba16float canvas in Display P3 with extended tone mapping.
  8. The WebGPU route: the shader. The element arrives as an 8-bit picture. The shader multiplies the marked boxes, adds the halos and draws the map view with no readback.
  9. The WebGPU route: one frame. Upload the element, then one render pass.
  10. The canvas route. A multiply fill over the element's box and a halo from a canvas shadow.

How it works

The canvas context is created with colorType: 'float16' and colorSpace: 'display-p3'. drawElementImage() then keeps CSS colour values above 1.0 that the element's own styles ask for. The page uses two routes to get such values, because each has limits.

CSS route. The badge, the focus ring, the bar and the strip use color(display-p3 …) with components multiplied by --headroom. The blur of a box-shadow in such a colour also keeps its values, so the bloom around the badge is CSS. A CSS filter or mix-blend-mode on the element clamps it to 1.0.

Canvas route. The Deploy button and the dot have sRGB colours. After the draw, the canvas fills their rounded boxes with a grey above 1.0 using the multiply operation, which scales what is there. The halo is the shadow of an off-canvas fill. lighter, ctx.filter and a shadow on drawElementImage() itself all clamp to 1.0, so they aren't used. The band of light after a deploy is one more multiply fill with a gradient.

Views. A standard screen clips everything above 1.0 to white. "Exposed down" multiplies the whole canvas by 1 ÷ headroom, so the brightest value lands on white and the rest of the panel goes dark in proportion. "Map" reads the float pixels back and colours each one: grey for 1.0 or under, yellow through red to magenta for 1.0 up to the headroom. The page picks "As stored" when the screen reports dynamic-range: high and "Exposed down" otherwise.

WebGPU route. "Use a WebGPU canvas" moves the panel into a canvas configured as rgba16float, Display P3, toneMapping: { mode: 'extended' }. drawElementImageToTexture() stores at most 1.0, so the CSS colours are set back to headroom 1 and a shader does all the raising: it multiplies the boxes of the badge, the bar, the dot and the Deploy button, raises the full-white pixels of the word in the strip, and adds the halos. The map view is drawn by the same shader, so it needs no readback. The focus ring isn't raised on this route. The button is there because the 2D float canvas showed no extra brightness on my phone.

Live checks

These run on their own small canvases in the corner of the window. They wait for a tap, because they read float pixels back and open a WebGL context and use the WebGPU device. On my phone (Chrome 159, Android) a float readback loses every float16 context on the page, so running them there also replaces the demo's canvas. Rows marked as expected failures record what the API clamps or refuses in the browser that wrote this page.

Findings