hdr-canvas version 0.1.0 released…
One result of my work with HDR content in the browser is an NPM module, which was also used to create the posts in this blog.
However, about a year has passed since the first versions and the browser API was rather experimental at that time. A lot has changed since then - one of the examples had even stopped working in the meantime: The most important change concerns the change from Uint16 to Float16 as 16 bit pixel data type for HDR.
Since browsers are developing rapidly and the use of older browsers is not recommended for security reasons (even if some people see it differently), no downward compatibility is to be expected.
In addition to the necessary adjustments, the new version also offers improvements in the area of documentation and examples.
The code can be found on GitHub and NPM.
The release notes
Introduction
Since the last release many areas of handling HDR contet in the browser have evolved.
Most notably is certainly the introduction of the Float16Array in the ImageData construtor:
- The WhatWG spec, MDN and [BCD](new ImageData(new Float16Array(4), 1, 1, {pixelFormat:“rgba-float16”})) have been updated accordingly. You can test your own browser using
new ImageData(new Float16Array(4), 1, 1, {pixelFormat:"rgba-float16"}).- Still open in Firefox
- Hidden behind flag in Safari
- Chromium has implemented it starting with 137: **The
ImageDataconstructor only accepptsFloat16Arrayinstead ofUint16Array. This makes older versions of this modue obsolute, since they targeted the chromium specific solution. - If Safari enables it by default it will be also in the Typescript DOM types
As @reitowo pointed out, there has been a change to the getContext("2d") method. The key pixelFormat has been replaced by colorType.
In parallel threre have been changes to the UltraHDR image format, especially te encoding of gain map matadata. While this used to be don in XMP it’s now done according to ISO 21496-1. This ihas been adopted by Google and Apple in newer OS versions like Android 15 and iOS 18 to avoid cross-platform fragmentation. The UltraHDR Library has already changed to ussin the ISO format as default.
Currently the ThreeJS UHDR loader doesn’t know how to handle this change, see mrdoob/three.js#32293.
Key Changes & New Features
- Better support for official Web-APIs
- Use
Float16Arrayinstead ofUint16Array - Use the correct option for initializing 2D canvas context
- Use
Improved Documentation
The documentation have been greatly improved, there is now also a site including the examples and API docs.
Examples
The examples from this blog are now part of this repository:
tests/site/assets/ts/hdr-three.js.ts- Three JS with HDR texturetests/site/assets/ts/image-slider.ts- Generated HDR contenttests/site/assets/ts/main.ts- feature detection
These example are also avalable on the new documentation site
Advocacy
Since the changes by the WhatWG weren’t picked up already there had to be some Issues in the relevant repos to be raised.