@monogrid/gainmap-js 3.4.1 → 3.6.0
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/CHANGELOG.md +14 -0
- package/README.md +111 -133
- package/dist/{QuadRenderer-Bl8ThfRL.js → QuadRenderer-CXtNzoCY.js} +1 -1
- package/dist/{QuadRenderer-D1rYlVRa.js → QuadRenderer-DcBTBLz6.js} +1 -1
- package/dist/{_commonjsHelpers-CHnLGTFq.js → _commonjsHelpers-Cdw2adc2.js} +1 -1
- package/dist/{_commonjsHelpers-D4ntYHBT.js → _commonjsHelpers-CnYhShyx.js} +1 -1
- package/dist/{compress-B5svUHuf.js → compress-C42bpk6O.js} +1 -1
- package/dist/{compress-DBGuVQfM.js → compress-CzMz2bpX.js} +1 -2
- package/dist/core/iso-gainmap-metadata.d.ts +40 -0
- package/dist/decode/shared/extract.d.ts +5 -3
- package/dist/decode/shared/index.d.ts +2 -0
- package/dist/decode/shared/utils/create-textures.d.ts +26 -0
- package/dist/decode/shared/utils/extractISO.d.ts +15 -0
- package/dist/decode/shared/utils/warn-deprecated.d.ts +8 -0
- package/dist/decode/webgl/decode.d.ts +1 -0
- package/dist/decode/webgl/index.d.ts +4 -0
- package/dist/decode/webgl/loaders/GainMapLoader.d.ts +3 -1
- package/dist/decode/webgl/loaders/HDRJPGLoader.d.ts +3 -1
- package/dist/decode/webgl/materials/GainMapDecoderMaterial.d.ts +1 -0
- package/dist/decode/webgpu/core/QuadRenderer.d.ts +1 -0
- package/dist/decode/webgpu/decode.d.ts +1 -0
- package/dist/decode/webgpu/index.d.ts +7 -0
- package/dist/decode/webgpu/loaders/GainMapLoader.d.ts +3 -1
- package/dist/decode/webgpu/loaders/GainMapNodeLoader.d.ts +42 -0
- package/dist/decode/webgpu/loaders/HDRJPGLoader.d.ts +3 -1
- package/dist/decode/webgpu/loaders/HDRJPGNodeLoader.d.ts +41 -0
- package/dist/decode/webgpu/loaders/LoaderBaseNode.d.ts +24 -0
- package/dist/decode/webgpu/materials/GainMapDecoderMaterial.d.ts +1 -0
- package/dist/decode/webgpu/nodes/GainMapNode.d.ts +137 -0
- package/dist/decode.js +18 -4
- package/dist/decode.min.js +2 -2
- package/dist/decode.umd.cjs +207 -36
- package/dist/decode.umd.min.cjs +2 -2
- package/dist/decode.webgpu.js +453 -8
- package/dist/decode.webgpu.min.js +2 -2
- package/dist/decode.webgpu.umd.cjs +644 -38
- package/dist/decode.webgpu.umd.min.cjs +2 -2
- package/dist/encode.js +4 -4
- package/dist/encode.min.js +2 -2
- package/dist/encode.umd.cjs +1 -2
- package/dist/encode.umd.min.cjs +1 -1
- package/dist/iso-gainmap-metadata-ByNqnUPn.js +141 -0
- package/dist/iso-gainmap-metadata-CEaaU7RT.js +5 -0
- package/dist/libultrahdr/jpeg-assembler.d.ts +2 -0
- package/dist/libultrahdr.js +30 -7
- package/dist/libultrahdr.min.js +2 -2
- package/dist/libultrahdr.umd.cjs +104 -7
- package/dist/libultrahdr.umd.min.cjs +2 -2
- package/dist/third-party.txt +69 -69
- package/dist/{Loader-Bi9FKrn4.js → warn-deprecated-Bk17fVbj.js} +117 -38
- package/dist/warn-deprecated-D0kPpXtA.js +5 -0
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.min.js +2 -2
- package/dist/worker-interface.umd.cjs +1 -1
- package/dist/worker-interface.umd.min.cjs +1 -1
- package/dist/worker.js +3 -3
- package/dist/worker.min.js +2 -2
- package/dist/worker.umd.cjs +1 -2
- package/dist/worker.umd.min.cjs +1 -1
- package/package.json +34 -37
- package/dist/Loader-uEDs4JZg.js +0 -5
|
@@ -3,6 +3,13 @@ export * from '../shared';
|
|
|
3
3
|
export * from './core/QuadRenderer';
|
|
4
4
|
export * from './decode';
|
|
5
5
|
export * from './loaders/GainMapLoader';
|
|
6
|
+
export * from './loaders/GainMapNodeLoader';
|
|
6
7
|
export * from './loaders/HDRJPGLoader';
|
|
8
|
+
export * from './loaders/HDRJPGNodeLoader';
|
|
9
|
+
/**
|
|
10
|
+
* Legacy name
|
|
11
|
+
* @deprecated Will be removed in v4.0.0. Use {@link HDRJPGNodeLoader} instead: it is **not a drop-in replacement**, it returns a {@link GainMapNode} instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
12
|
+
*/
|
|
7
13
|
export { HDRJPGLoader as JPEGRLoader } from './loaders/HDRJPGLoader';
|
|
8
14
|
export * from './materials/GainMapDecoderMaterial';
|
|
15
|
+
export * from './nodes/GainMapNode';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { HalfFloatType } from 'three/webgpu';
|
|
1
|
+
import { HalfFloatType, LoadingManager, WebGPURenderer } from 'three/webgpu';
|
|
2
2
|
import { QuadRenderer } from '../core/QuadRenderer';
|
|
3
3
|
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
4
4
|
import { LoaderBaseWebGPU } from './LoaderBaseWebGPU';
|
|
5
5
|
/**
|
|
6
6
|
* A Three.js Loader for the gain map format (WebGPU version).
|
|
7
7
|
*
|
|
8
|
+
* @deprecated Will be removed in v4.0.0. Use {@link GainMapNodeLoader} instead: it is **not a drop-in replacement**, it returns a {@link GainMapNode} instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
8
9
|
* @category Loaders
|
|
9
10
|
* @group Loaders
|
|
10
11
|
*
|
|
@@ -51,6 +52,7 @@ import { LoaderBaseWebGPU } from './LoaderBaseWebGPU';
|
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
export declare class GainMapLoader extends LoaderBaseWebGPU<[string, string, string]> {
|
|
55
|
+
constructor(renderer?: WebGPURenderer, manager?: LoadingManager);
|
|
54
56
|
/**
|
|
55
57
|
* Loads a gainmap using separate data
|
|
56
58
|
* * sdr image
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { GainMapNode } from '../nodes/GainMapNode';
|
|
2
|
+
import { LoaderBaseNode } from './LoaderBaseNode';
|
|
3
|
+
/**
|
|
4
|
+
* A Three.js Loader for the gain map format stored as separate files (sdr image, gain map image, metadata json),
|
|
5
|
+
* returning a {@link GainMapNode} (a TSL texture node holding the decoded HDR image).
|
|
6
|
+
*
|
|
7
|
+
* No renderer is needed: `load` returns the node synchronously, it can be assigned to materials right away
|
|
8
|
+
* and it is decoded on the GPU once loaded.
|
|
9
|
+
*
|
|
10
|
+
* @category Loaders
|
|
11
|
+
* @group Loaders
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { GainMapNodeLoader } from '@monogrid/gainmap-js/webgpu'
|
|
15
|
+
* import { MeshBasicNodeMaterial } from 'three/webgpu'
|
|
16
|
+
*
|
|
17
|
+
* const hdr = new GainMapNodeLoader().load([
|
|
18
|
+
* 'sdr.webp',
|
|
19
|
+
* 'gainmap.webp',
|
|
20
|
+
* 'metadata.json'
|
|
21
|
+
* ])
|
|
22
|
+
*
|
|
23
|
+
* const material = new MeshBasicNodeMaterial()
|
|
24
|
+
* material.colorNode = hdr
|
|
25
|
+
*/
|
|
26
|
+
export declare class GainMapNodeLoader extends LoaderBaseNode<[string, string, string]> {
|
|
27
|
+
/**
|
|
28
|
+
* Loads a gainmap using separate data
|
|
29
|
+
* * sdr image
|
|
30
|
+
* * gain map image
|
|
31
|
+
* * metadata json
|
|
32
|
+
*
|
|
33
|
+
* useful for webp gain maps
|
|
34
|
+
*
|
|
35
|
+
* @param urls An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
|
|
36
|
+
* @param onLoad Load complete callback, will receive the node
|
|
37
|
+
* @param onProgress Progress callback, will receive a `ProgressEvent`
|
|
38
|
+
* @param onError Error callback
|
|
39
|
+
* @returns a node which can be used immediately, it will hold the image once loaded
|
|
40
|
+
*/
|
|
41
|
+
load(urls: [string, string, string], onLoad?: (data: GainMapNode) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): GainMapNode;
|
|
42
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { HalfFloatType } from 'three/webgpu';
|
|
1
|
+
import { HalfFloatType, LoadingManager, WebGPURenderer } from 'three/webgpu';
|
|
2
2
|
import { QuadRenderer } from '../core/QuadRenderer';
|
|
3
3
|
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
4
4
|
import { LoaderBaseWebGPU } from './LoaderBaseWebGPU';
|
|
5
5
|
/**
|
|
6
6
|
* A Three.js Loader for a JPEG with embedded gainmap metadata (WebGPU version).
|
|
7
7
|
*
|
|
8
|
+
* @deprecated Will be removed in v4.0.0. Use {@link HDRJPGNodeLoader} instead: it is **not a drop-in replacement**, it returns a {@link GainMapNode} instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
8
9
|
* @category Loaders
|
|
9
10
|
* @group Loaders
|
|
10
11
|
*
|
|
@@ -51,6 +52,7 @@ import { LoaderBaseWebGPU } from './LoaderBaseWebGPU';
|
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
export declare class HDRJPGLoader extends LoaderBaseWebGPU<string> {
|
|
55
|
+
constructor(renderer?: WebGPURenderer, manager?: LoadingManager);
|
|
54
56
|
/**
|
|
55
57
|
* Loads a JPEG containing gain map metadata
|
|
56
58
|
* Renders a normal SDR image if gainmap data is not found
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GainMapNode } from '../nodes/GainMapNode';
|
|
2
|
+
import { LoaderBaseNode } from './LoaderBaseNode';
|
|
3
|
+
/**
|
|
4
|
+
* A Three.js Loader for a JPEG with embedded gain map metadata,
|
|
5
|
+
* returning a {@link GainMapNode} (a TSL texture node holding the decoded HDR image).
|
|
6
|
+
*
|
|
7
|
+
* No renderer is needed: `load` returns the node synchronously
|
|
8
|
+
* (like `TextureLoader` returns a `Texture`), it can be assigned to materials right away
|
|
9
|
+
* and it is decoded on the GPU once loaded.
|
|
10
|
+
*
|
|
11
|
+
* @category Loaders
|
|
12
|
+
* @group Loaders
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { HDRJPGNodeLoader } from '@monogrid/gainmap-js/webgpu'
|
|
16
|
+
* import { equirectUV } from 'three/tsl'
|
|
17
|
+
* import { MeshBasicNodeMaterial } from 'three/webgpu'
|
|
18
|
+
*
|
|
19
|
+
* const hdr = new HDRJPGNodeLoader().load('gainmap.jpeg')
|
|
20
|
+
*
|
|
21
|
+
* const material = new MeshBasicNodeMaterial()
|
|
22
|
+
* material.colorNode = hdr
|
|
23
|
+
*
|
|
24
|
+
* scene.backgroundNode = hdr.sample(equirectUV())
|
|
25
|
+
*
|
|
26
|
+
* // all parameters are uniforms, changing them re-decodes the image once
|
|
27
|
+
* hdr.maxDisplayBoost.value = 2
|
|
28
|
+
*/
|
|
29
|
+
export declare class HDRJPGNodeLoader extends LoaderBaseNode<string> {
|
|
30
|
+
/**
|
|
31
|
+
* Loads a JPEG containing gain map metadata
|
|
32
|
+
* Renders a normal SDR image if gainmap data is not found
|
|
33
|
+
*
|
|
34
|
+
* @param url Path to a JPEG file containing embedded gain map metadata
|
|
35
|
+
* @param onLoad Load complete callback, will receive the node
|
|
36
|
+
* @param onProgress Progress callback, will receive a `ProgressEvent`
|
|
37
|
+
* @param onError Error callback
|
|
38
|
+
* @returns a node which can be used immediately, it will hold the image once loaded
|
|
39
|
+
*/
|
|
40
|
+
load(url: string, onLoad?: (data: GainMapNode) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): GainMapNode;
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FileLoader, Loader } from 'three/webgpu';
|
|
2
|
+
import { type GainMapMetadata } from '../../../core/types';
|
|
3
|
+
import { GainMapNode } from '../nodes/GainMapNode';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for loaders returning a {@link GainMapNode}
|
|
6
|
+
* @template TUrl - The type of URL used to load resources
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class LoaderBaseNode<TUrl = string> extends Loader<GainMapNode, TUrl> {
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
* @param responseType
|
|
12
|
+
*/
|
|
13
|
+
protected createFileLoader(responseType?: 'arraybuffer'): FileLoader<string | ArrayBuffer>;
|
|
14
|
+
/**
|
|
15
|
+
* Decodes the images and feeds them to the node, together with the metadata
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @param node
|
|
19
|
+
* @param metadata
|
|
20
|
+
* @param sdrBuffer
|
|
21
|
+
* @param gainMapBuffer
|
|
22
|
+
*/
|
|
23
|
+
protected fillNode(node: GainMapNode, metadata: GainMapMetadata, sdrBuffer: ArrayBuffer, gainMapBuffer?: ArrayBuffer): Promise<void>;
|
|
24
|
+
}
|
|
@@ -4,6 +4,7 @@ import { type GainmapDecodingParameters } from '../../shared';
|
|
|
4
4
|
/**
|
|
5
5
|
* A Material which is able to decode the Gainmap into a full HDR Representation using TSL (Three.js Shading Language)
|
|
6
6
|
*
|
|
7
|
+
* @deprecated Will be removed in v4.0.0. The decode now happens in {@link GainMapNode}, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
7
8
|
* @category Materials
|
|
8
9
|
* @group Materials
|
|
9
10
|
*/
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type Node, type NodeFrame, RenderTarget, Texture, TextureNode, type UniformNode, Vector3, type WebGPURenderer } from 'three/webgpu';
|
|
2
|
+
import { type GainMapMetadata } from '../../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* Textures and uniforms driving a {@link GainMapNode} decode
|
|
5
|
+
*/
|
|
6
|
+
export type GainMapNodeUniforms = {
|
|
7
|
+
sdr: TextureNode;
|
|
8
|
+
gainMap: TextureNode;
|
|
9
|
+
gamma: UniformNode<'vec3', Vector3>;
|
|
10
|
+
offsetSdr: UniformNode<'vec3', Vector3>;
|
|
11
|
+
offsetHdr: UniformNode<'vec3', Vector3>;
|
|
12
|
+
gainMapMin: UniformNode<'vec3', Vector3>;
|
|
13
|
+
gainMapMax: UniformNode<'vec3', Vector3>;
|
|
14
|
+
hdrCapacityMin: UniformNode<'float', number>;
|
|
15
|
+
hdrCapacityMax: UniformNode<'float', number>;
|
|
16
|
+
maxDisplayBoost: UniformNode<'float', number>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A TSL texture node holding the HDR image decoded from an SDR image + gain map.
|
|
20
|
+
*
|
|
21
|
+
* The decode runs on the GPU into a HalfFloat render target, and only when something changed
|
|
22
|
+
* (textures loaded/swapped or any uniform value changed): sampling the node costs a single
|
|
23
|
+
* texture read, like any other texture.
|
|
24
|
+
*
|
|
25
|
+
* The node updates itself before rendering whenever it is part of a rendered node graph
|
|
26
|
+
* (material, `scene.backgroundNode`, ...). When only its texture is used (`node.value`,
|
|
27
|
+
* e.g. `scene.environment = node.value`) call {@link GainMapNode.decode} yourself.
|
|
28
|
+
*
|
|
29
|
+
* Re-decoding also flags the texture for PMREM regeneration,
|
|
30
|
+
* so environment maps are recomputed only when the image actually changes.
|
|
31
|
+
*
|
|
32
|
+
* `node.value` gets its final size once loaded: three.js PMREMs don't follow texture resizes,
|
|
33
|
+
* so assign it to `scene.environment` (or `pmremTexture()`) after load.
|
|
34
|
+
*
|
|
35
|
+
* @category Nodes
|
|
36
|
+
* @group Nodes
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* import { GainMapNode } from '@monogrid/gainmap-js/webgpu'
|
|
40
|
+
* import { equirectUV } from 'three/tsl'
|
|
41
|
+
*
|
|
42
|
+
* const hdr = new GainMapNode()
|
|
43
|
+
* .setTextures(sdrTexture, gainMapTexture)
|
|
44
|
+
* .setMetadata(metadata)
|
|
45
|
+
*
|
|
46
|
+
* material.colorNode = hdr
|
|
47
|
+
* scene.backgroundNode = hdr.sample(equirectUV())
|
|
48
|
+
* hdr.maxDisplayBoost.value = 2 // re-decodes once, on the next frame
|
|
49
|
+
*/
|
|
50
|
+
export declare class GainMapNode extends TextureNode {
|
|
51
|
+
static get type(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Shared textures and uniforms
|
|
54
|
+
*/
|
|
55
|
+
readonly uniforms: GainMapNodeUniforms;
|
|
56
|
+
/**
|
|
57
|
+
* The render target holding the decoded HDR image
|
|
58
|
+
*/
|
|
59
|
+
readonly renderTarget: RenderTarget;
|
|
60
|
+
private _quadMesh;
|
|
61
|
+
private _material;
|
|
62
|
+
private _rendererState;
|
|
63
|
+
private _state;
|
|
64
|
+
constructor();
|
|
65
|
+
/** The SDR rendition texture (sRGB) */
|
|
66
|
+
get sdr(): Texture<unknown, import("three").TextureEventMap>;
|
|
67
|
+
/** The gain map recovery texture (linear) */
|
|
68
|
+
get gainMap(): Texture<unknown, import("three").TextureEventMap>;
|
|
69
|
+
/** @see {@link GainMapMetadata.gamma} */
|
|
70
|
+
get gamma(): UniformNode<"vec3", Vector3>;
|
|
71
|
+
/** @see {@link GainMapMetadata.offsetSdr} */
|
|
72
|
+
get offsetSdr(): UniformNode<"vec3", Vector3>;
|
|
73
|
+
/** @see {@link GainMapMetadata.offsetHdr} */
|
|
74
|
+
get offsetHdr(): UniformNode<"vec3", Vector3>;
|
|
75
|
+
/** @see {@link GainMapMetadata.gainMapMin} */
|
|
76
|
+
get gainMapMin(): UniformNode<"vec3", Vector3>;
|
|
77
|
+
/** @see {@link GainMapMetadata.gainMapMax} */
|
|
78
|
+
get gainMapMax(): UniformNode<"vec3", Vector3>;
|
|
79
|
+
/** @see {@link GainMapMetadata.hdrCapacityMin} */
|
|
80
|
+
get hdrCapacityMin(): UniformNode<"float", number>;
|
|
81
|
+
/** @see {@link GainMapMetadata.hdrCapacityMax} */
|
|
82
|
+
get hdrCapacityMax(): UniformNode<"float", number>;
|
|
83
|
+
/**
|
|
84
|
+
* @see {@link GainmapDecodingParameters.maxDisplayBoost}
|
|
85
|
+
* @remarks Non Logarithmic space
|
|
86
|
+
*/
|
|
87
|
+
get maxDisplayBoost(): UniformNode<"float", number>;
|
|
88
|
+
/** Width of the SDR image, 0 until loaded */
|
|
89
|
+
get width(): number;
|
|
90
|
+
/** Height of the SDR image, 0 until loaded */
|
|
91
|
+
get height(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the SDR and gain map textures.
|
|
94
|
+
* The SDR texture is expected in sRGB color space, the gain map in linear.
|
|
95
|
+
*
|
|
96
|
+
* @param sdr
|
|
97
|
+
* @param gainMap
|
|
98
|
+
*/
|
|
99
|
+
setTextures(sdr: Texture, gainMap: Texture): this;
|
|
100
|
+
/**
|
|
101
|
+
* Copies the gain map metadata into the uniforms.
|
|
102
|
+
* Also sets `maxDisplayBoost` to fully restore the HDR range.
|
|
103
|
+
*
|
|
104
|
+
* @param metadata
|
|
105
|
+
*/
|
|
106
|
+
setMetadata(metadata: GainMapMetadata): this;
|
|
107
|
+
private _currentState;
|
|
108
|
+
/**
|
|
109
|
+
* Decodes the image into {@link GainMapNode.renderTarget}, only if something changed since the last decode.
|
|
110
|
+
*
|
|
111
|
+
* Called automatically when the node is part of a rendered node graph.
|
|
112
|
+
*
|
|
113
|
+
* @param renderer
|
|
114
|
+
* @returns `true` if the image was decoded
|
|
115
|
+
*/
|
|
116
|
+
decode(renderer: WebGPURenderer): boolean;
|
|
117
|
+
updateBefore(frame: NodeFrame): undefined;
|
|
118
|
+
set value(value: Texture);
|
|
119
|
+
get value(): Texture;
|
|
120
|
+
/**
|
|
121
|
+
* Clones created by `sample()` & co. are plain TextureNodes reading this node's texture,
|
|
122
|
+
* they keep it updated before rendering as well
|
|
123
|
+
*/
|
|
124
|
+
clone(): this;
|
|
125
|
+
/**
|
|
126
|
+
* Disposes the render target, the SDR and gain map textures
|
|
127
|
+
*/
|
|
128
|
+
dispose(): void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* TSL function creating a {@link GainMapNode} from an SDR texture, a gain map texture and its metadata
|
|
132
|
+
*
|
|
133
|
+
* @param sdr
|
|
134
|
+
* @param gainMap
|
|
135
|
+
* @param metadata
|
|
136
|
+
*/
|
|
137
|
+
export declare const gainMapNode: (sdr: Texture, gainMap: Texture, metadata: GainMapMetadata) => GainMapNode & Node;
|
package/dist/decode.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
2
|
+
* @monogrid/gainmap-js v3.6.0
|
|
3
3
|
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
7
|
-
import { c as createDecodeFunction, L as LoaderBaseShared, e as extractGainmapFromJPEG, X as XMPMetadataNotFoundError, G as GainMapNotFoundError } from './
|
|
8
|
-
export { M as MPFExtractor, a as extractXMP } from './
|
|
6
|
+
import { Q as QuadRenderer } from './QuadRenderer-CXtNzoCY.js';
|
|
7
|
+
import { w as warnDeprecated, c as createDecodeFunction, L as LoaderBaseShared, e as extractGainmapFromJPEG, X as XMPMetadataNotFoundError, G as GainMapNotFoundError } from './warn-deprecated-Bk17fVbj.js';
|
|
8
|
+
export { M as MPFExtractor, a as createTextures, b as extractISO, d as extractXMP, p as processImages } from './warn-deprecated-Bk17fVbj.js';
|
|
9
9
|
import { ShaderMaterial, NoBlending, Vector3, WebGLRenderer, FileLoader } from 'three';
|
|
10
|
+
import './iso-gainmap-metadata-ByNqnUPn.js';
|
|
10
11
|
|
|
11
12
|
const vertexShader = /* glsl */ `
|
|
12
13
|
varying vec2 vUv;
|
|
@@ -46,6 +47,7 @@ void main() {
|
|
|
46
47
|
/**
|
|
47
48
|
* A Material which is able to decode the Gainmap into a full HDR Representation
|
|
48
49
|
*
|
|
50
|
+
* @deprecated Will be removed in v4.0.0. The decode now happens in `GainMapNode` from `@monogrid/gainmap-js/webgpu`, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
49
51
|
* @category Materials
|
|
50
52
|
* @group Materials
|
|
51
53
|
*/
|
|
@@ -162,6 +164,7 @@ const decodeImpl = createDecodeFunction({
|
|
|
162
164
|
/**
|
|
163
165
|
* Decodes a gain map using a WebGL RenderTarget
|
|
164
166
|
*
|
|
167
|
+
* @deprecated Will be removed in v4.0.0. Use `gainMapNode()` from `@monogrid/gainmap-js/webgpu` with `WebGPURenderer` (which also has a WebGL2 backend) instead: it is **not a drop-in replacement**, it returns a `GainMapNode` instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
165
168
|
* @category Decoding Functions
|
|
166
169
|
* @group Decoding Functions
|
|
167
170
|
* @example
|
|
@@ -215,6 +218,7 @@ const decodeImpl = createDecodeFunction({
|
|
|
215
218
|
* @throws {Error} if the WebGLRenderer fails to render the gain map
|
|
216
219
|
*/
|
|
217
220
|
const decode = (params) => {
|
|
221
|
+
warnDeprecated('decode()', '@monogrid/gainmap-js', 'gainMapNode()');
|
|
218
222
|
// Ensure renderer is defined for the base function
|
|
219
223
|
if (!params.renderer) {
|
|
220
224
|
throw new Error('Renderer is required for decode function');
|
|
@@ -263,6 +267,7 @@ class LoaderBaseWebGL extends LoaderBaseShared {
|
|
|
263
267
|
/**
|
|
264
268
|
* A Three.js Loader for the gain map format.
|
|
265
269
|
*
|
|
270
|
+
* @deprecated Will be removed in v4.0.0. Use GainMapNodeLoader from `@monogrid/gainmap-js/webgpu` with `WebGPURenderer` (which also has a WebGL2 backend) instead: it is **not a drop-in replacement**, it returns a `GainMapNode` instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
266
271
|
* @category Loaders
|
|
267
272
|
* @group Loaders
|
|
268
273
|
*
|
|
@@ -308,6 +313,10 @@ class LoaderBaseWebGL extends LoaderBaseShared {
|
|
|
308
313
|
*
|
|
309
314
|
*/
|
|
310
315
|
class GainMapLoader extends LoaderBaseWebGL {
|
|
316
|
+
constructor(renderer, manager) {
|
|
317
|
+
super(renderer, manager);
|
|
318
|
+
warnDeprecated('GainMapLoader', '@monogrid/gainmap-js', 'GainMapNodeLoader');
|
|
319
|
+
}
|
|
311
320
|
/**
|
|
312
321
|
* Loads a gainmap using separate data
|
|
313
322
|
* * sdr image
|
|
@@ -448,6 +457,7 @@ class GainMapLoader extends LoaderBaseWebGL {
|
|
|
448
457
|
/**
|
|
449
458
|
* A Three.js Loader for a JPEG with embedded gainmap metadata.
|
|
450
459
|
*
|
|
460
|
+
* @deprecated Will be removed in v4.0.0. Use HDRJPGNodeLoader from `@monogrid/gainmap-js/webgpu` with `WebGPURenderer` (which also has a WebGL2 backend) instead: it is **not a drop-in replacement**, it returns a `GainMapNode` instead of a render target, see the [migration guide](https://github.com/MONOGRID/gainmap-js#migrating-to-v400).
|
|
451
461
|
* @category Loaders
|
|
452
462
|
* @group Loaders
|
|
453
463
|
*
|
|
@@ -493,6 +503,10 @@ class GainMapLoader extends LoaderBaseWebGL {
|
|
|
493
503
|
*
|
|
494
504
|
*/
|
|
495
505
|
class HDRJPGLoader extends LoaderBaseWebGL {
|
|
506
|
+
constructor(renderer, manager) {
|
|
507
|
+
super(renderer, manager);
|
|
508
|
+
warnDeprecated('HDRJPGLoader', '@monogrid/gainmap-js', 'HDRJPGNodeLoader');
|
|
509
|
+
}
|
|
496
510
|
/**
|
|
497
511
|
* Loads a JPEG containing gain map metadata
|
|
498
512
|
* Renders a normal SDR image if gainmap data is not found
|
package/dist/decode.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
2
|
+
* @monogrid/gainmap-js v3.6.0
|
|
3
3
|
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
|
-
import{Q as e}from"./QuadRenderer-
|
|
5
|
+
import{Q as e}from"./QuadRenderer-DcBTBLz6.js";import{w as r,c as t,L as n,e as i,X as s,G as o}from"./warn-deprecated-D0kPpXtA.js";export{M as MPFExtractor,a as createTextures,b as extractISO,d as extractXMP,p as processImages}from"./warn-deprecated-D0kPpXtA.js";import{ShaderMaterial as h,NoBlending as m,Vector3 as f,WebGLRenderer as c,FileLoader as g}from"three";import"./iso-gainmap-metadata-CEaaU7RT.js";class u extends h{_maxDisplayBoost;_hdrCapacityMin;_hdrCapacityMax;constructor({gamma:e,offsetHdr:a,offsetSdr:r,gainMapMin:t,gainMapMax:n,maxDisplayBoost:i,hdrCapacityMin:s,hdrCapacityMax:o,sdr:d,gainMap:h}){super({name:"GainMapDecoderMaterial",vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\n// min half float value\n#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )\n// max half float value\n#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )\n\nuniform sampler2D sdr;\nuniform sampler2D gainMap;\nuniform vec3 gamma;\nuniform vec3 offsetHdr;\nuniform vec3 offsetSdr;\nuniform vec3 gainMapMin;\nuniform vec3 gainMapMax;\nuniform float weightFactor;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec3 rgb = texture2D( sdr, vUv ).rgb;\n vec3 recovery = texture2D( gainMap, vUv ).rgb;\n vec3 logRecovery = pow( recovery, gamma );\n vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;\n vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;\n vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));\n gl_FragColor = vec4( clampedHdrColor , 1.0 );\n}\n",uniforms:{sdr:{value:d},gainMap:{value:h},gamma:{value:new f(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:(new f).fromArray(a)},offsetSdr:{value:(new f).fromArray(r)},gainMapMin:{value:(new f).fromArray(t)},gainMapMax:{value:(new f).fromArray(n)},weightFactor:{value:(Math.log2(i)-s)/(o-s)}},blending:m,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=i,this._hdrCapacityMin=s,this._hdrCapacityMax=o,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const a=this.uniforms.gamma.value;a.x=1/e[0],a.y=1/e[1],a.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}const l=t({renderer:c,createMaterial:e=>new u(e),createQuadRenderer:a=>new e(a)}),y=e=>{if(r("decode()","@monogrid/gainmap-js","gainMapNode()"),!e.renderer)throw new Error("Renderer is required for decode function");const a=l({...e,renderer:e.renderer});try{a.render()}catch(e){throw a.disposeOnDemandRenderer(),e}return a};class v extends n{constructor(a,r){super({renderer:a,createMaterial:e=>new u(e),createQuadRenderer:a=>new e(a)},r)}async render(e,a,r,t){const{sdrImage:n,gainMapImage:i,needsFlip:s}=await this.processImages(r,t,"flipY"),{gainMap:o,sdr:d}=this.createTextures(n,i,s);this.updateQuadRenderer(e,n,o,d,a),e.render()}}class w extends v{constructor(e,a){super(e,a),r("GainMapLoader","@monogrid/gainmap-js","GainMapNodeLoader")}load([e,a,r],t,n,i){const s=this.prepareQuadRenderer();let o,d,h;const m=async()=>{if(o&&d&&h){try{await this.render(s,h,o,d)}catch(t){return this.manager.itemError(e),this.manager.itemError(a),this.manager.itemError(r),"function"==typeof i&&i(t),void s.disposeOnDemandRenderer()}"function"==typeof t&&t(s),this.manager.itemEnd(e),this.manager.itemEnd(a),this.manager.itemEnd(r),s.disposeOnDemandRenderer()}};let f=!0,p=0,c=0,u=!0,l=0,M=0,y=!0,v=0,w=0;const x=()=>{if("function"==typeof n){n(new ProgressEvent("progress",{lengthComputable:f&&u&&y,loaded:c+M+w,total:p+l+v}))}};this.manager.itemStart(e),this.manager.itemStart(a),this.manager.itemStart(r);const C=new g(this._internalLoadingManager);C.setResponseType("arraybuffer"),C.setRequestHeader(this.requestHeader),C.setPath(this.path),C.setWithCredentials(this.withCredentials),C.load(e,async e=>{if("string"==typeof e)throw new Error("Invalid sdr buffer");o=e,await m()},e=>{f=e.lengthComputable,c=e.loaded,p=e.total,x()},a=>{this.manager.itemError(e),"function"==typeof i&&i(a)});const _=new g(this._internalLoadingManager);_.setResponseType("arraybuffer"),_.setRequestHeader(this.requestHeader),_.setPath(this.path),_.setWithCredentials(this.withCredentials),_.load(a,async e=>{if("string"==typeof e)throw new Error("Invalid gainmap buffer");d=e,await m()},e=>{u=e.lengthComputable,M=e.loaded,l=e.total,x()},e=>{this.manager.itemError(a),"function"==typeof i&&i(e)});const R=new g(this._internalLoadingManager);return R.setRequestHeader(this.requestHeader),R.setPath(this.path),R.setWithCredentials(this.withCredentials),R.load(r,async e=>{if("string"!=typeof e)throw new Error("Invalid metadata string");h=JSON.parse(e),await m()},e=>{y=e.lengthComputable,w=e.loaded,v=e.total,x()},e=>{this.manager.itemError(r),"function"==typeof i&&i(e)}),s}}class x extends v{constructor(e,a){super(e,a),r("HDRJPGLoader","@monogrid/gainmap-js","HDRJPGNodeLoader")}load(e,a,r,t){const n=this.prepareQuadRenderer(),d=new g(this._internalLoadingManager);return d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setPath(this.path),d.setWithCredentials(this.withCredentials),this.manager.itemStart(e),d.load(e,async r=>{if("string"==typeof r)throw new Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");const d=new Uint8Array(r);let h,m,f;try{const e=await i(d);h=e.sdr,m=e.gainMap,f=e.metadata}catch(a){if(!(a instanceof s||a instanceof o))throw a;console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),f={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},h=d}try{await this.render(n,f,h.buffer,m?.buffer)}catch(a){return this.manager.itemError(e),"function"==typeof t&&t(a),void n.disposeOnDemandRenderer()}"function"==typeof a&&a(n),this.manager.itemEnd(e),n.disposeOnDemandRenderer()},r,a=>{this.manager.itemError(e),"function"==typeof t&&t(a)}),n}}export{u as GainMapDecoderMaterial,w as GainMapLoader,o as GainMapNotFoundError,x as HDRJPGLoader,x as JPEGRLoader,n as LoaderBaseShared,e as QuadRenderer,s as XMPMetadataNotFoundError,t as createDecodeFunction,y as decode,i as extractGainmapFromJPEG};
|