@monogrid/gainmap-js 3.1.0 → 3.2.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 +7 -0
- package/CODE_OF_CONDUCT.md +1 -1
- package/CONTRIBUTING.md +1 -1
- package/README.md +105 -2
- package/dist/Loader-BZcKUVaX.js +424 -0
- package/dist/{QuadRenderer-DuOPRGA4.js → QuadRenderer-Y5tm-R3m.js} +39 -30
- package/dist/{_commonjsHelpers-DeBGiDfT.js → _commonjsHelpers-CuGYGi_5.js} +2 -2
- package/dist/{compress-B6OswAu8.js → compress-BaKKOAXI.js} +2 -3
- package/dist/core/QuadRenderer.d.ts +2 -2
- package/dist/core/get-data-texture.d.ts +4 -3
- package/dist/core/types.d.ts +2 -1
- package/dist/decode/index.d.ts +1 -11
- package/dist/decode/shared/Loader.d.ts +59 -0
- package/dist/decode/shared/decode.d.ts +24 -0
- package/dist/decode/{extract.d.ts → shared/extract.d.ts} +4 -4
- package/dist/decode/shared/index.d.ts +8 -0
- package/dist/decode/shared/types.d.ts +53 -0
- package/dist/decode/{utils → shared/utils}/MPFExtractor.d.ts +1 -1
- package/dist/decode/{utils → shared/utils}/extractXMP.d.ts +1 -1
- package/dist/decode/{decode.d.ts → webgl/decode.d.ts} +6 -6
- package/dist/decode/webgl/index.d.ts +8 -0
- package/dist/decode/{loaders → webgl/loaders}/GainMapLoader.d.ts +5 -6
- package/dist/decode/{loaders → webgl/loaders}/HDRJPGLoader.d.ts +6 -7
- package/dist/decode/webgl/loaders/LoaderBaseWebGL.d.ts +20 -0
- package/dist/decode/{materials → webgl/materials}/GainMapDecoderMaterial.d.ts +2 -2
- package/dist/decode/webgpu/core/QuadRenderer.d.ts +153 -0
- package/dist/decode/webgpu/decode.d.ts +60 -0
- package/dist/decode/webgpu/index.d.ts +8 -0
- package/dist/decode/webgpu/loaders/GainMapLoader.d.ts +69 -0
- package/dist/decode/webgpu/loaders/HDRJPGLoader.d.ts +65 -0
- package/dist/decode/webgpu/loaders/LoaderBaseWebGPU.d.ts +20 -0
- package/dist/decode/webgpu/materials/GainMapDecoderMaterial.d.ts +78 -0
- package/dist/decode.js +45 -426
- package/dist/decode.umd.cjs +360 -314
- package/dist/decode.webgpu.js +814 -0
- package/dist/decode.webgpu.umd.cjs +1244 -0
- package/dist/encode/encode-and-compress.d.ts +3 -3
- package/dist/encode/encode.d.ts +3 -3
- package/dist/encode/find-texture-min-max.d.ts +4 -3
- package/dist/encode/types.d.ts +4 -3
- package/dist/encode.js +32 -11
- package/dist/encode.umd.cjs +67 -38
- package/dist/libultrahdr/encode-jpeg-metadata.d.ts +2 -2
- package/dist/libultrahdr.js +11 -23
- package/dist/libultrahdr.umd.cjs +11 -23
- package/dist/worker-interface.js +74 -64
- package/dist/worker-interface.umd.cjs +73 -63
- package/dist/worker.js +103 -88
- package/dist/worker.umd.cjs +103 -89
- package/package.json +79 -72
- package/dist/decode/loaders/LoaderBase.d.ts +0 -45
- package/dist/decode/types.d.ts +0 -42
- /package/dist/decode/{errors → shared/errors}/GainMapNotFoundError.d.ts +0 -0
- /package/dist/decode/{errors → shared/errors}/XMPMetadataNotFoundError.d.ts +0 -0
- /package/dist/decode/{utils → shared/utils}/get-html-image-from-blob.d.ts +0 -0
|
@@ -21,7 +21,7 @@ import { CompressedImage, EncodingParametersWithCompression } from './types';
|
|
|
21
21
|
* const image = await loader.loadAsync('image.exr')
|
|
22
22
|
*
|
|
23
23
|
* // find RAW RGB Max value of a texture
|
|
24
|
-
* const textureMax =
|
|
24
|
+
* const textureMax = findTextureMinMax(image)
|
|
25
25
|
*
|
|
26
26
|
* // Encode the gainmap
|
|
27
27
|
* const encodingResult = await encodeAndCompress({
|
|
@@ -47,8 +47,8 @@ import { CompressedImage, EncodingParametersWithCompression } from './types';
|
|
|
47
47
|
export declare const encodeAndCompress: (params: EncodingParametersWithCompression) => Promise<{
|
|
48
48
|
sdr: CompressedImage;
|
|
49
49
|
gainMap: CompressedImage;
|
|
50
|
-
rawSDR: Uint8ClampedArray
|
|
51
|
-
rawGainMap: Uint8ClampedArray
|
|
50
|
+
rawSDR: Uint8ClampedArray<ArrayBufferLike>;
|
|
51
|
+
rawGainMap: Uint8ClampedArray<ArrayBufferLike>;
|
|
52
52
|
gamma: [number, number, number];
|
|
53
53
|
hdrCapacityMin: number;
|
|
54
54
|
hdrCapacityMax: number;
|
package/dist/encode/encode.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { EncodingParametersBase } from './types';
|
|
|
28
28
|
* const image = await loader.loadAsync('image.exr')
|
|
29
29
|
*
|
|
30
30
|
* // find RAW RGB Max value of a texture
|
|
31
|
-
* const textureMax =
|
|
31
|
+
* const textureMax = findTextureMinMax(image)
|
|
32
32
|
*
|
|
33
33
|
* // Encode the gainmap
|
|
34
34
|
* const encodingResult = encode({
|
|
@@ -54,8 +54,8 @@ import { EncodingParametersBase } from './types';
|
|
|
54
54
|
* @returns
|
|
55
55
|
*/
|
|
56
56
|
export declare const encode: (params: EncodingParametersBase) => {
|
|
57
|
-
sdr: import("../
|
|
58
|
-
gainMap: import("../
|
|
57
|
+
sdr: import("../core").QuadRenderer<1009, import(".").SDRMaterial>;
|
|
58
|
+
gainMap: import("../core").QuadRenderer<1009, import(".").GainMapEncoderMaterial>;
|
|
59
59
|
hdr: import("three").DataTexture;
|
|
60
60
|
getMetadata: () => GainMapMetadata;
|
|
61
61
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataTexture, WebGLRenderer } from 'three';
|
|
2
|
-
import { EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
-
import {
|
|
2
|
+
import { EXR } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
3
|
+
import { HDR } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
4
|
+
import { RGBE } from 'three/examples/jsm/loaders/RGBELoader.js';
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
* @category Utility
|
|
@@ -11,4 +12,4 @@ import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
|
11
12
|
* @param renderer
|
|
12
13
|
* @returns
|
|
13
14
|
*/
|
|
14
|
-
export declare const findTextureMinMax: (image: EXR | RGBE | DataTexture, mode?: "min" | "max", renderer?: WebGLRenderer) => number[];
|
|
15
|
+
export declare const findTextureMinMax: (image: EXR | RGBE | HDR | DataTexture, mode?: "min" | "max", renderer?: WebGLRenderer) => number[];
|
package/dist/encode/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
2
|
-
import { type EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
|
-
import { type
|
|
2
|
+
import { type EXR } from 'three/examples/jsm/loaders/EXRLoader.js';
|
|
3
|
+
import { type HDR } from 'three/examples/jsm/loaders/HDRLoader.js';
|
|
4
|
+
import { type RGBE } from 'three/examples/jsm/loaders/RGBELoader.js';
|
|
4
5
|
import { QuadRendererTextureOptions } from '../decode';
|
|
5
6
|
import { WorkerInterfaceImplementation } from '../worker-types';
|
|
6
7
|
/**
|
|
@@ -70,7 +71,7 @@ export type EncodingParametersBase = GainmapEncodingParameters & {
|
|
|
70
71
|
/**
|
|
71
72
|
* Input image for encoding, must be an HDR image
|
|
72
73
|
*/
|
|
73
|
-
image: EXR | RGBE | DataTexture;
|
|
74
|
+
image: EXR | RGBE | HDR | DataTexture;
|
|
74
75
|
/**
|
|
75
76
|
* Optional WebGLRenderer
|
|
76
77
|
* @remarks
|
package/dist/encode.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
3
|
-
* With ❤️, by MONOGRID <
|
|
2
|
+
* @monogrid/gainmap-js v3.2.0
|
|
3
|
+
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { c as compress } from './compress-
|
|
7
|
-
import { DataTexture, RGBAFormat, UVMapping, RepeatWrapping, LinearFilter, LinearSRGBColorSpace, ShaderMaterial,
|
|
8
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
6
|
+
import { c as compress } from './compress-BaKKOAXI.js';
|
|
7
|
+
import { DataTexture, RGBAFormat, UVMapping, RepeatWrapping, LinearFilter, LinearSRGBColorSpace, ShaderMaterial, NoBlending, Vector3, UnsignedByteType, ACESFilmicToneMapping, LinearToneMapping, CineonToneMapping, ReinhardToneMapping, SRGBColorSpace, AlphaFormat, RGBFormat, DepthFormat, DepthStencilFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, Vector2, WebGLRenderTarget, ClampToEdgeWrapping, NearestFilter, DataUtils, FloatType } from 'three';
|
|
8
|
+
import { Q as QuadRenderer } from './QuadRenderer-Y5tm-R3m.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Utility function to obtain a `DataTexture` from various input formats
|
|
@@ -75,6 +75,11 @@ void main() {
|
|
|
75
75
|
* @group Materials
|
|
76
76
|
*/
|
|
77
77
|
class GainMapEncoderMaterial extends ShaderMaterial {
|
|
78
|
+
_minContentBoost;
|
|
79
|
+
_maxContentBoost;
|
|
80
|
+
_offsetSdr;
|
|
81
|
+
_offsetHdr;
|
|
82
|
+
_gamma;
|
|
78
83
|
/**
|
|
79
84
|
*
|
|
80
85
|
* @param params
|
|
@@ -339,6 +344,12 @@ void main() {
|
|
|
339
344
|
* @group Materials
|
|
340
345
|
*/
|
|
341
346
|
class SDRMaterial extends ShaderMaterial {
|
|
347
|
+
_brightness = 0;
|
|
348
|
+
_contrast = 1;
|
|
349
|
+
_saturation = 1;
|
|
350
|
+
_exposure = 1;
|
|
351
|
+
_toneMapping;
|
|
352
|
+
_map;
|
|
342
353
|
/**
|
|
343
354
|
*
|
|
344
355
|
* @param params
|
|
@@ -359,10 +370,6 @@ class SDRMaterial extends ShaderMaterial {
|
|
|
359
370
|
depthTest: false,
|
|
360
371
|
depthWrite: false
|
|
361
372
|
});
|
|
362
|
-
this._brightness = 0;
|
|
363
|
-
this._contrast = 1;
|
|
364
|
-
this._saturation = 1;
|
|
365
|
-
this._exposure = 1;
|
|
366
373
|
this._map = map;
|
|
367
374
|
this.toneMapping = this._toneMapping = toneMapping || ACESFilmicToneMapping;
|
|
368
375
|
this.needsUpdate = true;
|
|
@@ -486,7 +493,7 @@ const getSDRRendition = (hdrTexture, renderer, toneMapping, renderTargetOptions)
|
|
|
486
493
|
* const image = await loader.loadAsync('image.exr')
|
|
487
494
|
*
|
|
488
495
|
* // find RAW RGB Max value of a texture
|
|
489
|
-
* const textureMax =
|
|
496
|
+
* const textureMax = findTextureMinMax(image)
|
|
490
497
|
*
|
|
491
498
|
* // Encode the gainmap
|
|
492
499
|
* const encodingResult = encode({
|
|
@@ -561,7 +568,7 @@ const encode = (params) => {
|
|
|
561
568
|
* const image = await loader.loadAsync('image.exr')
|
|
562
569
|
*
|
|
563
570
|
* // find RAW RGB Max value of a texture
|
|
564
|
-
* const textureMax =
|
|
571
|
+
* const textureMax = findTextureMinMax(image)
|
|
565
572
|
*
|
|
566
573
|
* // Encode the gainmap
|
|
567
574
|
* const encodingResult = await encodeAndCompress({
|
|
@@ -701,6 +708,20 @@ void main() {
|
|
|
701
708
|
*/
|
|
702
709
|
const findTextureMinMax = (image, mode = 'max', renderer) => {
|
|
703
710
|
const srcTex = getDataTexture(image);
|
|
711
|
+
// check if texture has a valid format
|
|
712
|
+
if (srcTex.format !== AlphaFormat &&
|
|
713
|
+
srcTex.format !== RGBFormat &&
|
|
714
|
+
srcTex.format !== RGBAFormat &&
|
|
715
|
+
srcTex.format !== DepthFormat &&
|
|
716
|
+
srcTex.format !== DepthStencilFormat &&
|
|
717
|
+
srcTex.format !== RedFormat &&
|
|
718
|
+
srcTex.format !== RedIntegerFormat &&
|
|
719
|
+
srcTex.format !== RGFormat &&
|
|
720
|
+
srcTex.format !== RGIntegerFormat &&
|
|
721
|
+
srcTex.format !== RGBIntegerFormat &&
|
|
722
|
+
srcTex.format !== RGBAIntegerFormat) {
|
|
723
|
+
throw new Error('Unsupported texture format');
|
|
724
|
+
}
|
|
704
725
|
const cellSize = 2;
|
|
705
726
|
const mat = new ShaderMaterial({
|
|
706
727
|
vertexShader,
|
package/dist/encode.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
3
|
-
* With ❤️, by MONOGRID <
|
|
2
|
+
* @monogrid/gainmap-js v3.2.0
|
|
3
|
+
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
(function (global, factory) {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
const canvasToBlob = async (canvas, mimeType, quality) => {
|
|
22
22
|
if (typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {
|
|
23
|
-
return canvas.convertToBlob({ type: mimeType, quality: quality
|
|
23
|
+
return canvas.convertToBlob({ type: mimeType, quality: quality });
|
|
24
24
|
}
|
|
25
25
|
else if (canvas instanceof HTMLCanvasElement) {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
resolve(res);
|
|
30
30
|
else
|
|
31
31
|
reject(new Error('Failed to convert canvas to blob'));
|
|
32
|
-
}, mimeType, quality
|
|
32
|
+
}, mimeType, quality);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
/* istanbul ignore next
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
if (typeof createImageBitmap === 'undefined')
|
|
53
53
|
throw new Error('createImageBitmap() not supported.');
|
|
54
54
|
const { source, mimeType, quality, flipY } = params;
|
|
55
|
-
// eslint-disable-next-line no-undef
|
|
56
55
|
let imageBitmapSource;
|
|
57
56
|
if ((source instanceof Uint8Array || source instanceof Uint8ClampedArray) && 'sourceMimeType' in params) {
|
|
58
57
|
imageBitmapSource = new Blob([source], { type: params.sourceMimeType });
|
|
@@ -188,29 +187,24 @@
|
|
|
188
187
|
* @group Core
|
|
189
188
|
*/
|
|
190
189
|
class QuadRenderer {
|
|
190
|
+
_renderer;
|
|
191
|
+
_rendererIsDisposable = false;
|
|
192
|
+
_material;
|
|
193
|
+
_scene;
|
|
194
|
+
_camera;
|
|
195
|
+
_quad;
|
|
196
|
+
_renderTarget;
|
|
197
|
+
_width;
|
|
198
|
+
_height;
|
|
199
|
+
_type;
|
|
200
|
+
_colorSpace;
|
|
201
|
+
_supportsReadPixels = true;
|
|
191
202
|
/**
|
|
192
203
|
* Constructs a new QuadRenderer
|
|
193
204
|
*
|
|
194
205
|
* @param options Parameters for this QuadRenderer
|
|
195
206
|
*/
|
|
196
207
|
constructor(options) {
|
|
197
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
198
|
-
this._rendererIsDisposable = false;
|
|
199
|
-
this._supportsReadPixels = true;
|
|
200
|
-
/**
|
|
201
|
-
* Renders the input texture using the specified material
|
|
202
|
-
*/
|
|
203
|
-
this.render = () => {
|
|
204
|
-
this._renderer.setRenderTarget(this._renderTarget);
|
|
205
|
-
try {
|
|
206
|
-
this._renderer.render(this._scene, this._camera);
|
|
207
|
-
}
|
|
208
|
-
catch (e) {
|
|
209
|
-
this._renderer.setRenderTarget(null);
|
|
210
|
-
throw e;
|
|
211
|
-
}
|
|
212
|
-
this._renderer.setRenderTarget(null);
|
|
213
|
-
};
|
|
214
208
|
this._width = options.width;
|
|
215
209
|
this._height = options.height;
|
|
216
210
|
this._type = options.type;
|
|
@@ -223,13 +217,13 @@
|
|
|
223
217
|
// user options
|
|
224
218
|
type: this._type, // set in class property
|
|
225
219
|
colorSpace: this._colorSpace, // set in class property
|
|
226
|
-
anisotropy:
|
|
227
|
-
generateMipmaps:
|
|
228
|
-
magFilter:
|
|
229
|
-
minFilter:
|
|
230
|
-
samples:
|
|
231
|
-
wrapS:
|
|
232
|
-
wrapT:
|
|
220
|
+
anisotropy: options.renderTargetOptions?.anisotropy !== undefined ? options.renderTargetOptions?.anisotropy : 1,
|
|
221
|
+
generateMipmaps: options.renderTargetOptions?.generateMipmaps !== undefined ? options.renderTargetOptions?.generateMipmaps : false,
|
|
222
|
+
magFilter: options.renderTargetOptions?.magFilter !== undefined ? options.renderTargetOptions?.magFilter : three.LinearFilter,
|
|
223
|
+
minFilter: options.renderTargetOptions?.minFilter !== undefined ? options.renderTargetOptions?.minFilter : three.LinearFilter,
|
|
224
|
+
samples: options.renderTargetOptions?.samples !== undefined ? options.renderTargetOptions?.samples : undefined,
|
|
225
|
+
wrapS: options.renderTargetOptions?.wrapS !== undefined ? options.renderTargetOptions?.wrapS : three.ClampToEdgeWrapping,
|
|
226
|
+
wrapT: options.renderTargetOptions?.wrapT !== undefined ? options.renderTargetOptions?.wrapT : three.ClampToEdgeWrapping
|
|
233
227
|
};
|
|
234
228
|
this._material = options.material;
|
|
235
229
|
if (options.renderer) {
|
|
@@ -267,7 +261,7 @@
|
|
|
267
261
|
this._quad.geometry.computeBoundingBox();
|
|
268
262
|
this._scene.add(this._quad);
|
|
269
263
|
this._renderTarget = new three.WebGLRenderTarget(this.width, this.height, rtOptions);
|
|
270
|
-
this._renderTarget.texture.mapping =
|
|
264
|
+
this._renderTarget.texture.mapping = options.renderTargetOptions?.mapping !== undefined ? options.renderTargetOptions?.mapping : three.UVMapping;
|
|
271
265
|
}
|
|
272
266
|
/**
|
|
273
267
|
* Instantiates a temporary renderer
|
|
@@ -283,6 +277,20 @@
|
|
|
283
277
|
// this._rendererIsDisposable = true
|
|
284
278
|
return renderer;
|
|
285
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Renders the input texture using the specified material
|
|
282
|
+
*/
|
|
283
|
+
render = () => {
|
|
284
|
+
this._renderer.setRenderTarget(this._renderTarget);
|
|
285
|
+
try {
|
|
286
|
+
this._renderer.render(this._scene, this._camera);
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
this._renderer.setRenderTarget(null);
|
|
290
|
+
throw e;
|
|
291
|
+
}
|
|
292
|
+
this._renderer.setRenderTarget(null);
|
|
293
|
+
};
|
|
286
294
|
/**
|
|
287
295
|
* Obtains a Buffer containing the rendered texture.
|
|
288
296
|
*
|
|
@@ -308,11 +316,11 @@
|
|
|
308
316
|
// fixed values
|
|
309
317
|
this.toArray(), this.width, this.height, three.RGBAFormat, this._type,
|
|
310
318
|
// user values
|
|
311
|
-
|
|
319
|
+
options?.mapping || three.UVMapping, options?.wrapS || three.ClampToEdgeWrapping, options?.wrapT || three.ClampToEdgeWrapping, options?.magFilter || three.LinearFilter, options?.minFilter || three.LinearFilter, options?.anisotropy || 1,
|
|
312
320
|
// fixed value
|
|
313
321
|
three.LinearSRGBColorSpace);
|
|
314
322
|
// set this afterwards, we can't set it in constructor
|
|
315
|
-
returnValue.generateMipmaps =
|
|
323
|
+
returnValue.generateMipmaps = options?.generateMipmaps !== undefined ? options?.generateMipmaps : false;
|
|
316
324
|
return returnValue;
|
|
317
325
|
}
|
|
318
326
|
/**
|
|
@@ -455,6 +463,11 @@ void main() {
|
|
|
455
463
|
* @group Materials
|
|
456
464
|
*/
|
|
457
465
|
class GainMapEncoderMaterial extends three.ShaderMaterial {
|
|
466
|
+
_minContentBoost;
|
|
467
|
+
_maxContentBoost;
|
|
468
|
+
_offsetSdr;
|
|
469
|
+
_offsetHdr;
|
|
470
|
+
_gamma;
|
|
458
471
|
/**
|
|
459
472
|
*
|
|
460
473
|
* @param params
|
|
@@ -719,6 +732,12 @@ void main() {
|
|
|
719
732
|
* @group Materials
|
|
720
733
|
*/
|
|
721
734
|
class SDRMaterial extends three.ShaderMaterial {
|
|
735
|
+
_brightness = 0;
|
|
736
|
+
_contrast = 1;
|
|
737
|
+
_saturation = 1;
|
|
738
|
+
_exposure = 1;
|
|
739
|
+
_toneMapping;
|
|
740
|
+
_map;
|
|
722
741
|
/**
|
|
723
742
|
*
|
|
724
743
|
* @param params
|
|
@@ -739,10 +758,6 @@ void main() {
|
|
|
739
758
|
depthTest: false,
|
|
740
759
|
depthWrite: false
|
|
741
760
|
});
|
|
742
|
-
this._brightness = 0;
|
|
743
|
-
this._contrast = 1;
|
|
744
|
-
this._saturation = 1;
|
|
745
|
-
this._exposure = 1;
|
|
746
761
|
this._map = map;
|
|
747
762
|
this.toneMapping = this._toneMapping = toneMapping || three.ACESFilmicToneMapping;
|
|
748
763
|
this.needsUpdate = true;
|
|
@@ -866,7 +881,7 @@ void main() {
|
|
|
866
881
|
* const image = await loader.loadAsync('image.exr')
|
|
867
882
|
*
|
|
868
883
|
* // find RAW RGB Max value of a texture
|
|
869
|
-
* const textureMax =
|
|
884
|
+
* const textureMax = findTextureMinMax(image)
|
|
870
885
|
*
|
|
871
886
|
* // Encode the gainmap
|
|
872
887
|
* const encodingResult = encode({
|
|
@@ -941,7 +956,7 @@ void main() {
|
|
|
941
956
|
* const image = await loader.loadAsync('image.exr')
|
|
942
957
|
*
|
|
943
958
|
* // find RAW RGB Max value of a texture
|
|
944
|
-
* const textureMax =
|
|
959
|
+
* const textureMax = findTextureMinMax(image)
|
|
945
960
|
*
|
|
946
961
|
* // Encode the gainmap
|
|
947
962
|
* const encodingResult = await encodeAndCompress({
|
|
@@ -1081,6 +1096,20 @@ void main() {
|
|
|
1081
1096
|
*/
|
|
1082
1097
|
const findTextureMinMax = (image, mode = 'max', renderer) => {
|
|
1083
1098
|
const srcTex = getDataTexture(image);
|
|
1099
|
+
// check if texture has a valid format
|
|
1100
|
+
if (srcTex.format !== three.AlphaFormat &&
|
|
1101
|
+
srcTex.format !== three.RGBFormat &&
|
|
1102
|
+
srcTex.format !== three.RGBAFormat &&
|
|
1103
|
+
srcTex.format !== three.DepthFormat &&
|
|
1104
|
+
srcTex.format !== three.DepthStencilFormat &&
|
|
1105
|
+
srcTex.format !== three.RedFormat &&
|
|
1106
|
+
srcTex.format !== three.RedIntegerFormat &&
|
|
1107
|
+
srcTex.format !== three.RGFormat &&
|
|
1108
|
+
srcTex.format !== three.RGIntegerFormat &&
|
|
1109
|
+
srcTex.format !== three.RGBIntegerFormat &&
|
|
1110
|
+
srcTex.format !== three.RGBAIntegerFormat) {
|
|
1111
|
+
throw new Error('Unsupported texture format');
|
|
1112
|
+
}
|
|
1084
1113
|
const cellSize = 2;
|
|
1085
1114
|
const mat = new three.ShaderMaterial({
|
|
1086
1115
|
vertexShader,
|
|
@@ -17,7 +17,7 @@ import { type CompressedImage } from '../encode/types';
|
|
|
17
17
|
* const image = await loader.loadAsync('image.exr')
|
|
18
18
|
*
|
|
19
19
|
* // find RAW RGB Max value of a texture
|
|
20
|
-
* const textureMax =
|
|
20
|
+
* const textureMax = findTextureMinMax(image)
|
|
21
21
|
*
|
|
22
22
|
* // Encode the gainmap
|
|
23
23
|
* const encodingResult = encode({
|
|
@@ -81,4 +81,4 @@ import { type CompressedImage } from '../encode/types';
|
|
|
81
81
|
export declare const encodeJPEGMetadata: (encodingResult: GainMapMetadata & {
|
|
82
82
|
sdr: CompressedImage;
|
|
83
83
|
gainMap: CompressedImage;
|
|
84
|
-
}) => Promise<Uint8Array
|
|
84
|
+
}) => Promise<Uint8Array<ArrayBufferLike>>;
|
package/dist/libultrahdr.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
3
|
-
* With ❤️, by MONOGRID <
|
|
2
|
+
* @monogrid/gainmap-js v3.2.0
|
|
3
|
+
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var Module = (() => {
|
|
@@ -986,7 +986,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
986
986
|
}
|
|
987
987
|
};
|
|
988
988
|
|
|
989
|
-
|
|
989
|
+
Module['noExitRuntime'] || true;
|
|
990
990
|
|
|
991
991
|
var ptrToString = (ptr) => {
|
|
992
992
|
assert(typeof ptr === 'number');
|
|
@@ -1502,7 +1502,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
1502
1502
|
|
|
1503
1503
|
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1504
1504
|
|
|
1505
|
-
|
|
1505
|
+
(argTypes[1] !== null && classType !== null);
|
|
1506
1506
|
|
|
1507
1507
|
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1508
1508
|
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
@@ -1544,27 +1544,19 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
1544
1544
|
var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1545
1545
|
var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1546
1546
|
|
|
1547
|
-
if (isClassMethodFunc) {
|
|
1548
|
-
invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
1547
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
1552
1548
|
invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
|
|
1553
1549
|
args1.push("argType"+i);
|
|
1554
1550
|
args2.push(argTypes[i+2]);
|
|
1555
1551
|
}
|
|
1556
1552
|
|
|
1557
|
-
if (isClassMethodFunc) {
|
|
1558
|
-
argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
1553
|
invokerFnBody +=
|
|
1562
1554
|
(returns || isAsync ? "var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
|
|
1563
1555
|
|
|
1564
1556
|
if (needsDestructorStack) {
|
|
1565
1557
|
invokerFnBody += "runDestructors(destructors);\n";
|
|
1566
1558
|
} else {
|
|
1567
|
-
for (var i =
|
|
1559
|
+
for (var i = 2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
1568
1560
|
var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
|
|
1569
1561
|
if (argTypes[i].destructorFunction !== null) {
|
|
1570
1562
|
invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
|
|
@@ -4233,7 +4225,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
4233
4225
|
throw new FS.ErrnoError(63);
|
|
4234
4226
|
}
|
|
4235
4227
|
node.node_ops.setattr(node, {
|
|
4236
|
-
mode: (mode & 4095) | (node.mode &
|
|
4228
|
+
mode: (mode & 4095) | (node.mode & -4096),
|
|
4237
4229
|
timestamp: Date.now()
|
|
4238
4230
|
});
|
|
4239
4231
|
},
|
|
@@ -4354,7 +4346,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
4354
4346
|
}
|
|
4355
4347
|
// can't truncate a device
|
|
4356
4348
|
if (FS.isChrdev(node.mode)) {
|
|
4357
|
-
flags &=
|
|
4349
|
+
flags &= -513;
|
|
4358
4350
|
}
|
|
4359
4351
|
// if asked only for a directory, then this must be one
|
|
4360
4352
|
if ((flags & 65536) && !FS.isDir(node.mode)) {
|
|
@@ -4374,7 +4366,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
4374
4366
|
FS.truncate(node, 0);
|
|
4375
4367
|
}
|
|
4376
4368
|
// we've already handled these, don't pass down to the underlying vfs
|
|
4377
|
-
flags &=
|
|
4369
|
+
flags &= -131713;
|
|
4378
4370
|
|
|
4379
4371
|
// register the stream with the filesystem
|
|
4380
4372
|
var stream = FS.createStream({
|
|
@@ -5210,14 +5202,9 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
5210
5202
|
|
|
5211
5203
|
|
|
5212
5204
|
var runtimeKeepaliveCounter = 0;
|
|
5213
|
-
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
5214
5205
|
|
|
5215
5206
|
var _proc_exit = (code) => {
|
|
5216
5207
|
EXITSTATUS = code;
|
|
5217
|
-
if (!keepRuntimeAlive()) {
|
|
5218
|
-
if (Module['onExit']) Module['onExit'](code);
|
|
5219
|
-
ABORT = true;
|
|
5220
|
-
}
|
|
5221
5208
|
quit_(code, new ExitStatus(code));
|
|
5222
5209
|
};
|
|
5223
5210
|
|
|
@@ -5229,7 +5216,7 @@ function unexportedRuntimeSymbol(sym) {
|
|
|
5229
5216
|
checkUnflushedContent();
|
|
5230
5217
|
|
|
5231
5218
|
// if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
|
|
5232
|
-
if (
|
|
5219
|
+
if (!implicit) {
|
|
5233
5220
|
var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
|
|
5234
5221
|
readyPromiseReject(msg);
|
|
5235
5222
|
err(msg);
|
|
@@ -6533,6 +6520,7 @@ let library;
|
|
|
6533
6520
|
*/
|
|
6534
6521
|
const getLibrary = async () => {
|
|
6535
6522
|
if (!library) {
|
|
6523
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
6536
6524
|
library = await Module();
|
|
6537
6525
|
}
|
|
6538
6526
|
return library;
|
|
@@ -6627,7 +6615,7 @@ const decodeJPEGMetadata = async (file) => {
|
|
|
6627
6615
|
* const image = await loader.loadAsync('image.exr')
|
|
6628
6616
|
*
|
|
6629
6617
|
* // find RAW RGB Max value of a texture
|
|
6630
|
-
* const textureMax =
|
|
6618
|
+
* const textureMax = findTextureMinMax(image)
|
|
6631
6619
|
*
|
|
6632
6620
|
* // Encode the gainmap
|
|
6633
6621
|
* const encodingResult = encode({
|
package/dist/libultrahdr.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v3.
|
|
3
|
-
* With ❤️, by MONOGRID <
|
|
2
|
+
* @monogrid/gainmap-js v3.2.0
|
|
3
|
+
* With ❤️, by MONOGRID <gainmap@monogrid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
(function (global, factory) {
|
|
@@ -993,7 +993,7 @@
|
|
|
993
993
|
}
|
|
994
994
|
};
|
|
995
995
|
|
|
996
|
-
|
|
996
|
+
Module['noExitRuntime'] || true;
|
|
997
997
|
|
|
998
998
|
var ptrToString = (ptr) => {
|
|
999
999
|
assert(typeof ptr === 'number');
|
|
@@ -1509,7 +1509,7 @@
|
|
|
1509
1509
|
|
|
1510
1510
|
assert(!isAsync, 'Async bindings are only supported with JSPI.');
|
|
1511
1511
|
|
|
1512
|
-
|
|
1512
|
+
(argTypes[1] !== null && classType !== null);
|
|
1513
1513
|
|
|
1514
1514
|
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
1515
1515
|
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
@@ -1551,27 +1551,19 @@
|
|
|
1551
1551
|
var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
|
|
1552
1552
|
var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
|
|
1553
1553
|
|
|
1554
|
-
if (isClassMethodFunc) {
|
|
1555
|
-
invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n";
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
1554
|
for (var i = 0; i < argCount - 2; ++i) {
|
|
1559
1555
|
invokerFnBody += "var arg"+i+"Wired = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n";
|
|
1560
1556
|
args1.push("argType"+i);
|
|
1561
1557
|
args2.push(argTypes[i+2]);
|
|
1562
1558
|
}
|
|
1563
1559
|
|
|
1564
|
-
if (isClassMethodFunc) {
|
|
1565
|
-
argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
1560
|
invokerFnBody +=
|
|
1569
1561
|
(returns || isAsync ? "var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
|
|
1570
1562
|
|
|
1571
1563
|
if (needsDestructorStack) {
|
|
1572
1564
|
invokerFnBody += "runDestructors(destructors);\n";
|
|
1573
1565
|
} else {
|
|
1574
|
-
for (var i =
|
|
1566
|
+
for (var i = 2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
1575
1567
|
var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
|
|
1576
1568
|
if (argTypes[i].destructorFunction !== null) {
|
|
1577
1569
|
invokerFnBody += paramName+"_dtor("+paramName+"); // "+argTypes[i].name+"\n";
|
|
@@ -4240,7 +4232,7 @@
|
|
|
4240
4232
|
throw new FS.ErrnoError(63);
|
|
4241
4233
|
}
|
|
4242
4234
|
node.node_ops.setattr(node, {
|
|
4243
|
-
mode: (mode & 4095) | (node.mode &
|
|
4235
|
+
mode: (mode & 4095) | (node.mode & -4096),
|
|
4244
4236
|
timestamp: Date.now()
|
|
4245
4237
|
});
|
|
4246
4238
|
},
|
|
@@ -4361,7 +4353,7 @@
|
|
|
4361
4353
|
}
|
|
4362
4354
|
// can't truncate a device
|
|
4363
4355
|
if (FS.isChrdev(node.mode)) {
|
|
4364
|
-
flags &=
|
|
4356
|
+
flags &= -513;
|
|
4365
4357
|
}
|
|
4366
4358
|
// if asked only for a directory, then this must be one
|
|
4367
4359
|
if ((flags & 65536) && !FS.isDir(node.mode)) {
|
|
@@ -4381,7 +4373,7 @@
|
|
|
4381
4373
|
FS.truncate(node, 0);
|
|
4382
4374
|
}
|
|
4383
4375
|
// we've already handled these, don't pass down to the underlying vfs
|
|
4384
|
-
flags &=
|
|
4376
|
+
flags &= -131713;
|
|
4385
4377
|
|
|
4386
4378
|
// register the stream with the filesystem
|
|
4387
4379
|
var stream = FS.createStream({
|
|
@@ -5217,14 +5209,9 @@
|
|
|
5217
5209
|
|
|
5218
5210
|
|
|
5219
5211
|
var runtimeKeepaliveCounter = 0;
|
|
5220
|
-
var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
|
|
5221
5212
|
|
|
5222
5213
|
var _proc_exit = (code) => {
|
|
5223
5214
|
EXITSTATUS = code;
|
|
5224
|
-
if (!keepRuntimeAlive()) {
|
|
5225
|
-
if (Module['onExit']) Module['onExit'](code);
|
|
5226
|
-
ABORT = true;
|
|
5227
|
-
}
|
|
5228
5215
|
quit_(code, new ExitStatus(code));
|
|
5229
5216
|
};
|
|
5230
5217
|
|
|
@@ -5236,7 +5223,7 @@
|
|
|
5236
5223
|
checkUnflushedContent();
|
|
5237
5224
|
|
|
5238
5225
|
// if exit() was called explicitly, warn the user if the runtime isn't actually being shut down
|
|
5239
|
-
if (
|
|
5226
|
+
if (!implicit) {
|
|
5240
5227
|
var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
|
|
5241
5228
|
readyPromiseReject(msg);
|
|
5242
5229
|
err(msg);
|
|
@@ -6540,6 +6527,7 @@
|
|
|
6540
6527
|
*/
|
|
6541
6528
|
const getLibrary = async () => {
|
|
6542
6529
|
if (!library) {
|
|
6530
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
6543
6531
|
library = await Module();
|
|
6544
6532
|
}
|
|
6545
6533
|
return library;
|
|
@@ -6634,7 +6622,7 @@
|
|
|
6634
6622
|
* const image = await loader.loadAsync('image.exr')
|
|
6635
6623
|
*
|
|
6636
6624
|
* // find RAW RGB Max value of a texture
|
|
6637
|
-
* const textureMax =
|
|
6625
|
+
* const textureMax = findTextureMinMax(image)
|
|
6638
6626
|
*
|
|
6639
6627
|
* // Encode the gainmap
|
|
6640
6628
|
* const encodingResult = encode({
|