@monogrid/gainmap-js 2.0.7 → 3.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 +17 -0
- package/dist/{QuadRenderer-QXcVmgNm.js → QuadRenderer-LVKXL-q4.js} +45 -38
- package/dist/{_commonjsHelpers-ftl_lJMx.js → _commonjsHelpers-7LfDr0XA.js} +1 -1
- package/dist/{compress-MvOX-rlz.js → compress-AzvRyeg9.js} +1 -1
- package/dist/core/QuadRenderer.d.ts +34 -2
- package/dist/core/types.d.ts +14 -0
- package/dist/decode/loaders/LoaderBase.d.ts +9 -1
- package/dist/decode/types.d.ts +5 -1
- package/dist/decode.js +58 -8
- package/dist/decode.umd.js +100 -43
- package/dist/encode/get-sdr-rendition.d.ts +3 -1
- package/dist/encode/types.d.ts +5 -0
- package/dist/encode.js +32 -8
- package/dist/encode.umd.js +73 -42
- package/dist/libultrahdr.js +1 -1
- package/dist/libultrahdr.umd.js +1 -1
- package/dist/worker-interface.js +2 -2
- package/dist/worker-interface.umd.js +1 -1
- package/dist/worker.js +3 -3
- package/dist/worker.umd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
# [3.0.0](https://github.com/MONOGRID/gainmap-js/compare/v2.0.7...v3.0.0) (2023-11-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **loaders:** properly catches render errors and calls onError callback ([b9bcdd1](https://github.com/MONOGRID/gainmap-js/commit/b9bcdd127576fa61c6ee92c876f4845cd80b4d34)), closes [#16](https://github.com/MONOGRID/gainmap-js/issues/16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** disables default mipmap generation, enables user to specify renderTarget (and toDataTexture) options ([147d278](https://github.com/MONOGRID/gainmap-js/commit/147d2783224cb0a2039d762abf4e4b972b0e86da)), closes [#14](https://github.com/MONOGRID/gainmap-js/issues/14) [#15](https://github.com/MONOGRID/gainmap-js/issues/15)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **core:** `generateMipmaps` is no longer `true` by default, both `minFilter` is no longer `LinearMipMapLinearFilter` by default but `LinearFilter`, `wrapS` and `warpT` are no longer `RepeatWrapping` by default but `ClampToEdgeWrapping`
|
|
17
|
+
|
|
1
18
|
## [2.0.7](https://github.com/MONOGRID/gainmap-js/compare/v2.0.6...v2.0.7) (2023-11-23)
|
|
2
19
|
|
|
3
20
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Scene, OrthographicCamera, HalfFloatType, FloatType, Mesh, PlaneGeometry, WebGLRenderTarget,
|
|
6
|
+
import { RGBAFormat, LinearFilter, ClampToEdgeWrapping, Scene, OrthographicCamera, HalfFloatType, FloatType, Mesh, PlaneGeometry, WebGLRenderTarget, UVMapping, WebGLRenderer, DataTexture, LinearSRGBColorSpace, ShaderMaterial, Texture, IntType, ShortType, ByteType, UnsignedIntType, UnsignedByteType, MeshBasicMaterial } from 'three';
|
|
7
7
|
|
|
8
8
|
const getBufferForType = (type, width, height) => {
|
|
9
9
|
let out;
|
|
@@ -44,23 +44,13 @@ let _canReadPixelsResult;
|
|
|
44
44
|
* @param type
|
|
45
45
|
* @param renderer
|
|
46
46
|
* @param camera
|
|
47
|
+
* @param renderTargetOptions
|
|
47
48
|
* @returns
|
|
48
49
|
*/
|
|
49
|
-
const canReadPixels = (type, renderer, camera) => {
|
|
50
|
+
const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
|
|
50
51
|
if (_canReadPixelsResult !== undefined)
|
|
51
52
|
return _canReadPixelsResult;
|
|
52
|
-
const testRT = new WebGLRenderTarget(1, 1,
|
|
53
|
-
type,
|
|
54
|
-
colorSpace: LinearSRGBColorSpace,
|
|
55
|
-
format: RGBAFormat,
|
|
56
|
-
magFilter: LinearFilter,
|
|
57
|
-
minFilter: LinearFilter,
|
|
58
|
-
wrapS: RepeatWrapping,
|
|
59
|
-
wrapT: RepeatWrapping,
|
|
60
|
-
depthBuffer: false,
|
|
61
|
-
stencilBuffer: false,
|
|
62
|
-
generateMipmaps: true
|
|
63
|
-
});
|
|
53
|
+
const testRT = new WebGLRenderTarget(1, 1, renderTargetOptions);
|
|
64
54
|
renderer.setRenderTarget(testRT);
|
|
65
55
|
const mesh = new Mesh(new PlaneGeometry(), new MeshBasicMaterial({ color: 0xffffff }));
|
|
66
56
|
renderer.render(mesh, camera);
|
|
@@ -85,7 +75,8 @@ class QuadRenderer {
|
|
|
85
75
|
* @param sourceTexture
|
|
86
76
|
* @param renderer
|
|
87
77
|
*/
|
|
88
|
-
constructor(
|
|
78
|
+
constructor(options) {
|
|
79
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
89
80
|
this._rendererIsDisposable = false;
|
|
90
81
|
this._supportsReadPixels = true;
|
|
91
82
|
/**
|
|
@@ -102,13 +93,29 @@ class QuadRenderer {
|
|
|
102
93
|
}
|
|
103
94
|
this._renderer.setRenderTarget(null);
|
|
104
95
|
};
|
|
105
|
-
this._width = width;
|
|
106
|
-
this._height = height;
|
|
107
|
-
this._type = type;
|
|
108
|
-
this._colorSpace = colorSpace;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
96
|
+
this._width = options.width;
|
|
97
|
+
this._height = options.height;
|
|
98
|
+
this._type = options.type;
|
|
99
|
+
this._colorSpace = options.colorSpace;
|
|
100
|
+
const rtOptions = {
|
|
101
|
+
// fixed options
|
|
102
|
+
format: RGBAFormat,
|
|
103
|
+
depthBuffer: false,
|
|
104
|
+
stencilBuffer: false,
|
|
105
|
+
// user options
|
|
106
|
+
type: this._type,
|
|
107
|
+
colorSpace: this._colorSpace,
|
|
108
|
+
anisotropy: ((_a = options.renderTargetOptions) === null || _a === void 0 ? void 0 : _a.anisotropy) !== undefined ? (_b = options.renderTargetOptions) === null || _b === void 0 ? void 0 : _b.anisotropy : 1,
|
|
109
|
+
generateMipmaps: ((_c = options.renderTargetOptions) === null || _c === void 0 ? void 0 : _c.generateMipmaps) !== undefined ? (_d = options.renderTargetOptions) === null || _d === void 0 ? void 0 : _d.generateMipmaps : false,
|
|
110
|
+
magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== undefined ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : LinearFilter,
|
|
111
|
+
minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== undefined ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : LinearFilter,
|
|
112
|
+
samples: ((_j = options.renderTargetOptions) === null || _j === void 0 ? void 0 : _j.samples) !== undefined ? (_k = options.renderTargetOptions) === null || _k === void 0 ? void 0 : _k.samples : undefined,
|
|
113
|
+
wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== undefined ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : ClampToEdgeWrapping,
|
|
114
|
+
wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== undefined ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : ClampToEdgeWrapping
|
|
115
|
+
};
|
|
116
|
+
this._material = options.material;
|
|
117
|
+
if (options.renderer) {
|
|
118
|
+
this._renderer = options.renderer;
|
|
112
119
|
}
|
|
113
120
|
else {
|
|
114
121
|
this._renderer = QuadRenderer.instantiateRenderer();
|
|
@@ -122,7 +129,7 @@ class QuadRenderer {
|
|
|
122
129
|
this._camera.top = 0.5;
|
|
123
130
|
this._camera.bottom = -0.5;
|
|
124
131
|
this._camera.updateProjectionMatrix();
|
|
125
|
-
if (!canReadPixels(this._type, this._renderer, this._camera)) {
|
|
132
|
+
if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
|
|
126
133
|
let alternativeType;
|
|
127
134
|
switch (this._type) {
|
|
128
135
|
case HalfFloatType:
|
|
@@ -141,18 +148,8 @@ class QuadRenderer {
|
|
|
141
148
|
this._quad = new Mesh(new PlaneGeometry(), this._material);
|
|
142
149
|
this._quad.geometry.computeBoundingBox();
|
|
143
150
|
this._scene.add(this._quad);
|
|
144
|
-
this._renderTarget = new WebGLRenderTarget(width, height,
|
|
145
|
-
|
|
146
|
-
colorSpace,
|
|
147
|
-
format: RGBAFormat,
|
|
148
|
-
magFilter: LinearFilter,
|
|
149
|
-
minFilter: LinearMipMapLinearFilter,
|
|
150
|
-
wrapS: RepeatWrapping,
|
|
151
|
-
wrapT: RepeatWrapping,
|
|
152
|
-
depthBuffer: false,
|
|
153
|
-
stencilBuffer: false,
|
|
154
|
-
generateMipmaps: true
|
|
155
|
-
});
|
|
151
|
+
this._renderTarget = new WebGLRenderTarget(this.width, this.height, rtOptions);
|
|
152
|
+
this._renderTarget.texture.mapping = ((_q = options.renderTargetOptions) === null || _q === void 0 ? void 0 : _q.mapping) !== undefined ? (_r = options.renderTargetOptions) === null || _r === void 0 ? void 0 : _r.mapping : UVMapping;
|
|
156
153
|
}
|
|
157
154
|
/**
|
|
158
155
|
* Instantiates a temporary renderer
|
|
@@ -185,10 +182,20 @@ class QuadRenderer {
|
|
|
185
182
|
* Performs a readPixel operation in the renderTarget
|
|
186
183
|
* and returns a DataTexture containing the read data
|
|
187
184
|
*
|
|
185
|
+
* @params options
|
|
188
186
|
* @returns
|
|
189
187
|
*/
|
|
190
|
-
toDataTexture() {
|
|
191
|
-
|
|
188
|
+
toDataTexture(options) {
|
|
189
|
+
const returnValue = new DataTexture(
|
|
190
|
+
// fixed values
|
|
191
|
+
this.toArray(), this.width, this.height, RGBAFormat, this._type,
|
|
192
|
+
// user values
|
|
193
|
+
(options === null || options === void 0 ? void 0 : options.mapping) || UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1,
|
|
194
|
+
// fixed value
|
|
195
|
+
LinearSRGBColorSpace);
|
|
196
|
+
// set this afterwards, we can't set it in constructor
|
|
197
|
+
returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== undefined ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
|
|
198
|
+
return returnValue;
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* If using a disposable renderer, it will dispose it.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, Material, ShortType, TextureDataType, UnsignedByteType, UnsignedIntType, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
import { QuadRendererTextureOptions } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Utility Type that translates `three` texture types to their TypedArray counterparts.
|
|
4
5
|
*
|
|
@@ -6,6 +7,36 @@ import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, M
|
|
|
6
7
|
* @group Utility
|
|
7
8
|
*/
|
|
8
9
|
export type TextureDataTypeToBufferType<TType extends TextureDataType> = TType extends typeof UnsignedByteType ? Uint8ClampedArray : TType extends typeof HalfFloatType ? Uint16Array : TType extends typeof UnsignedIntType ? Uint32Array : TType extends typeof ByteType ? Int8Array : TType extends typeof ShortType ? Int16Array : TType extends typeof IntType ? Int32Array : TType extends typeof FloatType ? Float32Array : never;
|
|
10
|
+
export type QuadRendererOptions<TType extends TextureDataType, TMaterial extends Material> = {
|
|
11
|
+
/**
|
|
12
|
+
* Width of the render target
|
|
13
|
+
*/
|
|
14
|
+
width: number;
|
|
15
|
+
/**
|
|
16
|
+
* height of the renderTarget
|
|
17
|
+
*/
|
|
18
|
+
height: number;
|
|
19
|
+
/**
|
|
20
|
+
* TextureDataType of the renderTarget
|
|
21
|
+
*/
|
|
22
|
+
type: TType;
|
|
23
|
+
/**
|
|
24
|
+
* ColorSpace of the renderTarget
|
|
25
|
+
*/
|
|
26
|
+
colorSpace: ColorSpace;
|
|
27
|
+
/**
|
|
28
|
+
* material to use for rendering
|
|
29
|
+
*/
|
|
30
|
+
material: TMaterial;
|
|
31
|
+
/**
|
|
32
|
+
* Renderer instance to use
|
|
33
|
+
*/
|
|
34
|
+
renderer?: WebGLRenderer;
|
|
35
|
+
/**
|
|
36
|
+
* Additional renderTarget options
|
|
37
|
+
*/
|
|
38
|
+
renderTargetOptions?: QuadRendererTextureOptions;
|
|
39
|
+
};
|
|
9
40
|
/**
|
|
10
41
|
* Utility class used for rendering a texture with a material
|
|
11
42
|
*
|
|
@@ -30,7 +61,7 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
|
|
|
30
61
|
* @param sourceTexture
|
|
31
62
|
* @param renderer
|
|
32
63
|
*/
|
|
33
|
-
constructor(
|
|
64
|
+
constructor(options: QuadRendererOptions<TType, TMaterial>);
|
|
34
65
|
/**
|
|
35
66
|
* Instantiates a temporary renderer
|
|
36
67
|
*
|
|
@@ -52,9 +83,10 @@ export declare class QuadRenderer<TType extends TextureDataType, TMaterial exten
|
|
|
52
83
|
* Performs a readPixel operation in the renderTarget
|
|
53
84
|
* and returns a DataTexture containing the read data
|
|
54
85
|
*
|
|
86
|
+
* @params options
|
|
55
87
|
* @returns
|
|
56
88
|
*/
|
|
57
|
-
toDataTexture(): DataTexture;
|
|
89
|
+
toDataTexture(options?: QuadRendererTextureOptions): DataTexture;
|
|
58
90
|
/**
|
|
59
91
|
* If using a disposable renderer, it will dispose it.
|
|
60
92
|
*/
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Mapping, RenderTargetOptions } from 'three';
|
|
1
2
|
/**
|
|
2
3
|
* This is the Metadata stored in an encoded Gainmap which is used
|
|
3
4
|
* to decode it and return an HDR image
|
|
@@ -62,3 +63,16 @@ export type GainMapMetadata = {
|
|
|
62
63
|
*/
|
|
63
64
|
gainMapMax: [number, number, number];
|
|
64
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
export type QuadRendererTextureOptions = Omit<RenderTargetOptions, 'type' | 'format' | 'colorSpace' | 'encoding' | 'depthTexture' | 'stencilBuffer' | 'depthBuffer' | 'internalFormat'> & {
|
|
70
|
+
/**
|
|
71
|
+
* @defaultValue {@link UVMapping}
|
|
72
|
+
*/
|
|
73
|
+
mapping?: Mapping;
|
|
74
|
+
/**
|
|
75
|
+
* @defaultValue 1
|
|
76
|
+
*/
|
|
77
|
+
anisotropy?: number;
|
|
78
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { HalfFloatType, Loader, LoadingManager, WebGLRenderer } from 'three';
|
|
2
2
|
import { QuadRenderer } from '../../core/QuadRenderer';
|
|
3
|
-
import { type GainMapMetadata } from '../../core/types';
|
|
3
|
+
import { type GainMapMetadata, QuadRendererTextureOptions } from '../../core/types';
|
|
4
4
|
import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
|
|
5
5
|
export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>, TUrl> {
|
|
6
6
|
private _renderer;
|
|
7
|
+
private _renderTargetOptions?;
|
|
7
8
|
/**
|
|
8
9
|
* @private
|
|
9
10
|
*/
|
|
@@ -14,6 +15,13 @@ export declare class LoaderBase<TUrl = string> extends Loader<QuadRenderer<typeo
|
|
|
14
15
|
* @param manager
|
|
15
16
|
*/
|
|
16
17
|
constructor(renderer: WebGLRenderer, manager?: LoadingManager);
|
|
18
|
+
/**
|
|
19
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
20
|
+
*
|
|
21
|
+
* @param options
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
setRenderTargetOptions(options: QuadRendererTextureOptions): this;
|
|
17
25
|
/**
|
|
18
26
|
* @private
|
|
19
27
|
* @returns
|
package/dist/decode/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Texture, type WebGLRenderer } from 'three';
|
|
2
|
-
import { type GainMapMetadata } from '../core/types';
|
|
2
|
+
import { type GainMapMetadata, type QuadRendererTextureOptions } from '../core/types';
|
|
3
3
|
/**
|
|
4
4
|
* Necessary parameters for decoding a Gainmap
|
|
5
5
|
*
|
|
@@ -35,4 +35,8 @@ export type DecodeParameters = {
|
|
|
35
35
|
* WebGLRenderer used to decode the GainMap
|
|
36
36
|
*/
|
|
37
37
|
renderer?: WebGLRenderer;
|
|
38
|
+
/**
|
|
39
|
+
* Options to use when creating the output renderTarget
|
|
40
|
+
*/
|
|
41
|
+
renderTargetOptions?: QuadRendererTextureOptions;
|
|
38
42
|
} & GainmapDecodingParameters & GainMapMetadata;
|
package/dist/decode.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
6
|
+
import { Q as QuadRenderer } from './QuadRenderer-LVKXL-q4.js';
|
|
7
7
|
import { ShaderMaterial, Vector3, NoBlending, SRGBColorSpace, LinearSRGBColorSpace, HalfFloatType, Loader, LoadingManager, Texture, UVMapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, FileLoader } from 'three';
|
|
8
8
|
|
|
9
9
|
const vertexShader = /* glsl */ `
|
|
@@ -221,9 +221,19 @@ const decode = (params) => {
|
|
|
221
221
|
sdr,
|
|
222
222
|
gainMap
|
|
223
223
|
});
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const quadRenderer = new QuadRenderer({
|
|
225
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
227
|
+
width: sdr.image.width,
|
|
228
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
230
|
+
height: sdr.image.height,
|
|
231
|
+
type: HalfFloatType,
|
|
232
|
+
colorSpace: LinearSRGBColorSpace,
|
|
233
|
+
material,
|
|
234
|
+
renderer,
|
|
235
|
+
renderTargetOptions: params.renderTargetOptions
|
|
236
|
+
});
|
|
227
237
|
try {
|
|
228
238
|
quadRenderer.render();
|
|
229
239
|
}
|
|
@@ -540,6 +550,16 @@ class LoaderBase extends Loader {
|
|
|
540
550
|
this._renderer = renderer;
|
|
541
551
|
this._internalLoadingManager = new LoadingManager();
|
|
542
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
555
|
+
*
|
|
556
|
+
* @param options
|
|
557
|
+
* @returns
|
|
558
|
+
*/
|
|
559
|
+
setRenderTargetOptions(options) {
|
|
560
|
+
this._renderTargetOptions = options;
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
543
563
|
/**
|
|
544
564
|
* @private
|
|
545
565
|
* @returns
|
|
@@ -558,7 +578,15 @@ class LoaderBase extends Loader {
|
|
|
558
578
|
gainMap: new Texture(),
|
|
559
579
|
sdr: new Texture()
|
|
560
580
|
});
|
|
561
|
-
return new QuadRenderer(
|
|
581
|
+
return new QuadRenderer({
|
|
582
|
+
width: 16,
|
|
583
|
+
height: 16,
|
|
584
|
+
type: HalfFloatType,
|
|
585
|
+
colorSpace: LinearSRGBColorSpace,
|
|
586
|
+
material,
|
|
587
|
+
renderer: this._renderer,
|
|
588
|
+
renderTargetOptions: this._renderTargetOptions
|
|
589
|
+
});
|
|
562
590
|
}
|
|
563
591
|
/**
|
|
564
592
|
* @private
|
|
@@ -684,7 +712,19 @@ class GainMapLoader extends LoaderBase {
|
|
|
684
712
|
let metadata;
|
|
685
713
|
const loadCheck = async () => {
|
|
686
714
|
if (sdr && gainMap && metadata) {
|
|
687
|
-
|
|
715
|
+
// solves #16
|
|
716
|
+
try {
|
|
717
|
+
await this.render(quadRenderer, metadata, sdr, gainMap);
|
|
718
|
+
}
|
|
719
|
+
catch (error) {
|
|
720
|
+
this.manager.itemError(sdrUrl);
|
|
721
|
+
this.manager.itemError(gainMapUrl);
|
|
722
|
+
this.manager.itemError(metadataUrl);
|
|
723
|
+
if (typeof onError === 'function')
|
|
724
|
+
onError(error);
|
|
725
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
688
728
|
if (typeof onLoad === 'function')
|
|
689
729
|
onLoad(quadRenderer);
|
|
690
730
|
this.manager.itemEnd(sdrUrl);
|
|
@@ -879,7 +919,17 @@ class HDRJPGLoader extends LoaderBase {
|
|
|
879
919
|
throw e;
|
|
880
920
|
}
|
|
881
921
|
}
|
|
882
|
-
|
|
922
|
+
// solves #16
|
|
923
|
+
try {
|
|
924
|
+
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG);
|
|
925
|
+
}
|
|
926
|
+
catch (error) {
|
|
927
|
+
this.manager.itemError(url);
|
|
928
|
+
if (typeof onError === 'function')
|
|
929
|
+
onError(error);
|
|
930
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
883
933
|
if (typeof onLoad === 'function')
|
|
884
934
|
onLoad(quadRenderer);
|
|
885
935
|
this.manager.itemEnd(url);
|
package/dist/decode.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -48,23 +48,13 @@
|
|
|
48
48
|
* @param type
|
|
49
49
|
* @param renderer
|
|
50
50
|
* @param camera
|
|
51
|
+
* @param renderTargetOptions
|
|
51
52
|
* @returns
|
|
52
53
|
*/
|
|
53
|
-
const canReadPixels = (type, renderer, camera) => {
|
|
54
|
+
const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
|
|
54
55
|
if (_canReadPixelsResult !== undefined)
|
|
55
56
|
return _canReadPixelsResult;
|
|
56
|
-
const testRT = new three.WebGLRenderTarget(1, 1,
|
|
57
|
-
type,
|
|
58
|
-
colorSpace: three.LinearSRGBColorSpace,
|
|
59
|
-
format: three.RGBAFormat,
|
|
60
|
-
magFilter: three.LinearFilter,
|
|
61
|
-
minFilter: three.LinearFilter,
|
|
62
|
-
wrapS: three.RepeatWrapping,
|
|
63
|
-
wrapT: three.RepeatWrapping,
|
|
64
|
-
depthBuffer: false,
|
|
65
|
-
stencilBuffer: false,
|
|
66
|
-
generateMipmaps: true
|
|
67
|
-
});
|
|
57
|
+
const testRT = new three.WebGLRenderTarget(1, 1, renderTargetOptions);
|
|
68
58
|
renderer.setRenderTarget(testRT);
|
|
69
59
|
const mesh = new three.Mesh(new three.PlaneGeometry(), new three.MeshBasicMaterial({ color: 0xffffff }));
|
|
70
60
|
renderer.render(mesh, camera);
|
|
@@ -89,7 +79,8 @@
|
|
|
89
79
|
* @param sourceTexture
|
|
90
80
|
* @param renderer
|
|
91
81
|
*/
|
|
92
|
-
constructor(
|
|
82
|
+
constructor(options) {
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
93
84
|
this._rendererIsDisposable = false;
|
|
94
85
|
this._supportsReadPixels = true;
|
|
95
86
|
/**
|
|
@@ -106,13 +97,29 @@
|
|
|
106
97
|
}
|
|
107
98
|
this._renderer.setRenderTarget(null);
|
|
108
99
|
};
|
|
109
|
-
this._width = width;
|
|
110
|
-
this._height = height;
|
|
111
|
-
this._type = type;
|
|
112
|
-
this._colorSpace = colorSpace;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
this._width = options.width;
|
|
101
|
+
this._height = options.height;
|
|
102
|
+
this._type = options.type;
|
|
103
|
+
this._colorSpace = options.colorSpace;
|
|
104
|
+
const rtOptions = {
|
|
105
|
+
// fixed options
|
|
106
|
+
format: three.RGBAFormat,
|
|
107
|
+
depthBuffer: false,
|
|
108
|
+
stencilBuffer: false,
|
|
109
|
+
// user options
|
|
110
|
+
type: this._type,
|
|
111
|
+
colorSpace: this._colorSpace,
|
|
112
|
+
anisotropy: ((_a = options.renderTargetOptions) === null || _a === void 0 ? void 0 : _a.anisotropy) !== undefined ? (_b = options.renderTargetOptions) === null || _b === void 0 ? void 0 : _b.anisotropy : 1,
|
|
113
|
+
generateMipmaps: ((_c = options.renderTargetOptions) === null || _c === void 0 ? void 0 : _c.generateMipmaps) !== undefined ? (_d = options.renderTargetOptions) === null || _d === void 0 ? void 0 : _d.generateMipmaps : false,
|
|
114
|
+
magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== undefined ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : three.LinearFilter,
|
|
115
|
+
minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== undefined ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : three.LinearFilter,
|
|
116
|
+
samples: ((_j = options.renderTargetOptions) === null || _j === void 0 ? void 0 : _j.samples) !== undefined ? (_k = options.renderTargetOptions) === null || _k === void 0 ? void 0 : _k.samples : undefined,
|
|
117
|
+
wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== undefined ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : three.ClampToEdgeWrapping,
|
|
118
|
+
wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== undefined ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : three.ClampToEdgeWrapping
|
|
119
|
+
};
|
|
120
|
+
this._material = options.material;
|
|
121
|
+
if (options.renderer) {
|
|
122
|
+
this._renderer = options.renderer;
|
|
116
123
|
}
|
|
117
124
|
else {
|
|
118
125
|
this._renderer = QuadRenderer.instantiateRenderer();
|
|
@@ -126,7 +133,7 @@
|
|
|
126
133
|
this._camera.top = 0.5;
|
|
127
134
|
this._camera.bottom = -0.5;
|
|
128
135
|
this._camera.updateProjectionMatrix();
|
|
129
|
-
if (!canReadPixels(this._type, this._renderer, this._camera)) {
|
|
136
|
+
if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
|
|
130
137
|
let alternativeType;
|
|
131
138
|
switch (this._type) {
|
|
132
139
|
case three.HalfFloatType:
|
|
@@ -145,18 +152,8 @@
|
|
|
145
152
|
this._quad = new three.Mesh(new three.PlaneGeometry(), this._material);
|
|
146
153
|
this._quad.geometry.computeBoundingBox();
|
|
147
154
|
this._scene.add(this._quad);
|
|
148
|
-
this._renderTarget = new three.WebGLRenderTarget(width, height,
|
|
149
|
-
|
|
150
|
-
colorSpace,
|
|
151
|
-
format: three.RGBAFormat,
|
|
152
|
-
magFilter: three.LinearFilter,
|
|
153
|
-
minFilter: three.LinearMipMapLinearFilter,
|
|
154
|
-
wrapS: three.RepeatWrapping,
|
|
155
|
-
wrapT: three.RepeatWrapping,
|
|
156
|
-
depthBuffer: false,
|
|
157
|
-
stencilBuffer: false,
|
|
158
|
-
generateMipmaps: true
|
|
159
|
-
});
|
|
155
|
+
this._renderTarget = new three.WebGLRenderTarget(this.width, this.height, rtOptions);
|
|
156
|
+
this._renderTarget.texture.mapping = ((_q = options.renderTargetOptions) === null || _q === void 0 ? void 0 : _q.mapping) !== undefined ? (_r = options.renderTargetOptions) === null || _r === void 0 ? void 0 : _r.mapping : three.UVMapping;
|
|
160
157
|
}
|
|
161
158
|
/**
|
|
162
159
|
* Instantiates a temporary renderer
|
|
@@ -189,10 +186,20 @@
|
|
|
189
186
|
* Performs a readPixel operation in the renderTarget
|
|
190
187
|
* and returns a DataTexture containing the read data
|
|
191
188
|
*
|
|
189
|
+
* @params options
|
|
192
190
|
* @returns
|
|
193
191
|
*/
|
|
194
|
-
toDataTexture() {
|
|
195
|
-
|
|
192
|
+
toDataTexture(options) {
|
|
193
|
+
const returnValue = new three.DataTexture(
|
|
194
|
+
// fixed values
|
|
195
|
+
this.toArray(), this.width, this.height, three.RGBAFormat, this._type,
|
|
196
|
+
// user values
|
|
197
|
+
(options === null || options === void 0 ? void 0 : options.mapping) || three.UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1,
|
|
198
|
+
// fixed value
|
|
199
|
+
three.LinearSRGBColorSpace);
|
|
200
|
+
// set this afterwards, we can't set it in constructor
|
|
201
|
+
returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== undefined ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
|
|
202
|
+
return returnValue;
|
|
196
203
|
}
|
|
197
204
|
/**
|
|
198
205
|
* If using a disposable renderer, it will dispose it.
|
|
@@ -510,9 +517,19 @@ void main() {
|
|
|
510
517
|
sdr,
|
|
511
518
|
gainMap
|
|
512
519
|
});
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
520
|
+
const quadRenderer = new QuadRenderer({
|
|
521
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
522
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
523
|
+
width: sdr.image.width,
|
|
524
|
+
// TODO: three types are generic, eslint complains here, see how we can solve
|
|
525
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
526
|
+
height: sdr.image.height,
|
|
527
|
+
type: three.HalfFloatType,
|
|
528
|
+
colorSpace: three.LinearSRGBColorSpace,
|
|
529
|
+
material,
|
|
530
|
+
renderer,
|
|
531
|
+
renderTargetOptions: params.renderTargetOptions
|
|
532
|
+
});
|
|
516
533
|
try {
|
|
517
534
|
quadRenderer.render();
|
|
518
535
|
}
|
|
@@ -829,6 +846,16 @@ void main() {
|
|
|
829
846
|
this._renderer = renderer;
|
|
830
847
|
this._internalLoadingManager = new three.LoadingManager();
|
|
831
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Specify the renderTarget options to use when rendering the gain map
|
|
851
|
+
*
|
|
852
|
+
* @param options
|
|
853
|
+
* @returns
|
|
854
|
+
*/
|
|
855
|
+
setRenderTargetOptions(options) {
|
|
856
|
+
this._renderTargetOptions = options;
|
|
857
|
+
return this;
|
|
858
|
+
}
|
|
832
859
|
/**
|
|
833
860
|
* @private
|
|
834
861
|
* @returns
|
|
@@ -847,7 +874,15 @@ void main() {
|
|
|
847
874
|
gainMap: new three.Texture(),
|
|
848
875
|
sdr: new three.Texture()
|
|
849
876
|
});
|
|
850
|
-
return new QuadRenderer(
|
|
877
|
+
return new QuadRenderer({
|
|
878
|
+
width: 16,
|
|
879
|
+
height: 16,
|
|
880
|
+
type: three.HalfFloatType,
|
|
881
|
+
colorSpace: three.LinearSRGBColorSpace,
|
|
882
|
+
material,
|
|
883
|
+
renderer: this._renderer,
|
|
884
|
+
renderTargetOptions: this._renderTargetOptions
|
|
885
|
+
});
|
|
851
886
|
}
|
|
852
887
|
/**
|
|
853
888
|
* @private
|
|
@@ -973,7 +1008,19 @@ void main() {
|
|
|
973
1008
|
let metadata;
|
|
974
1009
|
const loadCheck = async () => {
|
|
975
1010
|
if (sdr && gainMap && metadata) {
|
|
976
|
-
|
|
1011
|
+
// solves #16
|
|
1012
|
+
try {
|
|
1013
|
+
await this.render(quadRenderer, metadata, sdr, gainMap);
|
|
1014
|
+
}
|
|
1015
|
+
catch (error) {
|
|
1016
|
+
this.manager.itemError(sdrUrl);
|
|
1017
|
+
this.manager.itemError(gainMapUrl);
|
|
1018
|
+
this.manager.itemError(metadataUrl);
|
|
1019
|
+
if (typeof onError === 'function')
|
|
1020
|
+
onError(error);
|
|
1021
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
977
1024
|
if (typeof onLoad === 'function')
|
|
978
1025
|
onLoad(quadRenderer);
|
|
979
1026
|
this.manager.itemEnd(sdrUrl);
|
|
@@ -1168,7 +1215,17 @@ void main() {
|
|
|
1168
1215
|
throw e;
|
|
1169
1216
|
}
|
|
1170
1217
|
}
|
|
1171
|
-
|
|
1218
|
+
// solves #16
|
|
1219
|
+
try {
|
|
1220
|
+
await this.render(quadRenderer, metadata, sdrJPEG, gainMapJPEG);
|
|
1221
|
+
}
|
|
1222
|
+
catch (error) {
|
|
1223
|
+
this.manager.itemError(url);
|
|
1224
|
+
if (typeof onError === 'function')
|
|
1225
|
+
onError(error);
|
|
1226
|
+
quadRenderer.disposeOnDemandRenderer();
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1172
1229
|
if (typeof onLoad === 'function')
|
|
1173
1230
|
onLoad(quadRenderer);
|
|
1174
1231
|
this.manager.itemEnd(url);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
2
2
|
import { QuadRenderer } from '../core/QuadRenderer';
|
|
3
|
+
import { QuadRendererTextureOptions } from '../decode';
|
|
3
4
|
import { SDRMaterial } from './materials/SDRMaterial';
|
|
4
5
|
/**
|
|
5
6
|
* Renders an SDR Representation of an HDR Image
|
|
@@ -10,6 +11,7 @@ import { SDRMaterial } from './materials/SDRMaterial';
|
|
|
10
11
|
* @param hdrTexture The HDR image to be rendered
|
|
11
12
|
* @param renderer (optional) WebGLRenderer to use during the rendering, a disposable renderer will be create and destroyed if this is not provided.
|
|
12
13
|
* @param toneMapping (optional) Tone mapping to be applied to the SDR Rendition
|
|
14
|
+
* @param renderTargetOptions (optional) Options to use when creating the output renderTarget
|
|
13
15
|
* @throws {Error} if the WebGLRenderer fails to render the SDR image
|
|
14
16
|
*/
|
|
15
|
-
export declare const getSDRRendition: (hdrTexture: DataTexture, renderer?: WebGLRenderer, toneMapping?: ToneMapping) => QuadRenderer<1009, SDRMaterial>;
|
|
17
|
+
export declare const getSDRRendition: (hdrTexture: DataTexture, renderer?: WebGLRenderer, toneMapping?: ToneMapping, renderTargetOptions?: QuadRendererTextureOptions) => QuadRenderer<1009, SDRMaterial>;
|
package/dist/encode/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type DataTexture, ToneMapping, WebGLRenderer } from 'three';
|
|
|
2
2
|
import { type EXR } from 'three/examples/jsm/loaders/EXRLoader';
|
|
3
3
|
import { type LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
|
|
4
4
|
import { type RGBE } from 'three/examples/jsm/loaders/RGBELoader';
|
|
5
|
+
import { QuadRendererTextureOptions } from '../decode';
|
|
5
6
|
import { WorkerInterfaceImplementation } from '../worker-types';
|
|
6
7
|
/**
|
|
7
8
|
* Parameters used by content Creators in order to create a GainMap
|
|
@@ -82,6 +83,10 @@ export type EncodingParametersBase = GainmapEncodingParameters & {
|
|
|
82
83
|
* @defaultValue `ACESFilmicToneMapping`
|
|
83
84
|
*/
|
|
84
85
|
toneMapping?: ToneMapping;
|
|
86
|
+
/**
|
|
87
|
+
* Options to use when creating the output renderTarget
|
|
88
|
+
*/
|
|
89
|
+
renderTargetOptions?: QuadRendererTextureOptions;
|
|
85
90
|
};
|
|
86
91
|
/**
|
|
87
92
|
* This library can provide gainmap compressed in these mimeTypes
|
package/dist/encode.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { c as compress } from './compress-
|
|
6
|
+
import { c as compress } from './compress-AzvRyeg9.js';
|
|
7
7
|
import { DataTexture, RGBAFormat, UVMapping, RepeatWrapping, LinearFilter, LinearSRGBColorSpace, ShaderMaterial, Vector3, NoBlending, UnsignedByteType, ACESFilmicToneMapping, LinearToneMapping, CineonToneMapping, ReinhardToneMapping, SRGBColorSpace, Vector2, WebGLRenderTarget, NearestFilter, ClampToEdgeWrapping, FloatType, DataUtils } from 'three';
|
|
8
|
-
import { Q as QuadRenderer } from './QuadRenderer-
|
|
8
|
+
import { Q as QuadRenderer } from './QuadRenderer-LVKXL-q4.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Utility function to obtain a `DataTexture` from various input formats
|
|
@@ -195,7 +195,15 @@ const getGainMap = (params) => {
|
|
|
195
195
|
sdr: sdr.renderTarget.texture,
|
|
196
196
|
hdr: dataTexture
|
|
197
197
|
});
|
|
198
|
-
const quadRenderer = new QuadRenderer(
|
|
198
|
+
const quadRenderer = new QuadRenderer({
|
|
199
|
+
width: dataTexture.image.width,
|
|
200
|
+
height: dataTexture.image.height,
|
|
201
|
+
type: UnsignedByteType,
|
|
202
|
+
colorSpace: LinearSRGBColorSpace,
|
|
203
|
+
material,
|
|
204
|
+
renderer,
|
|
205
|
+
renderTargetOptions: params.renderTargetOptions
|
|
206
|
+
});
|
|
199
207
|
try {
|
|
200
208
|
quadRenderer.render();
|
|
201
209
|
}
|
|
@@ -418,11 +426,20 @@ class SDRMaterial extends ShaderMaterial {
|
|
|
418
426
|
* @param hdrTexture The HDR image to be rendered
|
|
419
427
|
* @param renderer (optional) WebGLRenderer to use during the rendering, a disposable renderer will be create and destroyed if this is not provided.
|
|
420
428
|
* @param toneMapping (optional) Tone mapping to be applied to the SDR Rendition
|
|
429
|
+
* @param renderTargetOptions (optional) Options to use when creating the output renderTarget
|
|
421
430
|
* @throws {Error} if the WebGLRenderer fails to render the SDR image
|
|
422
431
|
*/
|
|
423
|
-
const getSDRRendition = (hdrTexture, renderer, toneMapping) => {
|
|
432
|
+
const getSDRRendition = (hdrTexture, renderer, toneMapping, renderTargetOptions) => {
|
|
424
433
|
hdrTexture.needsUpdate = true;
|
|
425
|
-
const quadRenderer = new QuadRenderer(
|
|
434
|
+
const quadRenderer = new QuadRenderer({
|
|
435
|
+
width: hdrTexture.image.width,
|
|
436
|
+
height: hdrTexture.image.height,
|
|
437
|
+
type: UnsignedByteType,
|
|
438
|
+
colorSpace: SRGBColorSpace,
|
|
439
|
+
material: new SDRMaterial({ map: hdrTexture, toneMapping }),
|
|
440
|
+
renderer,
|
|
441
|
+
renderTargetOptions
|
|
442
|
+
});
|
|
426
443
|
try {
|
|
427
444
|
quadRenderer.render();
|
|
428
445
|
}
|
|
@@ -489,7 +506,7 @@ const getSDRRendition = (hdrTexture, renderer, toneMapping) => {
|
|
|
489
506
|
const encode = (params) => {
|
|
490
507
|
const { image, renderer } = params;
|
|
491
508
|
const dataTexture = getDataTexture(image);
|
|
492
|
-
const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping);
|
|
509
|
+
const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping, params.renderTargetOptions);
|
|
493
510
|
const gainMapRenderer = getGainMap({
|
|
494
511
|
...params,
|
|
495
512
|
image: dataTexture,
|
|
@@ -689,7 +706,14 @@ const findTextureMinMax = (image, mode = 'max', renderer) => {
|
|
|
689
706
|
mat.needsUpdate = true;
|
|
690
707
|
let w = srcTex.image.width;
|
|
691
708
|
let h = srcTex.image.height;
|
|
692
|
-
const quadRenderer = new QuadRenderer(
|
|
709
|
+
const quadRenderer = new QuadRenderer({
|
|
710
|
+
width: w,
|
|
711
|
+
height: h,
|
|
712
|
+
type: srcTex.type,
|
|
713
|
+
colorSpace: srcTex.colorSpace,
|
|
714
|
+
material: mat,
|
|
715
|
+
renderer
|
|
716
|
+
});
|
|
693
717
|
const frameBuffers = [];
|
|
694
718
|
while (w > 1 || h > 1) {
|
|
695
719
|
w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
|
package/dist/encode.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -153,23 +153,13 @@
|
|
|
153
153
|
* @param type
|
|
154
154
|
* @param renderer
|
|
155
155
|
* @param camera
|
|
156
|
+
* @param renderTargetOptions
|
|
156
157
|
* @returns
|
|
157
158
|
*/
|
|
158
|
-
const canReadPixels = (type, renderer, camera) => {
|
|
159
|
+
const canReadPixels = (type, renderer, camera, renderTargetOptions) => {
|
|
159
160
|
if (_canReadPixelsResult !== undefined)
|
|
160
161
|
return _canReadPixelsResult;
|
|
161
|
-
const testRT = new three.WebGLRenderTarget(1, 1,
|
|
162
|
-
type,
|
|
163
|
-
colorSpace: three.LinearSRGBColorSpace,
|
|
164
|
-
format: three.RGBAFormat,
|
|
165
|
-
magFilter: three.LinearFilter,
|
|
166
|
-
minFilter: three.LinearFilter,
|
|
167
|
-
wrapS: three.RepeatWrapping,
|
|
168
|
-
wrapT: three.RepeatWrapping,
|
|
169
|
-
depthBuffer: false,
|
|
170
|
-
stencilBuffer: false,
|
|
171
|
-
generateMipmaps: true
|
|
172
|
-
});
|
|
162
|
+
const testRT = new three.WebGLRenderTarget(1, 1, renderTargetOptions);
|
|
173
163
|
renderer.setRenderTarget(testRT);
|
|
174
164
|
const mesh = new three.Mesh(new three.PlaneGeometry(), new three.MeshBasicMaterial({ color: 0xffffff }));
|
|
175
165
|
renderer.render(mesh, camera);
|
|
@@ -194,7 +184,8 @@
|
|
|
194
184
|
* @param sourceTexture
|
|
195
185
|
* @param renderer
|
|
196
186
|
*/
|
|
197
|
-
constructor(
|
|
187
|
+
constructor(options) {
|
|
188
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
198
189
|
this._rendererIsDisposable = false;
|
|
199
190
|
this._supportsReadPixels = true;
|
|
200
191
|
/**
|
|
@@ -211,13 +202,29 @@
|
|
|
211
202
|
}
|
|
212
203
|
this._renderer.setRenderTarget(null);
|
|
213
204
|
};
|
|
214
|
-
this._width = width;
|
|
215
|
-
this._height = height;
|
|
216
|
-
this._type = type;
|
|
217
|
-
this._colorSpace = colorSpace;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
205
|
+
this._width = options.width;
|
|
206
|
+
this._height = options.height;
|
|
207
|
+
this._type = options.type;
|
|
208
|
+
this._colorSpace = options.colorSpace;
|
|
209
|
+
const rtOptions = {
|
|
210
|
+
// fixed options
|
|
211
|
+
format: three.RGBAFormat,
|
|
212
|
+
depthBuffer: false,
|
|
213
|
+
stencilBuffer: false,
|
|
214
|
+
// user options
|
|
215
|
+
type: this._type,
|
|
216
|
+
colorSpace: this._colorSpace,
|
|
217
|
+
anisotropy: ((_a = options.renderTargetOptions) === null || _a === void 0 ? void 0 : _a.anisotropy) !== undefined ? (_b = options.renderTargetOptions) === null || _b === void 0 ? void 0 : _b.anisotropy : 1,
|
|
218
|
+
generateMipmaps: ((_c = options.renderTargetOptions) === null || _c === void 0 ? void 0 : _c.generateMipmaps) !== undefined ? (_d = options.renderTargetOptions) === null || _d === void 0 ? void 0 : _d.generateMipmaps : false,
|
|
219
|
+
magFilter: ((_e = options.renderTargetOptions) === null || _e === void 0 ? void 0 : _e.magFilter) !== undefined ? (_f = options.renderTargetOptions) === null || _f === void 0 ? void 0 : _f.magFilter : three.LinearFilter,
|
|
220
|
+
minFilter: ((_g = options.renderTargetOptions) === null || _g === void 0 ? void 0 : _g.minFilter) !== undefined ? (_h = options.renderTargetOptions) === null || _h === void 0 ? void 0 : _h.minFilter : three.LinearFilter,
|
|
221
|
+
samples: ((_j = options.renderTargetOptions) === null || _j === void 0 ? void 0 : _j.samples) !== undefined ? (_k = options.renderTargetOptions) === null || _k === void 0 ? void 0 : _k.samples : undefined,
|
|
222
|
+
wrapS: ((_l = options.renderTargetOptions) === null || _l === void 0 ? void 0 : _l.wrapS) !== undefined ? (_m = options.renderTargetOptions) === null || _m === void 0 ? void 0 : _m.wrapS : three.ClampToEdgeWrapping,
|
|
223
|
+
wrapT: ((_o = options.renderTargetOptions) === null || _o === void 0 ? void 0 : _o.wrapT) !== undefined ? (_p = options.renderTargetOptions) === null || _p === void 0 ? void 0 : _p.wrapT : three.ClampToEdgeWrapping
|
|
224
|
+
};
|
|
225
|
+
this._material = options.material;
|
|
226
|
+
if (options.renderer) {
|
|
227
|
+
this._renderer = options.renderer;
|
|
221
228
|
}
|
|
222
229
|
else {
|
|
223
230
|
this._renderer = QuadRenderer.instantiateRenderer();
|
|
@@ -231,7 +238,7 @@
|
|
|
231
238
|
this._camera.top = 0.5;
|
|
232
239
|
this._camera.bottom = -0.5;
|
|
233
240
|
this._camera.updateProjectionMatrix();
|
|
234
|
-
if (!canReadPixels(this._type, this._renderer, this._camera)) {
|
|
241
|
+
if (!canReadPixels(this._type, this._renderer, this._camera, rtOptions)) {
|
|
235
242
|
let alternativeType;
|
|
236
243
|
switch (this._type) {
|
|
237
244
|
case three.HalfFloatType:
|
|
@@ -250,18 +257,8 @@
|
|
|
250
257
|
this._quad = new three.Mesh(new three.PlaneGeometry(), this._material);
|
|
251
258
|
this._quad.geometry.computeBoundingBox();
|
|
252
259
|
this._scene.add(this._quad);
|
|
253
|
-
this._renderTarget = new three.WebGLRenderTarget(width, height,
|
|
254
|
-
|
|
255
|
-
colorSpace,
|
|
256
|
-
format: three.RGBAFormat,
|
|
257
|
-
magFilter: three.LinearFilter,
|
|
258
|
-
minFilter: three.LinearMipMapLinearFilter,
|
|
259
|
-
wrapS: three.RepeatWrapping,
|
|
260
|
-
wrapT: three.RepeatWrapping,
|
|
261
|
-
depthBuffer: false,
|
|
262
|
-
stencilBuffer: false,
|
|
263
|
-
generateMipmaps: true
|
|
264
|
-
});
|
|
260
|
+
this._renderTarget = new three.WebGLRenderTarget(this.width, this.height, rtOptions);
|
|
261
|
+
this._renderTarget.texture.mapping = ((_q = options.renderTargetOptions) === null || _q === void 0 ? void 0 : _q.mapping) !== undefined ? (_r = options.renderTargetOptions) === null || _r === void 0 ? void 0 : _r.mapping : three.UVMapping;
|
|
265
262
|
}
|
|
266
263
|
/**
|
|
267
264
|
* Instantiates a temporary renderer
|
|
@@ -294,10 +291,20 @@
|
|
|
294
291
|
* Performs a readPixel operation in the renderTarget
|
|
295
292
|
* and returns a DataTexture containing the read data
|
|
296
293
|
*
|
|
294
|
+
* @params options
|
|
297
295
|
* @returns
|
|
298
296
|
*/
|
|
299
|
-
toDataTexture() {
|
|
300
|
-
|
|
297
|
+
toDataTexture(options) {
|
|
298
|
+
const returnValue = new three.DataTexture(
|
|
299
|
+
// fixed values
|
|
300
|
+
this.toArray(), this.width, this.height, three.RGBAFormat, this._type,
|
|
301
|
+
// user values
|
|
302
|
+
(options === null || options === void 0 ? void 0 : options.mapping) || three.UVMapping, (options === null || options === void 0 ? void 0 : options.wrapS) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.wrapT) || three.ClampToEdgeWrapping, (options === null || options === void 0 ? void 0 : options.magFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.minFilter) || three.LinearFilter, (options === null || options === void 0 ? void 0 : options.anisotropy) || 1,
|
|
303
|
+
// fixed value
|
|
304
|
+
three.LinearSRGBColorSpace);
|
|
305
|
+
// set this afterwards, we can't set it in constructor
|
|
306
|
+
returnValue.generateMipmaps = (options === null || options === void 0 ? void 0 : options.generateMipmaps) !== undefined ? options === null || options === void 0 ? void 0 : options.generateMipmaps : false;
|
|
307
|
+
return returnValue;
|
|
301
308
|
}
|
|
302
309
|
/**
|
|
303
310
|
* If using a disposable renderer, it will dispose it.
|
|
@@ -559,7 +566,15 @@ void main() {
|
|
|
559
566
|
sdr: sdr.renderTarget.texture,
|
|
560
567
|
hdr: dataTexture
|
|
561
568
|
});
|
|
562
|
-
const quadRenderer = new QuadRenderer(
|
|
569
|
+
const quadRenderer = new QuadRenderer({
|
|
570
|
+
width: dataTexture.image.width,
|
|
571
|
+
height: dataTexture.image.height,
|
|
572
|
+
type: three.UnsignedByteType,
|
|
573
|
+
colorSpace: three.LinearSRGBColorSpace,
|
|
574
|
+
material,
|
|
575
|
+
renderer,
|
|
576
|
+
renderTargetOptions: params.renderTargetOptions
|
|
577
|
+
});
|
|
563
578
|
try {
|
|
564
579
|
quadRenderer.render();
|
|
565
580
|
}
|
|
@@ -782,11 +797,20 @@ void main() {
|
|
|
782
797
|
* @param hdrTexture The HDR image to be rendered
|
|
783
798
|
* @param renderer (optional) WebGLRenderer to use during the rendering, a disposable renderer will be create and destroyed if this is not provided.
|
|
784
799
|
* @param toneMapping (optional) Tone mapping to be applied to the SDR Rendition
|
|
800
|
+
* @param renderTargetOptions (optional) Options to use when creating the output renderTarget
|
|
785
801
|
* @throws {Error} if the WebGLRenderer fails to render the SDR image
|
|
786
802
|
*/
|
|
787
|
-
const getSDRRendition = (hdrTexture, renderer, toneMapping) => {
|
|
803
|
+
const getSDRRendition = (hdrTexture, renderer, toneMapping, renderTargetOptions) => {
|
|
788
804
|
hdrTexture.needsUpdate = true;
|
|
789
|
-
const quadRenderer = new QuadRenderer(
|
|
805
|
+
const quadRenderer = new QuadRenderer({
|
|
806
|
+
width: hdrTexture.image.width,
|
|
807
|
+
height: hdrTexture.image.height,
|
|
808
|
+
type: three.UnsignedByteType,
|
|
809
|
+
colorSpace: three.SRGBColorSpace,
|
|
810
|
+
material: new SDRMaterial({ map: hdrTexture, toneMapping }),
|
|
811
|
+
renderer,
|
|
812
|
+
renderTargetOptions
|
|
813
|
+
});
|
|
790
814
|
try {
|
|
791
815
|
quadRenderer.render();
|
|
792
816
|
}
|
|
@@ -853,7 +877,7 @@ void main() {
|
|
|
853
877
|
const encode = (params) => {
|
|
854
878
|
const { image, renderer } = params;
|
|
855
879
|
const dataTexture = getDataTexture(image);
|
|
856
|
-
const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping);
|
|
880
|
+
const sdr = getSDRRendition(dataTexture, renderer, params.toneMapping, params.renderTargetOptions);
|
|
857
881
|
const gainMapRenderer = getGainMap({
|
|
858
882
|
...params,
|
|
859
883
|
image: dataTexture,
|
|
@@ -1053,7 +1077,14 @@ void main() {
|
|
|
1053
1077
|
mat.needsUpdate = true;
|
|
1054
1078
|
let w = srcTex.image.width;
|
|
1055
1079
|
let h = srcTex.image.height;
|
|
1056
|
-
const quadRenderer = new QuadRenderer(
|
|
1080
|
+
const quadRenderer = new QuadRenderer({
|
|
1081
|
+
width: w,
|
|
1082
|
+
height: h,
|
|
1083
|
+
type: srcTex.type,
|
|
1084
|
+
colorSpace: srcTex.colorSpace,
|
|
1085
|
+
material: mat,
|
|
1086
|
+
renderer
|
|
1087
|
+
});
|
|
1057
1088
|
const frameBuffers = [];
|
|
1058
1089
|
while (w > 1 || h > 1) {
|
|
1059
1090
|
w = Math.max(1, (w + cellSize - 1) / cellSize | 0);
|
package/dist/libultrahdr.js
CHANGED
package/dist/libultrahdr.umd.js
CHANGED
package/dist/worker-interface.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-
|
|
6
|
+
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-7LfDr0XA.js';
|
|
7
7
|
|
|
8
8
|
var lib$1;
|
|
9
9
|
var hasRequiredLib$1;
|
package/dist/worker.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @monogrid/gainmap-js v2.0.
|
|
2
|
+
* @monogrid/gainmap-js v2.0.7
|
|
3
3
|
* With ❤️, by MONOGRID <hello@mono-grid.com>
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { g as getDefaultExportFromCjs } from './_commonjsHelpers-
|
|
7
|
-
import { c as compress } from './compress-
|
|
6
|
+
import { g as getDefaultExportFromCjs } from './_commonjsHelpers-7LfDr0XA.js';
|
|
7
|
+
import { c as compress } from './compress-AzvRyeg9.js';
|
|
8
8
|
|
|
9
9
|
var isPromise$2 = {exports: {}};
|
|
10
10
|
|
package/dist/worker.umd.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monogrid/gainmap-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gain map",
|
|
5
5
|
"homepage": "https://github.com/MONOGRID/gainmap-js#readme",
|
|
6
6
|
"repository": {
|