hdr-canvas 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hdr-canvas.js +289 -8
- package/dist/hdr-canvas.js.map +1 -1
- package/dist/hdr-canvas.min.js +1 -1
- package/dist/hdr-canvas.min.js.map +1 -1
- package/dist/hdr-canvas.umd.js +289 -8
- package/dist/hdr-canvas.umd.js.map +1 -1
- package/docs/release-notes-0.1.0.md +6 -6
- package/docs/release-notes-0.1.1.md +19 -0
- package/docs/release-notes-0.1.2.md +16 -0
- package/docs/release.md +13 -0
- package/package.json +15 -14
- package/scripts/check.sh +1 -0
- package/src/Float16Image.ts +20 -7
- package/src/Uint16Image.ts +1 -0
- package/src/hdr-canvas.ts +5 -2
- package/src/types/HDRCanvas.d.ts +5 -0
- package/three/HDRWebGPUBackend.js +36 -73
- package/three/HDRWebGPURenderer.js +1 -0
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
# Introduction
|
|
4
4
|
|
|
5
|
-
Since the last release many areas of handling HDR
|
|
6
|
-
Most notably is certainly the introduction of the `Float16Array` in the `ImageData`
|
|
5
|
+
Since the last release many areas of handling HDR content in the browser have evolved.
|
|
6
|
+
Most notably is certainly the introduction of the `Float16Array` in the `ImageData` constructor:
|
|
7
7
|
|
|
8
|
-
- The [WhatWG spec](https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagedataarray), [MDN](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData#syntax) and [BCD](
|
|
8
|
+
- The [WhatWG spec](https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#imagedataarray), [MDN](https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData#syntax) and [BCD](https://github.com/mdn/browser-compat-data/issues/27547)) have been updated accordingly. You can test your own browser using `new ImageData(new Float16Array(4), 1, 1, {pixelFormat:"rgba-float16"})`.
|
|
9
9
|
- Still open in [Firefox](https://bugzil.la/1958830)
|
|
10
10
|
- Hidden behind flag in [Safari](https://webkit.org/b/291196)
|
|
11
|
-
- Chromium has implemented it starting with [137](https://source.chromium.org/chromium/chromium/src/+/refs/tags/137.0.7104.0:third_party/blink/renderer/core/html/canvas/image_data.idl): \*\*The `ImageData` constructor only
|
|
11
|
+
- Chromium has implemented it starting with [137](https://source.chromium.org/chromium/chromium/src/+/refs/tags/137.0.7104.0:third_party/blink/renderer/core/html/canvas/image_data.idl): \*\*The `ImageData` constructor only accepts `Float16Array` instead of `Uint16Array`. This makes older versions of this module obsolete, since they targeted the chromium specific solution.
|
|
12
12
|
- If Safari enables it by default it will be also in the [Typescript DOM types](https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/2107)
|
|
13
13
|
|
|
14
14
|
As [@reitowo](https://github.com/reitowo) pointed out, there has been a change to the `getContext("2d")` method. The key `pixelFormat` has been replaced by `colorType`.
|
|
15
15
|
|
|
16
|
-
In parallel
|
|
16
|
+
In parallel there have been changes to the UltraHDR image format, especially the encoding of gain map metadata. While this used to be don in XMP it's now done according to ISO 21496-1. This has been adopted by Google and Apple in newer OS versions like Android 15 and iOS 18 to avoid cross-platform fragmentation. The [UltraHDR Library](https://github.com/google/libultrahdr) has already changed to using the [ISO format as default](https://github.com/google/libultrahdr/blob/main/docs/building.md).
|
|
17
17
|
|
|
18
18
|
Currently the ThreeJS UHDR loader doesn't know how to handle this change, see [mrdoob/three.js#32293](https://github.com/mrdoob/three.js/issues/32293).
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ The documentation have been greatly improved, there is now also a [site](https:/
|
|
|
29
29
|
|
|
30
30
|
## Examples
|
|
31
31
|
|
|
32
|
-
The examples
|
|
32
|
+
The examples from the blog are now part of this repository:
|
|
33
33
|
|
|
34
34
|
- [`tests/site/assets/ts/hdr-three.js.ts`](tests/site/assets/ts/hdr-three.js.ts) - Three JS with HDR texture
|
|
35
35
|
- [`tests/site/assets/ts/image-slider.ts`](tests/site/assets/ts/image-slider.ts) - Generated HDR content
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# `hdr-canvas` 0.1.1
|
|
2
|
+
|
|
3
|
+
# Introduction
|
|
4
|
+
|
|
5
|
+
Since the last release many areas of handling HDR content in the browser have evolved. This also applies for WebGPU renderings using ThreeJS
|
|
6
|
+
|
|
7
|
+
The changes in initializing a `canvas for a Rendere are described in the [explainer](https://github.com/ccameron-chromium/webgpu-hdr/blob/main/EXPLAINER.md).
|
|
8
|
+
|
|
9
|
+
The important change is the renaming from `colorMetadata` to:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
toneMapping: { mode: "extended" }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This is also reflected by the ThreeJS API so a custom HDR WebGPU Renderer and Backend aren't strictly needed anymore. They will be removed soon.
|
|
16
|
+
|
|
17
|
+
# Key Changes & New Features
|
|
18
|
+
|
|
19
|
+
- Fix ThreeJS HDR Renderer and Backend
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# `hdr-canvas` 0.1.2
|
|
2
|
+
|
|
3
|
+
# Introduction
|
|
4
|
+
|
|
5
|
+
The color scaling of `Float16Image` was off.
|
|
6
|
+
|
|
7
|
+
This is certainly the last release before the removal:
|
|
8
|
+
|
|
9
|
+
- of the ThreeJS components, they aren't needed anymore.
|
|
10
|
+
- of the Uint16Image it's outdated and only still works since Chrom(e|ium) due to backwards compatibility.
|
|
11
|
+
- the support for Chrom(e|ium) < 140
|
|
12
|
+
- of the bundle UMD build since ESM is the way to go.
|
|
13
|
+
|
|
14
|
+
# Key Changes & New Features
|
|
15
|
+
|
|
16
|
+
- Fix `Float16Image` color scaling
|
package/docs/release.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hdr-canvas",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "HDR capable HTML canvas",
|
|
5
5
|
"main": "dist/hdr-canvas.cjs",
|
|
6
6
|
"module": "dist/hdr-canvas.js",
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
"@eslint/markdown": "^7.5.1",
|
|
75
75
|
"@fontsource-utils/scss": "^0.2.2",
|
|
76
76
|
"@fontsource-variable/league-spartan": "^5.2.8",
|
|
77
|
+
"@napi-rs/canvas": "^0.1.83",
|
|
77
78
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
78
79
|
"@rollup/plugin-terser": "^0.4.4",
|
|
79
80
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
80
|
-
"@napi-rs/canvas": "^0.1.82",
|
|
81
81
|
"@types/jsdom": "^27.0.0",
|
|
82
82
|
"@types/semver": "^7.7.1",
|
|
83
83
|
"@types/three": "^0.181.0",
|
|
84
|
-
"@typescript-eslint/parser": "^8.
|
|
84
|
+
"@typescript-eslint/parser": "^8.48.0",
|
|
85
85
|
"@typescript/lib-dom": "npm:@types/web@^0.0.294",
|
|
86
86
|
"better-docs": "^2.7.3",
|
|
87
87
|
"eslint": "^9.39.1",
|
|
@@ -89,24 +89,25 @@
|
|
|
89
89
|
"globals": "^16.5.0",
|
|
90
90
|
"jsdoc": "^4.0.5",
|
|
91
91
|
"jsdom": "^27.2.0",
|
|
92
|
-
"knip": "^5.
|
|
92
|
+
"knip": "^5.70.2",
|
|
93
93
|
"pkg-types": "^2.3.0",
|
|
94
|
-
"prettier": "^3.
|
|
95
|
-
"rimraf": "^6.1.
|
|
96
|
-
"rollup": "^4.53.
|
|
97
|
-
"rollup-plugin-dts": "^6.
|
|
98
|
-
"sass": "^1.94.
|
|
94
|
+
"prettier": "^3.7.1",
|
|
95
|
+
"rimraf": "^6.1.2",
|
|
96
|
+
"rollup": "^4.53.3",
|
|
97
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
98
|
+
"sass": "^1.94.2",
|
|
99
99
|
"semver": "^7.7.3",
|
|
100
|
-
"stylelint": "^16.
|
|
100
|
+
"stylelint": "^16.26.1",
|
|
101
101
|
"stylelint-config-standard-scss": "^16.0.0",
|
|
102
|
-
"three": "^0.181.
|
|
102
|
+
"three": "^0.181.2",
|
|
103
103
|
"tslib": "^2.8.1",
|
|
104
104
|
"typescript": "^5.9.3",
|
|
105
|
-
"typescript-eslint": "^8.
|
|
106
|
-
"vite": "^7.2.
|
|
107
|
-
"vitest": "^4.0.
|
|
105
|
+
"typescript-eslint": "^8.48.0",
|
|
106
|
+
"vite": "^7.2.4",
|
|
107
|
+
"vitest": "^4.0.14"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
|
+
"@petamoriken/float16": "^3.9.3",
|
|
110
111
|
"colorjs.io": "^0.5.2"
|
|
111
112
|
}
|
|
112
113
|
}
|
package/scripts/check.sh
CHANGED
package/src/Float16Image.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { HDRImage } from "./HDRImage";
|
|
|
2
2
|
|
|
3
3
|
import Color from "colorjs.io";
|
|
4
4
|
import type { Coords } from "colorjs.io";
|
|
5
|
+
import { f16round } from "@petamoriken/float16";
|
|
5
6
|
|
|
6
7
|
import type { HDRPredefinedColorSpace, HDRImageData, HDRImagePixelCallback } from "./types/HDRCanvas.d.ts";
|
|
7
8
|
|
|
@@ -97,6 +98,7 @@ export class Float16Image extends HDRImage {
|
|
|
97
98
|
*
|
|
98
99
|
* @param {Uint8ClampedArray} pixel - An array of four 8-bit numbers (R, G, B, A).
|
|
99
100
|
* @returns {Float16Array} The converted 16-bit pixel in the `rec2100-hlg` color space.
|
|
101
|
+
* @deprecated
|
|
100
102
|
*/
|
|
101
103
|
static convertPixelToRec2100_hlg(pixel: Uint8ClampedArray): Float16Array {
|
|
102
104
|
const colorJScolorSpace = <string>Float16Image.COLORSPACES["rec2100-hlg" as HDRPredefinedColorSpace];
|
|
@@ -126,13 +128,14 @@ export class Float16Image extends HDRImage {
|
|
|
126
128
|
* @returns {Float16Array} The converted 16-bit pixel data.
|
|
127
129
|
*/
|
|
128
130
|
static convertArrayToRec2100_hlg(data: Uint8ClampedArray): Float16Array {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
131
|
+
const float16Array = new Float16Array(data.length);
|
|
132
|
+
|
|
133
|
+
for (let i = 0; i < data.length; i++) {
|
|
134
|
+
const normalizedFloat = data[i] / 255.0;
|
|
135
|
+
float16Array[i] = f16round(normalizedFloat);
|
|
134
136
|
}
|
|
135
|
-
|
|
137
|
+
|
|
138
|
+
return float16Array;
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
/**
|
|
@@ -142,7 +145,17 @@ export class Float16Image extends HDRImage {
|
|
|
142
145
|
*/
|
|
143
146
|
pixelCallback(fn: HDRImagePixelCallback) {
|
|
144
147
|
for (let i = 0; i < this.data.length; i += 4) {
|
|
145
|
-
|
|
148
|
+
const pixel = fn(this.data[i], this.data[i + 1], this.data[i + 2], this.data[i + 3]);
|
|
149
|
+
|
|
150
|
+
//TODO: Check if we should implicitly should operate on int pixel vaulues
|
|
151
|
+
/*
|
|
152
|
+
for (let i = 0; i < pixel.length; i++) {
|
|
153
|
+
const normalizedFloat = pixel[i] / 255.0;
|
|
154
|
+
pixel[i] = f16round(normalizedFloat);
|
|
155
|
+
}
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
this.data.set(pixel, i);
|
|
146
159
|
}
|
|
147
160
|
}
|
|
148
161
|
|
package/src/Uint16Image.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { HDRPredefinedColorSpace, HDRImageData, HDRImagePixelCallback } fro
|
|
|
9
9
|
* Represents an image using a `Uint16Array` for its pixel data,
|
|
10
10
|
* providing support for high dynamic range (HDR) color spaces.
|
|
11
11
|
* **Don't use this anymore, it's just here for migrating to Float16Array!**
|
|
12
|
+
* @deprecated Use Uint16Image instead
|
|
12
13
|
*/
|
|
13
14
|
export class Uint16Image extends HDRImage {
|
|
14
15
|
/** The raw pixel data stored as a `Uint16Array`. */
|
package/src/hdr-canvas.ts
CHANGED
|
@@ -15,6 +15,7 @@ export function getHdrOptions(): CanvasRenderingContext2DHDRSettings {
|
|
|
15
15
|
if (browserMajorVersion == null) {
|
|
16
16
|
console.warn(`Unsupported / untested browser (${navigator.userAgent}) detected - using more modern defaults`);
|
|
17
17
|
hdrOptions["colorType"] = "float16";
|
|
18
|
+
hdrOptions["toneMapping"] = { mode: "extended" };
|
|
18
19
|
} else {
|
|
19
20
|
if (browserMajorVersion < 134) {
|
|
20
21
|
console.warn("Older Chrome / chromium based browser detected, using older `pixelFormat`");
|
|
@@ -22,7 +23,6 @@ export function getHdrOptions(): CanvasRenderingContext2DHDRSettings {
|
|
|
22
23
|
hdrOptions["pixelFormat"] = "float16";
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
|
|
26
26
|
return hdrOptions;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -34,7 +34,10 @@ export function getHdrOptions(): CanvasRenderingContext2DHDRSettings {
|
|
|
34
34
|
* @returns {CanvasRenderingContext2DHDR | null} The 2D rendering context, or `null` if the context cannot be created. Can be cast down to `CanvasRenderingContext2D` or `RenderingContext`
|
|
35
35
|
*/
|
|
36
36
|
export function initHDRCanvas(canvas: HDRHTMLCanvasElement): CanvasRenderingContext2DHDR | null {
|
|
37
|
-
|
|
37
|
+
const browserMajorVersion = getBrowserVersion();
|
|
38
|
+
if (browserMajorVersion !== null && browserMajorVersion < 134) {
|
|
39
|
+
canvas.configureHighDynamicRange({ mode: "extended" });
|
|
40
|
+
}
|
|
38
41
|
const ctx = canvas.getContext("2d", getHdrOptions());
|
|
39
42
|
return ctx as CanvasRenderingContext2DHDR;
|
|
40
43
|
}
|
package/src/types/HDRCanvas.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface HDRImageData {
|
|
|
21
21
|
// See https://github.com/w3c/ColorWeb-CG/blob/main/hdr_html_canvas_element.md
|
|
22
22
|
// "rec2100-display-linear" is left out because of mapping issues
|
|
23
23
|
type HDRPredefinedColorSpace = "display-p3" | "srgb" | "rec2100-hlg" | "rec2100-pq";
|
|
24
|
+
type HDRCanvasToneMapping = { mode: HDRCanvasToneMappingMode };
|
|
25
|
+
type HDRCanvasToneMappingMode = "standard" | "extended";
|
|
24
26
|
|
|
25
27
|
//enum HDRPredefinedColorSpace {"display-p3", "srgb", "rec2100-hlg", "rec2100-pq", "rec2100-display-linear"};
|
|
26
28
|
|
|
@@ -43,11 +45,14 @@ interface CanvasRenderingContext2DHDRSettings {
|
|
|
43
45
|
colorSpace: HDRPredefinedColorSpace;
|
|
44
46
|
pixelFormat?: "uint8" | "float16";
|
|
45
47
|
colorType?: "unorm8" | "float16";
|
|
48
|
+
toneMapping?: HDRCanvasToneMapping;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export {
|
|
49
52
|
HDRHTMLCanvasElement,
|
|
50
53
|
HDRPredefinedColorSpace,
|
|
54
|
+
HDRCanvasToneMapping,
|
|
55
|
+
HDRCanvasToneMappingMode,
|
|
51
56
|
HDRImageDataArray,
|
|
52
57
|
HDRImageData,
|
|
53
58
|
HDRImagePixelCallback,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebGPUBackend from 'three/src/renderers/webgpu/WebGPUBackend.js';
|
|
2
|
-
import {
|
|
2
|
+
import { REVISION, HalfFloatType } from 'three/src/constants.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An HDR-enabled WebGPU backend for three.js, extending the standard `WebGPUBackend`.
|
|
@@ -9,100 +9,63 @@ import { GPUFeatureName, GPUTextureFormat } from 'three/src/renderers/webgpu/uti
|
|
|
9
9
|
*
|
|
10
10
|
* @class
|
|
11
11
|
* @augments {WebGPUBackend}
|
|
12
|
+
* @deprecated Use WebGPUBackend instead
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
class HDRWebGPUBackend extends WebGPUBackend {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
* Initializes the backend, including requesting a WebGPU device and configuring the context.
|
|
18
|
-
* This method overrides the parent `init` to set a specific HDR color space.
|
|
19
|
-
*
|
|
20
|
-
* @param {WebGLRenderer} renderer - The three.js renderer instance.
|
|
21
|
-
* @returns {Promise<void>} A promise that resolves when the initialization is complete.
|
|
22
|
-
*/
|
|
23
|
-
// See https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/webgpu/WebGPUBackend.js#L123
|
|
24
|
-
async init( renderer ) {
|
|
17
|
+
get context() {
|
|
25
18
|
|
|
26
|
-
|
|
19
|
+
const canvasTarget = this.renderer.getCanvasTarget();
|
|
20
|
+
const canvasData = this.get( canvasTarget );
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
let context = canvasData.context;
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
if ( context === undefined ) {
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
const parameters = this.parameters;
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
if ( canvasTarget.isDefaultCanvasTarget === true && parameters.context !== undefined ) {
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
context = parameters.context;
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
powerPreference: parameters.powerPreference
|
|
40
|
-
};
|
|
32
|
+
} else {
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
context = canvasTarget.domElement.getContext( 'webgpu' );
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
}
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
// OffscreenCanvas does not have setAttribute, see #22811
|
|
39
|
+
if ( 'setAttribute' in canvasTarget.domElement ) canvasTarget.domElement.setAttribute( 'data-engine', `three.js r${ REVISION } webgpu` );
|
|
47
40
|
|
|
48
|
-
|
|
41
|
+
const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
|
|
49
42
|
|
|
50
|
-
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
+
const toneMappingMode = parameters.outputType === HalfFloatType ? 'extended' : 'standard';
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
// See https://github.com/ccameron-chromium/webgpu-hdr/blob/main/EXPLAINER.md#example-use
|
|
47
|
+
/**
|
|
48
|
+
* Configures the WebGPU context with HDR settings.
|
|
49
|
+
* The `colorSpace` is set to `rec2100-hlg` for High Dynamic Range support.
|
|
50
|
+
* @see {@link https://github.com/ccameron-chromium/webgpu-hdr/blob/main/EXPLAINER.md#example-use | WebGPU HDR Explainer}
|
|
51
|
+
*/
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
context.configure( {
|
|
54
|
+
device: this.device,
|
|
55
|
+
format: this.utils.getPreferredCanvasFormat(),
|
|
56
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
57
|
+
alphaMode: alphaMode,
|
|
58
|
+
colorSpace: "rec2100-hlg",
|
|
59
|
+
toneMapping: { mode: "extended" }
|
|
60
|
+
} );
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
canvasData.context = context;
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
}
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
return context;
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const deviceDescriptor = {
|
|
67
|
-
requiredFeatures: supportedFeatures,
|
|
68
|
-
requiredLimits: parameters.requiredLimits
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
device = await adapter.requestDevice( deviceDescriptor );
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
|
|
75
|
-
device = parameters.device;
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const context = ( parameters.context !== undefined ) ? parameters.context : renderer.domElement.getContext( 'webgpu' );
|
|
80
|
-
|
|
81
|
-
this.device = device;
|
|
82
|
-
this.context = context;
|
|
83
|
-
|
|
84
|
-
const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
|
|
85
|
-
|
|
86
|
-
// See https://github.com/ccameron-chromium/webgpu-hdr/blob/main/EXPLAINER.md#example-use
|
|
87
|
-
/**
|
|
88
|
-
* Configures the WebGPU context with HDR settings.
|
|
89
|
-
* The `colorSpace` is set to `rec2100-hlg` for High Dynamic Range support.
|
|
90
|
-
* @see {@link https://github.com/ccameron-chromium/webgpu-hdr/blob/main/EXPLAINER.md#example-use | WebGPU HDR Explainer}
|
|
91
|
-
*/
|
|
92
|
-
this.context.configure( {
|
|
93
|
-
device: this.device,
|
|
94
|
-
format: GPUTextureFormat.BGRA8Unorm,
|
|
95
|
-
//format: GPUTextureFormat.RGBA16Float,
|
|
96
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
97
|
-
alphaMode: alphaMode,
|
|
98
|
-
//colorSpace: "display-p3",
|
|
99
|
-
colorSpace: "rec2100-hlg",
|
|
100
|
-
colorMetadata: { mode:"extended" }
|
|
101
|
-
} );
|
|
102
|
-
|
|
103
|
-
this.updateSize();
|
|
104
|
-
|
|
105
|
-
}
|
|
68
|
+
}
|
|
106
69
|
|
|
107
70
|
}
|
|
108
71
|
|
|
@@ -12,6 +12,7 @@ import HDRWebGPUBackend from './HDRWebGPUBackend.js';
|
|
|
12
12
|
* @fires contextrestored
|
|
13
13
|
* @fires contextlost
|
|
14
14
|
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer | WebGLRenderer}
|
|
15
|
+
* @deprecated Use WebGPURenderer instead
|
|
15
16
|
*/
|
|
16
17
|
class HDRWebGPURenderer extends Renderer {
|
|
17
18
|
/**
|