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.
Show the code float16 context, CSS colours above 1.0, a multiply pass
- The context. A 2D context with 16-bit float pixels in Display P3, and extended tone mapping where the browser accepts the option.
- The CSS route. Colours whose components are multiplied by a custom property.
- The markup.
data-glowmarks the two elements that the canvas raises. - On
paint. Draw the panel, raise the marked elements, then apply the chosen view. - 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.
- 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. - The WebGPU route: the target. An
rgba16floatcanvas in Display P3 with extended tone mapping. - 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.
- The WebGPU route: one frame. Upload the element, then one render pass.
- The canvas route. A
multiplyfill 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
- In Chromium 157 a float16 Display P3 2D canvas keeps CSS colour values above 1.0 through
drawElementImage(): backgrounds, text, borders, outlines, gradients,box-shadowandtext-shadowblur, and relative colours scaled withcalc().color(display-p3 3 3 3)reads back as 3.0. color(srgb-linear 4 4 4)reads back as 1.82 because the readback is in the canvas's encoded space: 4.0 linear is 1.82 after the sRGB transfer curve. It isn't a tone curve or a limit.rgb()andoklch()values above white clamp to 1.0. Onlycolor()with a predefined space carried values above 1.0.- A CSS
filter(evenblur(0)) ormix-blend-modeon the element clamps its picture to 1.0.opacity,mask,clip-pathand transforms do not. - On the canvas side,
source-overandmultiplyfills, canvas gradients, shadows of fills andputImageData()keep values above 1.0.lighter,screen,ctx.filter, a shadow ondrawElementImage()anddrawImage()of another float16 canvas clamp to 1.0. A bloom that blurs a copy of the canvas is therefore not possible in 2D. - WebGL and WebGPU don't receive the values.
texElementSubImage2D()raisesINVALID_OPERATIONfor an RGBA16F texture, anddrawElementImageToTexture()into anrgba16floattexture stores 1.0 for a CSS value of 3.0. On those routes a shader has to decide which pixels to raise. toneMapping: { mode: 'extended' }is accepted by the 2D context and reported back asstandardin Chromium 157 without the experimental features flag. The line under the controls prints what this browser reports.- On Chrome 159 on an Android phone,
getImageData()withpixelFormat: 'rgba-float16'loses the float16 2D context, and every other float16 context on the page with it. The first version of the page read back every 1.5 seconds and was lost every 1.5 seconds. With readback on a button, the canvas was lost "right after a float readback" when the map view was chosen. Drawing alone didn't lose it. After such a loss the page now starts a new float16 canvas and switches readback and the map view off on that device. - That phone reports
dynamic-range: high. - On that phone the word in this page's strip (15 pixel letters at 4.0 on 1.0) couldn't be read, with tone mapping
standard, withextended(experimental features flag on) or withdynamic-range-limit: no-limit. - Values above 1.0 do reach that phone's screen through HTML-in-canvas. On the reduced case, bars of 1.0 and 4.0 were seen in a plain float16 2D canvas, in a WebGPU canvas, in a drawable canvas drawn with
fillRect(), and in a drawable canvas whose picture is an element drawn withdrawElementImage(). A CSS white box beside them showed no bars. So the word that couldn't be read in this page's strip was a weak test, not a clamp: the strip now has bars as well. - A WebGPU canvas configured
rgba16floatwithtoneMapping: { mode: 'extended' }reportsextendedwithout a flag in Chromium 157. The page's shader raises an uploaded element to 4.0 in such a target (live check). Not verified: whether that route is shown brighter than white on the phone. "Use a WebGPU canvas" and the strip answer it on the device that opens the page.