@monogrid/gainmap-js 1.1.0 → 2.0.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 +22 -0
- package/README.md +21 -8
- package/dist/QuadRenderer-IDZuHqZM.js +178 -0
- package/dist/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-G_2thcKl.js} +1 -1
- package/dist/{compress-a4b59cab.js → compress-Cw5IwRTb.js} +1 -1
- package/dist/{loaders → core}/LoaderBase.d.ts +3 -3
- package/dist/{utils → core}/QuadRenderer.d.ts +6 -0
- package/dist/core/types.d.ts +64 -0
- package/dist/decode/decode.d.ts +56 -0
- package/dist/decode/extract.d.ts +10 -0
- package/dist/decode/index.d.ts +8 -0
- package/dist/{loaders → decode/loaders}/GainMapLoader.d.ts +4 -4
- package/dist/{loaders → decode/loaders}/JPEGRLoader.d.ts +5 -5
- package/dist/{materials → decode/materials}/GainMapDecoderMaterial.d.ts +3 -2
- package/dist/decode/types.d.ts +38 -0
- package/dist/decode/utils/MPFExtractor.d.ts +22 -0
- package/dist/decode/utils/extract-metadata-from-jpeg.d.ts +7 -0
- package/dist/decode.d.ts +1 -56
- package/dist/decode.js +737 -0
- package/dist/decode.umd.js +917 -0
- package/dist/{encode-utils → encode}/compress.d.ts +1 -1
- package/dist/encode/encode-and-compress.d.ts +61 -0
- package/dist/encode/encode.d.ts +58 -0
- package/dist/{encode-utils → encode}/get-gainmap.d.ts +3 -3
- package/dist/{encode-utils → encode}/get-sdr-rendition.d.ts +4 -5
- package/dist/encode/index.d.ts +10 -0
- package/dist/encode/types.d.ts +172 -0
- package/dist/encode.d.ts +1 -117
- package/dist/{index.js → encode.js} +42 -230
- package/dist/encode.umd.js +972 -0
- package/dist/libultrahdr/decode-jpeg-metadata.d.ts +31 -0
- package/dist/libultrahdr/encode-jpeg-metadata.d.ts +84 -0
- package/dist/libultrahdr/library.d.ts +9 -0
- package/dist/libultrahdr.d.ts +3 -123
- package/dist/libultrahdr.js +92 -167
- package/dist/libultrahdr.umd.js +91 -530
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.umd.js +1 -3
- package/dist/worker-types.d.ts +2 -2
- package/dist/worker.js +3 -3
- package/dist/worker.umd.js +1 -1
- package/package.json +36 -29
- package/dist/LoaderBase-aa4842c4.js +0 -373
- package/dist/index.d.ts +0 -11
- package/dist/index.umd.js +0 -1360
- package/dist/materials/index.d.ts +0 -3
- package/dist/types.d.ts +0 -262
- /package/dist/{utils → core}/get-data-texture.d.ts +0 -0
- /package/dist/{encode-utils → encode}/find-texture-min-max.d.ts +0 -0
- /package/dist/{materials → encode/materials}/GainMapEncoderMaterial.d.ts +0 -0
- /package/dist/{materials → encode/materials}/SDRMaterial.d.ts +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CompressedImage, EncodingParametersWithCompression } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a Gainmap starting from an HDR file into compressed file formats (`image/jpeg`, `image/webp` or `image/png`).
|
|
4
|
+
*
|
|
5
|
+
* Uses {@link encode} internally, then pipes the results to {@link compress}.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* if a `renderer` parameter is not provided
|
|
9
|
+
* This function will automatically dispose its "disposable"
|
|
10
|
+
* renderer, no need to dispose it manually later
|
|
11
|
+
*
|
|
12
|
+
* @category Encoding Functions
|
|
13
|
+
* @group Encoding Functions
|
|
14
|
+
* @example
|
|
15
|
+
* import { encodeAndCompress, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
16
|
+
* import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
|
|
17
|
+
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
18
|
+
*
|
|
19
|
+
* // load an HDR file
|
|
20
|
+
* const loader = new EXRLoader()
|
|
21
|
+
* const image = await loader.loadAsync('image.exr')
|
|
22
|
+
*
|
|
23
|
+
* // find RAW RGB Max value of a texture
|
|
24
|
+
* const textureMax = await findTextureMinMax(image)
|
|
25
|
+
*
|
|
26
|
+
* // Encode the gainmap
|
|
27
|
+
* const encodingResult = await encodeAndCompress({
|
|
28
|
+
* image,
|
|
29
|
+
* maxContentBoost: Math.max.apply(this, textureMax),
|
|
30
|
+
* mimeType: 'image/jpeg'
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* // embed the compressed images + metadata into a single
|
|
34
|
+
* // JPEG file
|
|
35
|
+
* const jpeg = await encodeJPEGMetadata({
|
|
36
|
+
* ...encodingResult,
|
|
37
|
+
* sdr: encodingResult.sdr,
|
|
38
|
+
* gainMap: encodingResult.gainMap
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* // `jpeg` will be an `Uint8Array` which can be saved somewhere
|
|
42
|
+
*
|
|
43
|
+
*
|
|
44
|
+
* @param params Encoding Parameters
|
|
45
|
+
* @throws {Error} if the browser does not support [createImageBitmap](https://caniuse.com/createimagebitmap)
|
|
46
|
+
*/
|
|
47
|
+
export declare const encodeAndCompress: (params: EncodingParametersWithCompression) => Promise<{
|
|
48
|
+
sdr: CompressedImage;
|
|
49
|
+
gainMap: CompressedImage;
|
|
50
|
+
rawSDR: Uint8ClampedArray;
|
|
51
|
+
rawGainMap: Uint8ClampedArray;
|
|
52
|
+
gamma: [number, number, number];
|
|
53
|
+
hdrCapacityMin: number;
|
|
54
|
+
hdrCapacityMax: number;
|
|
55
|
+
offsetSdr: [number, number, number];
|
|
56
|
+
offsetHdr: [number, number, number];
|
|
57
|
+
gainMapMin: [number, number, number];
|
|
58
|
+
gainMapMax: [number, number, number];
|
|
59
|
+
hdr: import("three").DataTexture;
|
|
60
|
+
getMetadata: () => import(".").GainMapMetadata;
|
|
61
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { GainMapMetadata } from '../core/types';
|
|
2
|
+
import { EncodingParametersBase } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Encodes a Gainmap starting from an HDR file.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* if you do not pass a `renderer` parameter
|
|
8
|
+
* you must manually dispose the result
|
|
9
|
+
* ```js
|
|
10
|
+
* const encodingResult = await encode({ ... })
|
|
11
|
+
* // do something with the buffers
|
|
12
|
+
* const sdr = encodingResult.sdr.getArray()
|
|
13
|
+
* const gainMap = encodingResult.gainMap.getArray()
|
|
14
|
+
* // after that
|
|
15
|
+
* encodingResult.sdr.dispose()
|
|
16
|
+
* encodingResult.gainMap.dispose()
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Encoding Functions
|
|
20
|
+
* @group Encoding Functions
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { encode, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
24
|
+
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
25
|
+
*
|
|
26
|
+
* // load an HDR file
|
|
27
|
+
* const loader = new EXRLoader()
|
|
28
|
+
* const image = await loader.loadAsync('image.exr')
|
|
29
|
+
*
|
|
30
|
+
* // find RAW RGB Max value of a texture
|
|
31
|
+
* const textureMax = await findTextureMinMax(image)
|
|
32
|
+
*
|
|
33
|
+
* // Encode the gainmap
|
|
34
|
+
* const encodingResult = encode({
|
|
35
|
+
* image,
|
|
36
|
+
* // this will encode the full HDR range
|
|
37
|
+
* maxContentBoost: Math.max.apply(this, textureMax)
|
|
38
|
+
* })
|
|
39
|
+
* // can be re-encoded after changing parameters
|
|
40
|
+
* encodingResult.sdr.material.exposure = 0.9
|
|
41
|
+
* encodingResult.sdr.render()
|
|
42
|
+
* // or
|
|
43
|
+
* encodingResult.gainMap.material.gamma = [1.1, 1.1, 1.1]
|
|
44
|
+
* encodingResult.gainMap.render()
|
|
45
|
+
*
|
|
46
|
+
* // must be manually disposed
|
|
47
|
+
* encodingResult.sdr.dispose()
|
|
48
|
+
* encodingResult.gainMap.dispose()
|
|
49
|
+
*
|
|
50
|
+
* @param params Encoding Parameters
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export declare const encode: (params: EncodingParametersBase) => {
|
|
54
|
+
sdr: import("../decode").QuadRenderer<1009, import(".").SDRMaterial>;
|
|
55
|
+
gainMap: import("../decode").QuadRenderer<1009, import(".").GainMapEncoderMaterial>;
|
|
56
|
+
hdr: import("three").DataTexture;
|
|
57
|
+
getMetadata: () => GainMapMetadata;
|
|
58
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { QuadRenderer } from '../core/QuadRenderer';
|
|
2
|
+
import { GainMapEncoderMaterial } from './materials/GainMapEncoderMaterial';
|
|
3
|
+
import { EncodingParametersBase } from './types';
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param params
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export { SDRMaterial };
|
|
2
|
+
import { QuadRenderer } from '../core/QuadRenderer';
|
|
3
|
+
import { SDRMaterial } from './materials/SDRMaterial';
|
|
5
4
|
/**
|
|
6
5
|
* Renders an SDR Representation of an HDR Image
|
|
7
6
|
*
|
|
@@ -9,8 +8,8 @@ export { SDRMaterial };
|
|
|
9
8
|
* @group Encoding Functions
|
|
10
9
|
*
|
|
11
10
|
* @param hdrTexture The HDR image to be rendered
|
|
12
|
-
* @param renderer (optional) WebGLRenderer to use
|
|
13
|
-
* @param toneMapping (optional)
|
|
11
|
+
* @param renderer (optional) WebGLRenderer to use during the rendering, a disposable renderer will be create and destroyed if this is not provided.
|
|
12
|
+
* @param toneMapping (optional) Tone mapping to be applied to the SDR Rendition
|
|
14
13
|
* @throws {Error} if the WebGLRenderer fails to render the SDR image
|
|
15
14
|
*/
|
|
16
15
|
export declare const getSDRRendition: (hdrTexture: DataTexture, renderer?: WebGLRenderer, toneMapping?: ToneMapping) => QuadRenderer<1009, SDRMaterial>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from '../core/types';
|
|
2
|
+
export * from './compress';
|
|
3
|
+
export * from './encode';
|
|
4
|
+
export * from './encode-and-compress';
|
|
5
|
+
export * from './find-texture-min-max';
|
|
6
|
+
export * from './get-gainmap';
|
|
7
|
+
export * from './get-sdr-rendition';
|
|
8
|
+
export * from './materials/GainMapEncoderMaterial';
|
|
9
|
+
export * from './materials/SDRMaterial';
|
|
10
|
+
export * from './types';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
2
|
+
import { type EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
+
import { type LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
|
|
4
|
+
import { type RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
5
|
+
import { WorkerInterfaceImplementation } from '../worker-types';
|
|
6
|
+
/**
|
|
7
|
+
* Parameters used by content Creators in order to create a GainMap
|
|
8
|
+
* @category Gainmap Specifications
|
|
9
|
+
* @group Gainmap Specifications
|
|
10
|
+
*/
|
|
11
|
+
export type GainmapEncodingParameters = {
|
|
12
|
+
/**
|
|
13
|
+
* This is the offset to apply to the HDR pixel values during gain map generation and application.
|
|
14
|
+
* @defaultValue [1/64, 1/64, 1/64]
|
|
15
|
+
*/
|
|
16
|
+
offsetHdr?: [number, number, number];
|
|
17
|
+
/**
|
|
18
|
+
* This is the offset to apply to the SDR pixel values during gain map generation and application
|
|
19
|
+
* @defaultValue [1/64, 1/64, 1/64]
|
|
20
|
+
*/
|
|
21
|
+
offsetSdr?: [number, number, number];
|
|
22
|
+
/**
|
|
23
|
+
* This value lets the content creator constrain how much darker an image can get, when shown on an HDR display, relative to the SDR rendition.
|
|
24
|
+
* This value is a constant for a particular image.
|
|
25
|
+
* @defaultValue 1
|
|
26
|
+
* @remarks
|
|
27
|
+
* * If, for example, the value is 0.5, then for any given pixel, the linear luminance of the displayed HDR rendition must be (at the least) 0.5x the linear luminance of the SDR rendition.
|
|
28
|
+
* * In practice, this value is typically equal to or just less than 1.0.
|
|
29
|
+
* * Always less than or equal to Max content boost.
|
|
30
|
+
*
|
|
31
|
+
* Non Logarithmic space
|
|
32
|
+
*/
|
|
33
|
+
minContentBoost?: number;
|
|
34
|
+
/**
|
|
35
|
+
* This value lets the content creator constrain how much brighter an image can get, when shown on an HDR display, relative to the SDR rendition.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* * This value is a constant for a particular image.
|
|
39
|
+
* For example, if the value is four, then for any given pixel, the linear luminance of the
|
|
40
|
+
* displayed HDR rendition must be, at the most, 4x the linear luminance of the SDR rendition.
|
|
41
|
+
* In practice, this means that the brighter parts of the scene can be shown up to 4x brighter.
|
|
42
|
+
* * In practice, this value is typically greater than 1.0.
|
|
43
|
+
* * Always greater than or equal to Min content boost.
|
|
44
|
+
*
|
|
45
|
+
* Non Logarithmic space
|
|
46
|
+
*/
|
|
47
|
+
maxContentBoost: number;
|
|
48
|
+
/**
|
|
49
|
+
* This is the gamma to apply to the stored map values.
|
|
50
|
+
*
|
|
51
|
+
* @defaultValue [1, 1, 1]
|
|
52
|
+
* @remarks
|
|
53
|
+
* * Typically you can use a gamma of 1.0.
|
|
54
|
+
* * You can use a different value if your gain map has a very uneven distribution of log_recovery(x, y) values.
|
|
55
|
+
* For example, this might apply if a gain map has a lot of detail just above SDR range
|
|
56
|
+
* (represented as small log_recovery(x, y) values), and a very large map_max_log2 for the top
|
|
57
|
+
* end of the HDR rendition's desired brightness (represented by large log_recovery(x, y) values).
|
|
58
|
+
* In this case, you can use a map_gamma higher than 1.0 so that recovery(x, y)
|
|
59
|
+
* can precisely encode the detail in both the low end and high end of log_recovery(x, y).
|
|
60
|
+
*/
|
|
61
|
+
gamma?: [number, number, number];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Parameters used to Encode a GainMap
|
|
65
|
+
*
|
|
66
|
+
* @category Encoding Parameters
|
|
67
|
+
* @group Encoding Parameters
|
|
68
|
+
*/
|
|
69
|
+
export type EncodingParametersBase = GainmapEncodingParameters & {
|
|
70
|
+
/**
|
|
71
|
+
* Input image for encoding, must be an HDR image
|
|
72
|
+
*/
|
|
73
|
+
image: EXR | RGBE | LogLuv | DataTexture;
|
|
74
|
+
/**
|
|
75
|
+
* Optional WebGLRenderer
|
|
76
|
+
* @remarks
|
|
77
|
+
* will be created and destroyed on demand if not provided.
|
|
78
|
+
*/
|
|
79
|
+
renderer?: WebGLRenderer;
|
|
80
|
+
/**
|
|
81
|
+
* Optional tone mapping to apply to the SDR Rendition
|
|
82
|
+
* @defaultValue `ACESFilmicToneMapping`
|
|
83
|
+
*/
|
|
84
|
+
toneMapping?: ToneMapping;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* This library can provide gainmap compressed in these mimeTypes
|
|
88
|
+
*
|
|
89
|
+
* @category Compression
|
|
90
|
+
* @group Compression
|
|
91
|
+
*/
|
|
92
|
+
export type CompressionMimeType = 'image/png' | 'image/jpeg' | 'image/webp';
|
|
93
|
+
/**
|
|
94
|
+
* Accepted HDR image buffers, definitions coming from the THREE.js Library types
|
|
95
|
+
*
|
|
96
|
+
* @category General
|
|
97
|
+
* @group General
|
|
98
|
+
*/
|
|
99
|
+
export type HDRRawImageBuffer = EXR['data'] | RGBE['data'] | LogLuv['data'];
|
|
100
|
+
/**
|
|
101
|
+
* Raw HDR image data
|
|
102
|
+
*
|
|
103
|
+
* @category General
|
|
104
|
+
* @group General
|
|
105
|
+
*/
|
|
106
|
+
export type HDRRawImage = {
|
|
107
|
+
data: HDRRawImageBuffer;
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Options for compressing a RAW RGBA image into the specified mimeType
|
|
113
|
+
*
|
|
114
|
+
* @category Compression
|
|
115
|
+
* @group Compression
|
|
116
|
+
*/
|
|
117
|
+
export type CompressOptions = {
|
|
118
|
+
/**
|
|
119
|
+
* The mimeType of the output
|
|
120
|
+
*/
|
|
121
|
+
mimeType: CompressionMimeType;
|
|
122
|
+
/**
|
|
123
|
+
* Encoding quality [0-1]
|
|
124
|
+
*/
|
|
125
|
+
quality?: number;
|
|
126
|
+
/**
|
|
127
|
+
* FlipY of the encoding process
|
|
128
|
+
*/
|
|
129
|
+
flipY?: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Data structure representing a compressed image with a mimeType
|
|
133
|
+
*
|
|
134
|
+
* @category Compression
|
|
135
|
+
* @group Compression
|
|
136
|
+
*/
|
|
137
|
+
export type CompressedImage = {
|
|
138
|
+
data: Uint8Array;
|
|
139
|
+
mimeType: CompressionMimeType;
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* @category Compression
|
|
145
|
+
* @group Compression
|
|
146
|
+
*/
|
|
147
|
+
export type CompressParameters = CompressOptions & ({
|
|
148
|
+
/**
|
|
149
|
+
* RAW RGBA Image Data
|
|
150
|
+
*/
|
|
151
|
+
source: ImageData;
|
|
152
|
+
} | {
|
|
153
|
+
/**
|
|
154
|
+
* Encoded Image Data with a mimeType
|
|
155
|
+
*/
|
|
156
|
+
source: Uint8Array | Uint8ClampedArray;
|
|
157
|
+
/**
|
|
158
|
+
* mimeType of the encoded input
|
|
159
|
+
*/
|
|
160
|
+
sourceMimeType: string;
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Additional parameters to encode a GainMap compressed with a mimeType
|
|
164
|
+
* @category Encoding Parameters
|
|
165
|
+
* @group Encoding Parameters
|
|
166
|
+
*/
|
|
167
|
+
export type EncodingParametersWithCompression = EncodingParametersBase & CompressOptions & {
|
|
168
|
+
/**
|
|
169
|
+
* Encodes the Gainmap using a Web Worker
|
|
170
|
+
*/
|
|
171
|
+
withWorker?: WorkerInterfaceImplementation;
|
|
172
|
+
};
|
package/dist/encode.d.ts
CHANGED
|
@@ -1,117 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Encodes a Gainmap starting from an HDR file.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* if you do not pass a `renderer` parameter
|
|
7
|
-
* you must manually dispose the result
|
|
8
|
-
* ```js
|
|
9
|
-
* const encodingResult = await encode({ ... })
|
|
10
|
-
* // do something with the buffers
|
|
11
|
-
* const sdr = encodingResult.sdr.getArray()
|
|
12
|
-
* const gainMap = encodingResult.gainMap.getArray()
|
|
13
|
-
* // after that
|
|
14
|
-
* encodingResult.sdr.dispose()
|
|
15
|
-
* encodingResult.gainMap.dispose()
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @category Encoding Functions
|
|
19
|
-
* @group Encoding Functions
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* import { encode, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
23
|
-
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
24
|
-
*
|
|
25
|
-
* // load an HDR file
|
|
26
|
-
* const loader = new EXRLoader()
|
|
27
|
-
* const image = await loader.loadAsync('image.exr')
|
|
28
|
-
*
|
|
29
|
-
* // find RAW RGB Max value of a texture
|
|
30
|
-
* const textureMax = await findTextureMinMax(image)
|
|
31
|
-
*
|
|
32
|
-
* // Encode the gainmap
|
|
33
|
-
* const encodingResult = encode({
|
|
34
|
-
* image,
|
|
35
|
-
* // this will encode the full HDR range
|
|
36
|
-
* maxContentBoost: Math.max.apply(this, textureMax)
|
|
37
|
-
* })
|
|
38
|
-
* // can be re-encoded after changing parameters
|
|
39
|
-
* encodingResult.sdr.material.exposure = 0.9
|
|
40
|
-
* encodingResult.sdr.render()
|
|
41
|
-
* // or
|
|
42
|
-
* encodingResult.gainMap.material.gamma = [1.1, 1.1, 1.1]
|
|
43
|
-
* encodingResult.gainMap.render()
|
|
44
|
-
*
|
|
45
|
-
* // must be manually disposed
|
|
46
|
-
* encodingResult.sdr.dispose()
|
|
47
|
-
* encodingResult.gainMap.dispose()
|
|
48
|
-
*
|
|
49
|
-
* @param params Encoding Paramaters
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
export declare const encode: (params: EncodingParametersBase) => {
|
|
53
|
-
sdr: import(".").QuadRenderer<1009, import("./materials/SDRMaterial").SDRMaterial>;
|
|
54
|
-
gainMap: import(".").QuadRenderer<1009, import("./materials").GainMapEncoderMaterial>;
|
|
55
|
-
hdr: import("three").DataTexture;
|
|
56
|
-
getMetadata: () => GainMapMetadata;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Encodes a Gainmap starting from an HDR file into compressed file formats (`image/jpeg`, `image/webp` or `image/png`).
|
|
60
|
-
*
|
|
61
|
-
* Uses {@link encode} internally, then pipes the results to {@link compress}.
|
|
62
|
-
*
|
|
63
|
-
* @remarks
|
|
64
|
-
* if a `renderer` parameter is not provided
|
|
65
|
-
* This function will automatically dispose its "disposable"
|
|
66
|
-
* renderer, no need to disapose it manually later
|
|
67
|
-
*
|
|
68
|
-
* @category Encoding Functions
|
|
69
|
-
* @group Encoding Functions
|
|
70
|
-
* @example
|
|
71
|
-
* import { encodeAndCompress, findTextureMinMax } from '@monogrid/gainmap-js'
|
|
72
|
-
* import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
|
|
73
|
-
* import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js'
|
|
74
|
-
*
|
|
75
|
-
* // load an HDR file
|
|
76
|
-
* const loader = new EXRLoader()
|
|
77
|
-
* const image = await loader.loadAsync('image.exr')
|
|
78
|
-
*
|
|
79
|
-
* // find RAW RGB Max value of a texture
|
|
80
|
-
* const textureMax = await findTextureMinMax(image)
|
|
81
|
-
*
|
|
82
|
-
* // Encode the gainmap
|
|
83
|
-
* const encodingResult = await encodeAndCompress({
|
|
84
|
-
* image,
|
|
85
|
-
* maxContentBoost: Math.max.apply(this, textureMax),
|
|
86
|
-
* mimeType: 'image/jpeg'
|
|
87
|
-
* })
|
|
88
|
-
*
|
|
89
|
-
* // embed the compressed images + metadata into a single
|
|
90
|
-
* // JPEG file
|
|
91
|
-
* const jpeg = await encodeJPEGMetadata({
|
|
92
|
-
* ...encodingResult,
|
|
93
|
-
* sdr: encodingResult.sdr,
|
|
94
|
-
* gainMap: encodingResult.gainMap
|
|
95
|
-
* })
|
|
96
|
-
*
|
|
97
|
-
* // `jpeg` will be an `Uint8Array` which can be saved somewhere
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @param params Encoding Paramaters
|
|
101
|
-
* @throws {Error} if the browser does not support [createImageBitmap](https://caniuse.com/createimagebitmap)
|
|
102
|
-
*/
|
|
103
|
-
export declare const encodeAndCompress: (params: EncodingParametersWithCompression) => Promise<{
|
|
104
|
-
sdr: CompressedImage;
|
|
105
|
-
gainMap: CompressedImage;
|
|
106
|
-
rawSDR: Uint8ClampedArray;
|
|
107
|
-
rawGainMap: Uint8ClampedArray;
|
|
108
|
-
gamma: [number, number, number];
|
|
109
|
-
hdrCapacityMin: number;
|
|
110
|
-
hdrCapacityMax: number;
|
|
111
|
-
offsetSdr: [number, number, number];
|
|
112
|
-
offsetHdr: [number, number, number];
|
|
113
|
-
gainMapMin: [number, number, number];
|
|
114
|
-
gainMapMax: [number, number, number];
|
|
115
|
-
hdr: import("three").DataTexture;
|
|
116
|
-
getMetadata: () => GainMapMetadata;
|
|
117
|
-
}>;
|
|
1
|
+
export * from './encode/index';
|