@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.8.2 → 3.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RenderingEngine.js +2 -2
- package/dist/RenderingEngine.js.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.d.ts +15 -0
- package/dist/loaders/EnvironmentMapLoader.d.ts.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.js +29 -0
- package/dist/loaders/EnvironmentMapLoader.js.map +1 -1
- package/dist/loaders/MaterialLoader.js +1 -1
- package/dist/loaders/MaterialLoader.js.map +1 -1
- package/dist/managers/PostProcessingManager.d.ts.map +1 -1
- package/dist/managers/PostProcessingManager.js +5 -2
- package/dist/managers/PostProcessingManager.js.map +1 -1
- package/dist/managers/postprocessing/ao/hbao/shader/hbao_utils.d.ts +2 -0
- package/dist/managers/postprocessing/ao/hbao/shader/hbao_utils.d.ts.map +1 -0
- package/dist/managers/postprocessing/ao/hbao/shader/hbao_utils.js +99 -0
- package/dist/managers/postprocessing/ao/hbao/shader/hbao_utils.js.map +1 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.d.ts +1 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.js +2 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts +166 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js +292 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.d.ts +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.js +160 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.d.ts +2 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js +97 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js.map +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToneMappingEffect = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const postprocessing_1 = require("postprocessing");
|
|
6
|
+
const three_1 = require("three");
|
|
7
|
+
const tone_mapping_1 = require("./tone-mapping");
|
|
8
|
+
/**
|
|
9
|
+
* A tone mapping effect.
|
|
10
|
+
*
|
|
11
|
+
* Note: `ToneMappingMode.REINHARD2_ADAPTIVE` requires support for `EXT_shader_texture_lod`.
|
|
12
|
+
*
|
|
13
|
+
* Reference:
|
|
14
|
+
* GDC2007 - Wolfgang Engel, Post-Processing Pipeline
|
|
15
|
+
* http://perso.univ-lyon1.fr/jean-claude.iehl/Public/educ/GAMA/2007/gdc07/Post-Processing_Pipeline.pdf
|
|
16
|
+
*/
|
|
17
|
+
class ToneMappingEffect extends postprocessing_1.Effect {
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new tone mapping effect.
|
|
20
|
+
*
|
|
21
|
+
* The additional parameters only affect the Reinhard2 operator.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} [options] - The options.
|
|
24
|
+
* @param {BlendFunction} [options.blendFunction=BlendFunction.SRC] - The blend function of this effect.
|
|
25
|
+
* @param {boolean} [options.adaptive=false] - Deprecated. Use mode instead.
|
|
26
|
+
* @param {ToneMappingMode} [options.mode=ToneMappingMode.AGX] - The tone mapping mode.
|
|
27
|
+
* @param {number} [options.resolution=256] - The resolution of the luminance texture. Must be a power of two.
|
|
28
|
+
* @param {number} [options.maxLuminance=4.0] - Deprecated. Same as whitePoint.
|
|
29
|
+
* @param {number} [options.whitePoint=4.0] - The white point.
|
|
30
|
+
* @param {number} [options.middleGrey=0.6] - The middle grey factor.
|
|
31
|
+
* @param {number} [options.minLuminance=0.01] - The minimum luminance. Prevents very high exposure in dark scenes.
|
|
32
|
+
* @param {number} [options.averageLuminance=1.0] - The average luminance. Used for the non-adaptive Reinhard operator.
|
|
33
|
+
* @param {number} [options.adaptationRate=1.0] - The luminance adaptation rate.
|
|
34
|
+
*/
|
|
35
|
+
constructor({ blendFunction = postprocessing_1.BlendFunction.SRC, adaptive = false, mode = adaptive ? postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE : postprocessing_1.ToneMappingMode.AGX, resolution = 256, maxLuminance = 4.0, whitePoint = maxLuminance, middleGrey = 0.6, minLuminance = 0.01, averageLuminance = 1.0, adaptationRate = 1.0, } = {}) {
|
|
36
|
+
super('ToneMappingEffect', tone_mapping_1.tone_mapping, {
|
|
37
|
+
attributes: postprocessing_1.EffectAttribute.DEPTH,
|
|
38
|
+
blendFunction,
|
|
39
|
+
uniforms: new Map([
|
|
40
|
+
['luminanceBuffer', new three_1.Uniform(null)],
|
|
41
|
+
['maxLuminance', new three_1.Uniform(maxLuminance)],
|
|
42
|
+
['whitePoint', new three_1.Uniform(whitePoint)],
|
|
43
|
+
['middleGrey', new three_1.Uniform(middleGrey)],
|
|
44
|
+
['averageLuminance', new three_1.Uniform(averageLuminance)]
|
|
45
|
+
])
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The render target for the current luminance.
|
|
49
|
+
*
|
|
50
|
+
* @type {WebGLRenderTarget}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
this.renderTargetLuminance = new three_1.WebGLRenderTarget(1, 1, {
|
|
54
|
+
minFilter: three_1.LinearMipmapLinearFilter,
|
|
55
|
+
depthBuffer: false
|
|
56
|
+
});
|
|
57
|
+
this.renderTargetLuminance.texture.generateMipmaps = true;
|
|
58
|
+
this.renderTargetLuminance.texture.name = 'Luminance';
|
|
59
|
+
/**
|
|
60
|
+
* A luminance pass.
|
|
61
|
+
*
|
|
62
|
+
* @type {ShaderPass}
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
this.luminancePass = new postprocessing_1.LuminancePass({
|
|
66
|
+
renderTarget: this.renderTargetLuminance
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* An adaptive luminance pass.
|
|
70
|
+
*
|
|
71
|
+
* @type {AdaptiveLuminancePass}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
this.adaptiveLuminancePass = new postprocessing_1.AdaptiveLuminancePass(this.luminancePass.texture, {
|
|
75
|
+
minLuminance,
|
|
76
|
+
adaptationRate
|
|
77
|
+
});
|
|
78
|
+
this.uniforms.get('luminanceBuffer').value = this.adaptiveLuminancePass.texture;
|
|
79
|
+
this.resolution = resolution;
|
|
80
|
+
this.mode = mode;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The luminance adaptation rate.
|
|
84
|
+
*
|
|
85
|
+
* @type {number}
|
|
86
|
+
* @deprecated Use adaptiveLuminanceMaterial.adaptationRate instead.
|
|
87
|
+
*/
|
|
88
|
+
get adaptationRate() {
|
|
89
|
+
return this.adaptiveLuminanceMaterial.adaptationRate;
|
|
90
|
+
}
|
|
91
|
+
set adaptationRate(value) {
|
|
92
|
+
this.adaptiveLuminanceMaterial.adaptationRate = value;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Indicates whether this pass uses adaptive luminance.
|
|
96
|
+
*
|
|
97
|
+
* @type {boolean}
|
|
98
|
+
* @deprecated Use mode instead.
|
|
99
|
+
*/
|
|
100
|
+
get adaptive() {
|
|
101
|
+
return (this.mode === postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE);
|
|
102
|
+
}
|
|
103
|
+
set adaptive(value) {
|
|
104
|
+
this.mode = value ? postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE : postprocessing_1.ToneMappingMode.REINHARD2;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The adaptive luminance material.
|
|
108
|
+
*
|
|
109
|
+
* @type {AdaptiveLuminanceMaterial}
|
|
110
|
+
*/
|
|
111
|
+
get adaptiveLuminanceMaterial() {
|
|
112
|
+
return this.adaptiveLuminancePass.fullscreenMaterial;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The average luminance.
|
|
116
|
+
*
|
|
117
|
+
* Only applies to Reinhard2 (Modified).
|
|
118
|
+
*
|
|
119
|
+
* @type {number}
|
|
120
|
+
*/
|
|
121
|
+
get averageLuminance() {
|
|
122
|
+
return this.uniforms.get('averageLuminance').value;
|
|
123
|
+
}
|
|
124
|
+
set averageLuminance(value) {
|
|
125
|
+
this.uniforms.get('averageLuminance').value = value;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @type {number}
|
|
129
|
+
* @deprecated
|
|
130
|
+
*/
|
|
131
|
+
get distinction() {
|
|
132
|
+
console.warn(this.name, 'distinction was removed.');
|
|
133
|
+
return 1.0;
|
|
134
|
+
}
|
|
135
|
+
set distinction(value) {
|
|
136
|
+
console.warn(this.name, 'distinction was removed.');
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The middle grey factor. Default is `0.6`.
|
|
140
|
+
*
|
|
141
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
142
|
+
*
|
|
143
|
+
* @type {number}
|
|
144
|
+
*/
|
|
145
|
+
get middleGrey() {
|
|
146
|
+
return this.uniforms.get('middleGrey').value;
|
|
147
|
+
}
|
|
148
|
+
set middleGrey(value) {
|
|
149
|
+
this.uniforms.get('middleGrey').value = value;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The tone mapping mode.
|
|
153
|
+
*
|
|
154
|
+
* @type {ToneMappingMode}
|
|
155
|
+
*/
|
|
156
|
+
get mode() {
|
|
157
|
+
return Number(this.defines.get('TONE_MAPPING_MODE'));
|
|
158
|
+
}
|
|
159
|
+
set mode(value) {
|
|
160
|
+
if (this.mode === value) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const revision = +three_1.REVISION.replace(/\D+/g, '');
|
|
164
|
+
const cineonToneMapping = (revision >= 168) ? 'CineonToneMapping(texel)' : 'OptimizedCineonToneMapping(texel)';
|
|
165
|
+
this.defines.clear();
|
|
166
|
+
this.defines.set('TONE_MAPPING_MODE', value.toFixed(0));
|
|
167
|
+
// Use one of the built-in tone mapping operators.
|
|
168
|
+
switch (value) {
|
|
169
|
+
case postprocessing_1.ToneMappingMode.LINEAR:
|
|
170
|
+
this.defines.set('toneMapping(texel)', 'LinearToneMapping(texel)');
|
|
171
|
+
break;
|
|
172
|
+
case postprocessing_1.ToneMappingMode.REINHARD:
|
|
173
|
+
this.defines.set('toneMapping(texel)', 'ReinhardToneMapping(texel)');
|
|
174
|
+
break;
|
|
175
|
+
case postprocessing_1.ToneMappingMode.OPTIMIZED_CINEON:
|
|
176
|
+
this.defines.set('toneMapping(texel)', cineonToneMapping);
|
|
177
|
+
break;
|
|
178
|
+
case postprocessing_1.ToneMappingMode.ACES_FILMIC:
|
|
179
|
+
this.defines.set('toneMapping(texel)', 'ACESFilmicToneMapping(texel)');
|
|
180
|
+
break;
|
|
181
|
+
case postprocessing_1.ToneMappingMode.AGX:
|
|
182
|
+
this.defines.set('toneMapping(texel)', 'AgXToneMapping(texel)');
|
|
183
|
+
break;
|
|
184
|
+
case postprocessing_1.ToneMappingMode.NEUTRAL:
|
|
185
|
+
this.defines.set('toneMapping(texel)', 'NeutralToneMapping(texel)');
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
this.defines.set('toneMapping(texel)', 'texel');
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
this.adaptiveLuminancePass.enabled = (value === postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE);
|
|
192
|
+
this.setChanged();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The resolution of the luminance texture. Must be a power of two.
|
|
196
|
+
*
|
|
197
|
+
* @type {number}
|
|
198
|
+
*/
|
|
199
|
+
get resolution() {
|
|
200
|
+
return this.luminancePass.resolution.width;
|
|
201
|
+
}
|
|
202
|
+
set resolution(value) {
|
|
203
|
+
// Round the given value to the next power of two.
|
|
204
|
+
const exponent = Math.max(0, Math.ceil(Math.log2(value)));
|
|
205
|
+
const size = Math.pow(2, exponent);
|
|
206
|
+
this.luminancePass.resolution.setPreferredSize(size, size);
|
|
207
|
+
this.adaptiveLuminanceMaterial.mipLevel1x1 = exponent;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The white point. Default is `4.0`.
|
|
211
|
+
*
|
|
212
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
213
|
+
*
|
|
214
|
+
* @type {number}
|
|
215
|
+
*/
|
|
216
|
+
get whitePoint() {
|
|
217
|
+
return this.uniforms.get('whitePoint').value;
|
|
218
|
+
}
|
|
219
|
+
set whitePoint(value) {
|
|
220
|
+
this.uniforms.get('whitePoint').value = value;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Returns the adaptive luminance material.
|
|
224
|
+
*
|
|
225
|
+
* @deprecated Use adaptiveLuminanceMaterial instead.
|
|
226
|
+
* @return {AdaptiveLuminanceMaterial} The material.
|
|
227
|
+
*/
|
|
228
|
+
getAdaptiveLuminanceMaterial() {
|
|
229
|
+
return this.adaptiveLuminanceMaterial;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Returns the current tone mapping mode.
|
|
233
|
+
*
|
|
234
|
+
* @deprecated Use mode instead.
|
|
235
|
+
* @return {ToneMappingMode} The tone mapping mode.
|
|
236
|
+
*/
|
|
237
|
+
getMode() {
|
|
238
|
+
return this.mode;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Returns the resolution of the luminance texture.
|
|
242
|
+
*
|
|
243
|
+
* @deprecated Use resolution instead.
|
|
244
|
+
* @return {number} The resolution.
|
|
245
|
+
*/
|
|
246
|
+
getResolution() {
|
|
247
|
+
return this.resolution;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Performs initialization tasks.
|
|
251
|
+
*
|
|
252
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
253
|
+
* @param {boolean} alpha - Whether the renderer uses the alpha channel or not.
|
|
254
|
+
* @param {number} frameBufferType - The type of the main frame buffers.
|
|
255
|
+
*/
|
|
256
|
+
initialize(renderer, alpha, frameBufferType) {
|
|
257
|
+
this.adaptiveLuminancePass.initialize(renderer, alpha, frameBufferType);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sets the tone mapping mode.
|
|
261
|
+
*
|
|
262
|
+
* @deprecated Use mode instead.
|
|
263
|
+
* @param {ToneMappingMode} value - The tone mapping mode.
|
|
264
|
+
*/
|
|
265
|
+
setMode(value) {
|
|
266
|
+
this.mode = value;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Sets the resolution of the luminance texture. Must be a power of two.
|
|
270
|
+
*
|
|
271
|
+
* @deprecated Use resolution instead.
|
|
272
|
+
* @param {number} value - The resolution.
|
|
273
|
+
*/
|
|
274
|
+
setResolution(value) {
|
|
275
|
+
this.resolution = value;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Updates this effect.
|
|
279
|
+
*
|
|
280
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
281
|
+
* @param {WebGLRenderTarget} inputBuffer - A frame buffer that contains the result of the previous pass.
|
|
282
|
+
* @param {number} [deltaTime] - The time between the last frame and the current one in seconds.
|
|
283
|
+
*/
|
|
284
|
+
update(renderer, inputBuffer, deltaTime) {
|
|
285
|
+
if (this.adaptiveLuminancePass.enabled) {
|
|
286
|
+
this.luminancePass.render(renderer, inputBuffer);
|
|
287
|
+
this.adaptiveLuminancePass.render(renderer, null, null, deltaTime);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
exports.ToneMappingEffect = ToneMappingEffect;
|
|
292
|
+
//# sourceMappingURL=ToneMappingEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingEffect.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,mDAOyB;AACzB,iCAMgB;AAChB,iDAA8C;AAE9C;;;;;;;;GAQG;AAEH,MAAa,iBAAkB,SAAQ,uBAAM;IAK5C;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,EACX,aAAa,GAAG,8BAAa,CAAC,GAAG,EACjC,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,gCAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,gCAAe,CAAC,GAAG,EAC1E,UAAU,GAAG,GAAG,EAChB,YAAY,GAAG,GAAG,EAClB,UAAU,GAAG,YAAY,EACzB,UAAU,GAAG,GAAG,EAChB,YAAY,GAAG,IAAI,EACnB,gBAAgB,GAAG,GAAG,EACtB,cAAc,GAAG,GAAG,MAYjB,EAAE;QACL,KAAK,CAAC,mBAAmB,EAAE,2BAAY,EAAE;YACxC,UAAU,EAAE,gCAAe,CAAC,KAAK;YACjC,aAAa;YACb,QAAQ,EAAE,IAAI,GAAG,CAAC;gBACjB,CAAC,iBAAiB,EAAE,IAAI,eAAO,CAAC,IAAI,CAAC,CAAC;gBACtC,CAAC,cAAc,EAAE,IAAI,eAAO,CAAC,YAAY,CAAC,CAAC;gBAC3C,CAAC,YAAY,EAAE,IAAI,eAAO,CAAC,UAAU,CAAC,CAAC;gBACvC,CAAC,YAAY,EAAE,IAAI,eAAO,CAAC,UAAU,CAAC,CAAC;gBACvC,CAAC,kBAAkB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qBAAqB,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IAEI,OAAO,CAAC,KAAsB;QACpC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IAEI,aAAa,CAAC,KAAa;QACjC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IAEI,MAAM,CAAC,QAAuB,EAAE,WAA8B,EAAE,SAAiB;QACvF,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE;YACtC,IAAI,CAAC,aAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;SACnE;IACF,CAAC;CACD;AAtWD,8CAsWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ToneMappingPass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingPass.d.ts","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingPass.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { Pass, Resolution } from "postprocessing";
|
|
3
|
+
// import { Camera, Color, DepthStencilFormat, DepthTexture, Line, LineLoop, LineSegments, Mesh, MeshNormalMaterial, MeshPhysicalMaterial, NearestFilter, Object3D, Scene, Texture, UnsignedInt248Type, UnsignedIntType, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
4
|
+
// import { RenderPass } from "./RenderPass";
|
|
5
|
+
// /**
|
|
6
|
+
// * A pass that renders the normals of a given scene.
|
|
7
|
+
// */
|
|
8
|
+
// export class NormalPass extends Pass {
|
|
9
|
+
// renderPass: RenderPass;
|
|
10
|
+
// renderTarget: WebGLRenderTarget | undefined;
|
|
11
|
+
// resolution: Resolution;
|
|
12
|
+
// dTexture: any;
|
|
13
|
+
// /**
|
|
14
|
+
// * Constructs a new normal pass.
|
|
15
|
+
// *
|
|
16
|
+
// * @param {Scene} scene - The scene to render.
|
|
17
|
+
// * @param {Camera} camera - The camera to use to render the scene.
|
|
18
|
+
// * @param {Object} [options] - The options.
|
|
19
|
+
// * @param {WebGLRenderTarget} [options.renderTarget] - A custom render target.
|
|
20
|
+
// * @param {Number} [options.resolutionScale=1.0] - The resolution scale.
|
|
21
|
+
// * @param {Number} [options.resolutionX=Resolution.AUTO_SIZE] - The horizontal resolution.
|
|
22
|
+
// * @param {Number} [options.resolutionY=Resolution.AUTO_SIZE] - The vertical resolution.
|
|
23
|
+
// * @param {Number} [options.width=Resolution.AUTO_SIZE] - Deprecated. Use resolutionX instead.
|
|
24
|
+
// * @param {Number} [options.height=Resolution.AUTO_SIZE] - Deprecated. Use resolutionY instead.
|
|
25
|
+
// */
|
|
26
|
+
// constructor(scene: Scene, camera: Camera, {
|
|
27
|
+
// renderTarget,
|
|
28
|
+
// resolutionScale = 1.0,
|
|
29
|
+
// width = Resolution.AUTO_SIZE,
|
|
30
|
+
// height = Resolution.AUTO_SIZE,
|
|
31
|
+
// resolutionX = width,
|
|
32
|
+
// resolutionY = height
|
|
33
|
+
// }: { renderTarget?: WebGLRenderTarget; resolutionScale?: number; resolutionX?: number; resolutionY?: number; width?: number; height?: number; } = {}) {
|
|
34
|
+
// super("NormalPass");
|
|
35
|
+
// this.needsSwap = false;
|
|
36
|
+
// /**
|
|
37
|
+
// * A render pass.
|
|
38
|
+
// *
|
|
39
|
+
// * @type {RenderPass}
|
|
40
|
+
// * @private
|
|
41
|
+
// */
|
|
42
|
+
// this.renderPass = new RenderPass(scene, camera, new MeshNormalMaterial());
|
|
43
|
+
// const renderPass = this.renderPass;
|
|
44
|
+
// renderPass.ignoreBackground = true;
|
|
45
|
+
// renderPass.skipShadowMapUpdate = true;
|
|
46
|
+
// const clearPass = renderPass.getClearPass();
|
|
47
|
+
// clearPass.overrideClearColor = new Color(0x7777ff);
|
|
48
|
+
// clearPass.overrideClearAlpha = 1.0;
|
|
49
|
+
// /**
|
|
50
|
+
// * A render target for the scene normals.
|
|
51
|
+
// *
|
|
52
|
+
// * @type {WebGLRenderTarget}
|
|
53
|
+
// * @readonly
|
|
54
|
+
// */
|
|
55
|
+
// this.renderTarget = renderTarget;
|
|
56
|
+
// if (this.renderTarget === undefined) {
|
|
57
|
+
// this.renderTarget = new WebGLRenderTarget(1, 1, {
|
|
58
|
+
// minFilter: NearestFilter,
|
|
59
|
+
// magFilter: NearestFilter
|
|
60
|
+
// });
|
|
61
|
+
// this.renderTarget.texture.name = "NormalPass.Target";
|
|
62
|
+
// }
|
|
63
|
+
// this.dTexture = new DepthTexture(1, 1);
|
|
64
|
+
// // Hack: Make sure the input buffer uses the depth texture.
|
|
65
|
+
// this.renderTarget.depthTexture = this.dTexture;
|
|
66
|
+
// this.renderTarget.dispose();
|
|
67
|
+
// if (this.renderTarget.stencilBuffer) {
|
|
68
|
+
// this.dTexture.format = DepthStencilFormat;
|
|
69
|
+
// this.dTexture.type = UnsignedInt248Type;
|
|
70
|
+
// } else {
|
|
71
|
+
// this.dTexture.type = UnsignedIntType;
|
|
72
|
+
// }
|
|
73
|
+
// /**
|
|
74
|
+
// * The resolution.
|
|
75
|
+
// *
|
|
76
|
+
// * @type {Resolution}
|
|
77
|
+
// * @readonly
|
|
78
|
+
// */
|
|
79
|
+
// const resolution: Resolution = this.resolution = new Resolution(this, resolutionX, resolutionY, resolutionScale);
|
|
80
|
+
// resolution.addEventListener("change", (e) => this.setSize(resolution.baseWidth, resolution.baseHeight));
|
|
81
|
+
// }
|
|
82
|
+
// set mainScene(value: Scene) {
|
|
83
|
+
// this.renderPass.mainScene = value;
|
|
84
|
+
// }
|
|
85
|
+
// set mainCamera(value: Camera) {
|
|
86
|
+
// this.renderPass.mainCamera = value;
|
|
87
|
+
// }
|
|
88
|
+
// /**
|
|
89
|
+
// * The normal texture.
|
|
90
|
+
// *
|
|
91
|
+
// * @type {Texture}
|
|
92
|
+
// */
|
|
93
|
+
// get texture() {
|
|
94
|
+
// return this.renderTarget?.texture;
|
|
95
|
+
// }
|
|
96
|
+
// get depthTexture() {
|
|
97
|
+
// return this.renderTarget?.depthTexture;
|
|
98
|
+
// }
|
|
99
|
+
// /**
|
|
100
|
+
// * The normal texture.
|
|
101
|
+
// *
|
|
102
|
+
// * @deprecated Use texture instead.
|
|
103
|
+
// * @return {Texture} The texture.
|
|
104
|
+
// */
|
|
105
|
+
// getTexture(): Texture | undefined {
|
|
106
|
+
// return this.renderTarget?.texture;
|
|
107
|
+
// }
|
|
108
|
+
// /**
|
|
109
|
+
// * Returns the resolution settings.
|
|
110
|
+
// *
|
|
111
|
+
// * @deprecated Use resolution instead.
|
|
112
|
+
// * @return {Resolution} The resolution.
|
|
113
|
+
// */
|
|
114
|
+
// getResolution(): Resolution {
|
|
115
|
+
// return this.resolution;
|
|
116
|
+
// }
|
|
117
|
+
// /**
|
|
118
|
+
// * Returns the current resolution scale.
|
|
119
|
+
// *
|
|
120
|
+
// * @return {Number} The resolution scale.
|
|
121
|
+
// * @deprecated Use resolution.preferredWidth or resolution.preferredHeight instead.
|
|
122
|
+
// */
|
|
123
|
+
// getResolutionScale(): number {
|
|
124
|
+
// return this.resolution.scale;
|
|
125
|
+
// }
|
|
126
|
+
// /**
|
|
127
|
+
// * Sets the resolution scale.
|
|
128
|
+
// *
|
|
129
|
+
// * @param {Number} scale - The new resolution scale.
|
|
130
|
+
// * @deprecated Use resolution.preferredWidth or resolution.preferredHeight instead.
|
|
131
|
+
// */
|
|
132
|
+
// setResolutionScale(scale: number) {
|
|
133
|
+
// this.resolution.scale = scale;
|
|
134
|
+
// }
|
|
135
|
+
// /**
|
|
136
|
+
// * Renders the scene normals.
|
|
137
|
+
// *
|
|
138
|
+
// * @param {WebGLRenderer} renderer - The renderer.
|
|
139
|
+
// * @param {WebGLRenderTarget} inputBuffer - A frame buffer that contains the result of the previous pass.
|
|
140
|
+
// * @param {WebGLRenderTarget} outputBuffer - A frame buffer that serves as the output render target unless this pass renders to screen.
|
|
141
|
+
// * @param {Number} [deltaTime] - The time between the last frame and the current one in seconds.
|
|
142
|
+
// * @param {Boolean} [stencilTest] - Indicates whether a stencil mask is active.
|
|
143
|
+
// */
|
|
144
|
+
// render(renderer: WebGLRenderer) {
|
|
145
|
+
// const renderTarget = this.renderToScreen ? null : this.renderTarget;
|
|
146
|
+
// this.renderPass.render(renderer, renderTarget!, renderTarget!, 0, true);
|
|
147
|
+
// }
|
|
148
|
+
// /**
|
|
149
|
+
// * Updates the size of this pass.
|
|
150
|
+
// *
|
|
151
|
+
// * @param {Number} width - The width.
|
|
152
|
+
// * @param {Number} height - The height.
|
|
153
|
+
// */
|
|
154
|
+
// setSize(width: number, height: number) {
|
|
155
|
+
// const resolution = this.resolution;
|
|
156
|
+
// resolution.setBaseSize(width, height);
|
|
157
|
+
// this.renderTarget?.setSize(resolution.width, resolution.height);
|
|
158
|
+
// }
|
|
159
|
+
// }
|
|
160
|
+
//# sourceMappingURL=ToneMappingPass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingPass.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingPass.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,yQAAyQ;AACzQ,6CAA6C;AAE7C,MAAM;AACN,uDAAuD;AACvD,MAAM;AAEN,yCAAyC;AACzC,8BAA8B;AAC9B,mDAAmD;AACnD,8BAA8B;AAC9B,qBAAqB;AAErB,UAAU;AACV,uCAAuC;AACvC,SAAS;AACT,qDAAqD;AACrD,yEAAyE;AACzE,kDAAkD;AAClD,qFAAqF;AACrF,+EAA+E;AAC/E,iGAAiG;AACjG,+FAA+F;AAC/F,qGAAqG;AACrG,sGAAsG;AACtG,UAAU;AAEV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UAAU;AAEV,oCAAoC;AAEpC,kCAAkC;AAElC,QAAQ;AAER,UAAU;AACV,+CAA+C;AAC/C,SAAS;AACT,gDAAgD;AAChD,0FAA0F;AAC1F,UAAU;AAEV,qCAAqC;AAErC,wCAAwC;AAExC,QAAQ;AAER,UAAU;AACV,oCAAoC;AACpC,SAAS;AACT,2DAA2D;AAC3D,0FAA0F;AAC1F,UAAU;AAEV,0CAA0C;AAE1C,yCAAyC;AAEzC,QAAQ;AAER,UAAU;AACV,oCAAoC;AACpC,SAAS;AACT,yDAAyD;AACzD,gHAAgH;AAChH,8IAA8I;AAC9I,uGAAuG;AACvG,sFAAsF;AACtF,UAAU;AAEV,wCAAwC;AAExC,+EAA+E;AAC/E,mFAAmF;AAEnF,QAAQ;AAER,UAAU;AACV,wCAAwC;AACxC,SAAS;AACT,4CAA4C;AAC5C,8CAA8C;AAC9C,UAAU;AAEV,+CAA+C;AAE/C,8CAA8C;AAC9C,iDAAiD;AACjD,2EAA2E;AAE3E,QAAQ;AAER,IAAI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const tone_mapping = "\n#include <tonemapping_pars_fragment>\n\nuniform float whitePoint;\n\n#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3\n\n\t// Reinhard 2\n\n\tuniform float middleGrey;\n\n\t#if TONE_MAPPING_MODE == 3\n\n\t\tuniform lowp sampler2D luminanceBuffer;\n\n\t#else\n\n\t\tuniform float averageLuminance;\n\n\t#endif\n\n\tvec3 Reinhard2ToneMapping(vec3 color) {\n\n\t\tcolor *= toneMappingExposure;\n\n\t\t// Calculate the luminance of the current pixel.\n\t\tfloat l = luminance(color);\n\n\t\t#if TONE_MAPPING_MODE == 3\n\n\t\t\t// Get the average luminance from the adaptive 1x1 buffer.\n\t\t\tfloat lumAvg = unpackRGBAToFloat(texture2D(luminanceBuffer, vec2(0.5)));\n\n\t\t#else\n\n\t\t\tfloat lumAvg = averageLuminance;\n\n\t\t#endif\n\n\t\tfloat lumScaled = (l * middleGrey) / max(lumAvg, 1e-6);\n\t\tfloat lumCompressed = lumScaled * (1.0 + lumScaled / (whitePoint * whitePoint));\n\t\tlumCompressed /= (1.0 + lumScaled);\n\n\t\treturn clamp(lumCompressed * color, 0.0, 1.0);\n\n\t}\n\n#elif TONE_MAPPING_MODE == 4\n\n\t// Uncharted 2: http://filmicworlds.com/blog/filmic-tonemapping-operators\n\n\t#define A 0.15\n\t#define B 0.50\n\t#define C 0.10\n\t#define D 0.20\n\t#define E 0.02\n\t#define F 0.30\n\n\tvec3 Uncharted2Helper(const in vec3 x) {\n\n\t\treturn ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;\n\n\t}\n\n\tvec3 Uncharted2ToneMapping(vec3 color) {\n\n\t\tcolor *= toneMappingExposure;\n\t\treturn clamp(Uncharted2Helper(color) / Uncharted2Helper(vec3(whitePoint)), 0.0, 1.0);\n\n\t}\n\n#endif\n\nvoid mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth, out vec4 outputColor) {\n\t#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3\n\n\t\toutputColor = vec4(Reinhard2ToneMapping(inputColor.rgb), inputColor.a);\n\n\t#elif TONE_MAPPING_MODE == 4\n\n\t\toutputColor = vec4(Uncharted2ToneMapping(inputColor.rgb), inputColor.a);\n\n\t#else\n\n\t\toutputColor = vec4(toneMapping(inputColor.rgb), inputColor.a);\n\n\t#endif\n\n if(depth >= 1.0) {\n outputColor = inputColor;\n }\n}\n";
|
|
2
|
+
//# sourceMappingURL=tone-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-mapping.d.ts","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/tone-mapping.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,+gEA4FxB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tone_mapping = void 0;
|
|
4
|
+
exports.tone_mapping = `
|
|
5
|
+
#include <tonemapping_pars_fragment>
|
|
6
|
+
|
|
7
|
+
uniform float whitePoint;
|
|
8
|
+
|
|
9
|
+
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
|
|
10
|
+
|
|
11
|
+
// Reinhard 2
|
|
12
|
+
|
|
13
|
+
uniform float middleGrey;
|
|
14
|
+
|
|
15
|
+
#if TONE_MAPPING_MODE == 3
|
|
16
|
+
|
|
17
|
+
uniform lowp sampler2D luminanceBuffer;
|
|
18
|
+
|
|
19
|
+
#else
|
|
20
|
+
|
|
21
|
+
uniform float averageLuminance;
|
|
22
|
+
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
vec3 Reinhard2ToneMapping(vec3 color) {
|
|
26
|
+
|
|
27
|
+
color *= toneMappingExposure;
|
|
28
|
+
|
|
29
|
+
// Calculate the luminance of the current pixel.
|
|
30
|
+
float l = luminance(color);
|
|
31
|
+
|
|
32
|
+
#if TONE_MAPPING_MODE == 3
|
|
33
|
+
|
|
34
|
+
// Get the average luminance from the adaptive 1x1 buffer.
|
|
35
|
+
float lumAvg = unpackRGBAToFloat(texture2D(luminanceBuffer, vec2(0.5)));
|
|
36
|
+
|
|
37
|
+
#else
|
|
38
|
+
|
|
39
|
+
float lumAvg = averageLuminance;
|
|
40
|
+
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
float lumScaled = (l * middleGrey) / max(lumAvg, 1e-6);
|
|
44
|
+
float lumCompressed = lumScaled * (1.0 + lumScaled / (whitePoint * whitePoint));
|
|
45
|
+
lumCompressed /= (1.0 + lumScaled);
|
|
46
|
+
|
|
47
|
+
return clamp(lumCompressed * color, 0.0, 1.0);
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#elif TONE_MAPPING_MODE == 4
|
|
52
|
+
|
|
53
|
+
// Uncharted 2: http://filmicworlds.com/blog/filmic-tonemapping-operators
|
|
54
|
+
|
|
55
|
+
#define A 0.15
|
|
56
|
+
#define B 0.50
|
|
57
|
+
#define C 0.10
|
|
58
|
+
#define D 0.20
|
|
59
|
+
#define E 0.02
|
|
60
|
+
#define F 0.30
|
|
61
|
+
|
|
62
|
+
vec3 Uncharted2Helper(const in vec3 x) {
|
|
63
|
+
|
|
64
|
+
return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
vec3 Uncharted2ToneMapping(vec3 color) {
|
|
69
|
+
|
|
70
|
+
color *= toneMappingExposure;
|
|
71
|
+
return clamp(Uncharted2Helper(color) / Uncharted2Helper(vec3(whitePoint)), 0.0, 1.0);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth, out vec4 outputColor) {
|
|
78
|
+
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
|
|
79
|
+
|
|
80
|
+
outputColor = vec4(Reinhard2ToneMapping(inputColor.rgb), inputColor.a);
|
|
81
|
+
|
|
82
|
+
#elif TONE_MAPPING_MODE == 4
|
|
83
|
+
|
|
84
|
+
outputColor = vec4(Uncharted2ToneMapping(inputColor.rgb), inputColor.a);
|
|
85
|
+
|
|
86
|
+
#else
|
|
87
|
+
|
|
88
|
+
outputColor = vec4(toneMapping(inputColor.rgb), inputColor.a);
|
|
89
|
+
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
if(depth >= 1.0) {
|
|
93
|
+
outputColor = inputColor;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
//# sourceMappingURL=tone-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-mapping.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/tone-mapping.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4F3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.rendering-engine.rendering-engine-threejs",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shapediver/viewer.data-engine.gltf-converter": "3.8.
|
|
42
|
-
"@shapediver/viewer.data-engine.shared-types": "3.8.
|
|
43
|
-
"@shapediver/viewer.data-engine.tag3d-engine": "3.8.
|
|
44
|
-
"@shapediver/viewer.rendering-engine.animation-engine": "3.8.
|
|
45
|
-
"@shapediver/viewer.rendering-engine.animation-frame-engine": "3.8.
|
|
46
|
-
"@shapediver/viewer.rendering-engine.camera-engine": "3.8.
|
|
47
|
-
"@shapediver/viewer.rendering-engine.canvas-engine": "3.8.
|
|
48
|
-
"@shapediver/viewer.rendering-engine.intersection-engine": "3.8.
|
|
49
|
-
"@shapediver/viewer.rendering-engine.light-engine": "3.8.
|
|
50
|
-
"@shapediver/viewer.rendering-engine.rendering-engine": "3.8.
|
|
51
|
-
"@shapediver/viewer.shared.global-access-objects": "3.8.
|
|
52
|
-
"@shapediver/viewer.shared.math": "3.8.
|
|
53
|
-
"@shapediver/viewer.shared.node-tree": "3.8.
|
|
54
|
-
"@shapediver/viewer.shared.services": "3.8.
|
|
55
|
-
"@shapediver/viewer.shared.types": "3.8.
|
|
41
|
+
"@shapediver/viewer.data-engine.gltf-converter": "3.8.4",
|
|
42
|
+
"@shapediver/viewer.data-engine.shared-types": "3.8.4",
|
|
43
|
+
"@shapediver/viewer.data-engine.tag3d-engine": "3.8.4",
|
|
44
|
+
"@shapediver/viewer.rendering-engine.animation-engine": "3.8.4",
|
|
45
|
+
"@shapediver/viewer.rendering-engine.animation-frame-engine": "3.8.4",
|
|
46
|
+
"@shapediver/viewer.rendering-engine.camera-engine": "3.8.4",
|
|
47
|
+
"@shapediver/viewer.rendering-engine.canvas-engine": "3.8.4",
|
|
48
|
+
"@shapediver/viewer.rendering-engine.intersection-engine": "3.8.4",
|
|
49
|
+
"@shapediver/viewer.rendering-engine.light-engine": "3.8.4",
|
|
50
|
+
"@shapediver/viewer.rendering-engine.rendering-engine": "3.8.4",
|
|
51
|
+
"@shapediver/viewer.shared.global-access-objects": "3.8.4",
|
|
52
|
+
"@shapediver/viewer.shared.math": "3.8.4",
|
|
53
|
+
"@shapediver/viewer.shared.node-tree": "3.8.4",
|
|
54
|
+
"@shapediver/viewer.shared.services": "3.8.4",
|
|
55
|
+
"@shapediver/viewer.shared.types": "3.8.4",
|
|
56
56
|
"@tweenjs/tween.js": "^18.6.4",
|
|
57
57
|
"@types/stats.js": "^0.17.0",
|
|
58
58
|
"@types/three": "0.162.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"stats.js": "^0.17.0",
|
|
62
62
|
"three": "0.162.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "21004ab0437061c44dcb1f141fd0fc96e3b53547"
|
|
65
65
|
}
|