@xviewer.js/postprocessing 1.0.0-alpha.4 → 1.0.0-alpha.6
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/main.js +462 -438
- package/dist/main.js.map +1 -1
- package/dist/module.js +465 -441
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
package/dist/module.js
CHANGED
|
@@ -1,20 +1,284 @@
|
|
|
1
1
|
import { Plugin, property } from '@xviewer.js/core';
|
|
2
|
-
import {
|
|
3
|
-
import { ShaderChunk, ShaderLib, UniformsUtils, ShaderMaterial, Uniform, Vector2, Matrix4, Vector3, NoBlending, GLSL3, FramebufferTexture, LinearFilter, Clock, Quaternion, WebGLRenderTarget, NearestFilter, DataTexture, RGBAFormat, FloatType, ClampToEdgeWrapping, LinearMipMapLinearFilter, EquirectangularReflectionMapping, TextureLoader, RepeatWrapping, NoColorSpace, MeshPhysicalMaterial, Color, DepthTexture, RedFormat, Matrix3,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { RenderPass, EffectPass, EffectComposer, ToneMappingMode, ToneMappingEffect, BloomEffect, BlendFunction, FXAAEffect, SMAAPreset, EdgeDetectionMode, PredicationMode, SMAAEffect, Pass, Effect, Selection, NormalPass } from 'postprocessing';
|
|
3
|
+
import { HalfFloatType, ShaderChunk, ShaderLib, UniformsUtils, ShaderMaterial, Uniform, Vector2, Matrix4, Vector3, NoBlending, GLSL3, FramebufferTexture, LinearFilter, Clock, Quaternion, WebGLRenderTarget, NearestFilter, DataTexture, RGBAFormat, FloatType, ClampToEdgeWrapping, LinearMipMapLinearFilter, EquirectangularReflectionMapping, TextureLoader, RepeatWrapping, NoColorSpace, MeshPhysicalMaterial, Color, DepthTexture, RedFormat, Matrix3, WebGLMultipleRenderTargets, SRGBColorSpace } from 'three';
|
|
4
|
+
|
|
5
|
+
class EffectComposerPlugin extends Plugin {
|
|
6
|
+
static Instance(viewer) {
|
|
7
|
+
return viewer.getPlugin(EffectComposerPlugin, true);
|
|
8
|
+
}
|
|
9
|
+
get multisampling() {
|
|
10
|
+
return this._composer.multisampling;
|
|
11
|
+
}
|
|
12
|
+
set multisampling(v) {
|
|
13
|
+
this._composer.multisampling = v;
|
|
14
|
+
}
|
|
15
|
+
getPass(constructor) {
|
|
16
|
+
return this._composer.passes.find((v)=>v.constructor === constructor);
|
|
17
|
+
}
|
|
18
|
+
addPass(pass) {
|
|
19
|
+
this._composer.addPass(pass, this._composer.passes.length - 1);
|
|
20
|
+
this._checkOutputPass();
|
|
21
|
+
return pass;
|
|
22
|
+
}
|
|
23
|
+
removePass(pass) {
|
|
24
|
+
this._composer.removePass(pass);
|
|
25
|
+
this._checkOutputPass();
|
|
26
|
+
}
|
|
27
|
+
activePass(pass, v) {
|
|
28
|
+
pass.enabled = v;
|
|
29
|
+
this._checkOutputPass();
|
|
30
|
+
return pass;
|
|
31
|
+
}
|
|
32
|
+
_checkOutputPass() {
|
|
33
|
+
const count = this._composer.passes.filter((v)=>v.enabled && v.name !== "VelocityDepthNormalPass" && v !== this._outputPass).length;
|
|
34
|
+
this._outputPass.enabled = this._composer.multisampling > 0 && count === 1;
|
|
35
|
+
this._setRenderToScreen();
|
|
36
|
+
}
|
|
37
|
+
_setRenderToScreen() {
|
|
38
|
+
const passes = this._composer.passes;
|
|
39
|
+
for(let k = 0, i = passes.length; i--;){
|
|
40
|
+
let pass = passes[i];
|
|
41
|
+
if (pass.enabled && pass.name !== "VelocityDepthNormalPass" && k === 0) {
|
|
42
|
+
k = i;
|
|
43
|
+
}
|
|
44
|
+
pass.renderToScreen = k === i;
|
|
10
45
|
}
|
|
46
|
+
}
|
|
47
|
+
constructor(props){
|
|
48
|
+
super();
|
|
49
|
+
this.install = ()=>{
|
|
50
|
+
const { renderer, scene, camera } = this.viewer;
|
|
51
|
+
this._renderPass = new RenderPass(scene, camera);
|
|
52
|
+
this._outputPass = new EffectPass(camera);
|
|
53
|
+
this._composer = new EffectComposer(renderer, Object.assign({
|
|
54
|
+
frameBufferType: HalfFloatType
|
|
55
|
+
}, props));
|
|
56
|
+
this._composer.addPass(this._renderPass);
|
|
57
|
+
this._composer.addPass(this._outputPass);
|
|
58
|
+
this.viewer._onResize = (width, height)=>this._composer.setSize(width, height);
|
|
59
|
+
this.viewer._onRender = (dt)=>this._composer.render(dt);
|
|
60
|
+
};
|
|
61
|
+
this.uninstall = ()=>{
|
|
62
|
+
this._composer.dispose();
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
11
66
|
|
|
12
|
-
|
|
13
|
-
|
|
67
|
+
/******************************************************************************
|
|
68
|
+
Copyright (c) Microsoft Corporation.
|
|
14
69
|
|
|
15
|
-
|
|
70
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
71
|
+
purpose with or without fee is hereby granted.
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
74
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
75
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
76
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
77
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
78
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
79
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
80
|
+
***************************************************************************** */
|
|
81
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
function __decorate(decorators, target, key, desc) {
|
|
85
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
86
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
87
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
88
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
89
|
}
|
|
17
90
|
|
|
91
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
92
|
+
var e = new Error(message);
|
|
93
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
class PassPlugin extends Plugin {
|
|
97
|
+
get enable() {
|
|
98
|
+
return this.pass.enabled;
|
|
99
|
+
}
|
|
100
|
+
set enable(v) {
|
|
101
|
+
this.setEnable(v);
|
|
102
|
+
}
|
|
103
|
+
get composer() {
|
|
104
|
+
return EffectComposerPlugin.Instance(this.viewer);
|
|
105
|
+
}
|
|
106
|
+
setEnable(v) {
|
|
107
|
+
this.composer.activePass(this.pass, v);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
__decorate([
|
|
111
|
+
property
|
|
112
|
+
], PassPlugin.prototype, "enable", null);
|
|
113
|
+
|
|
114
|
+
class ToneMappingPlugin extends PassPlugin {
|
|
115
|
+
get mode() {
|
|
116
|
+
return this.effect.mode;
|
|
117
|
+
}
|
|
118
|
+
set mode(v) {
|
|
119
|
+
this.effect.mode = v;
|
|
120
|
+
}
|
|
121
|
+
constructor(props){
|
|
122
|
+
super();
|
|
123
|
+
this.install = ()=>{
|
|
124
|
+
this.effect = new ToneMappingEffect(props);
|
|
125
|
+
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, this.effect));
|
|
126
|
+
};
|
|
127
|
+
this.uninstall = ()=>{
|
|
128
|
+
this.composer.removePass(this.pass);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
__decorate([
|
|
133
|
+
property({
|
|
134
|
+
value: ToneMappingMode
|
|
135
|
+
})
|
|
136
|
+
], ToneMappingPlugin.prototype, "mode", null);
|
|
137
|
+
|
|
138
|
+
class BloomPlugin extends PassPlugin {
|
|
139
|
+
get intensity() {
|
|
140
|
+
return this.effect.intensity;
|
|
141
|
+
}
|
|
142
|
+
set intensity(v) {
|
|
143
|
+
this.effect.intensity = v;
|
|
144
|
+
}
|
|
145
|
+
get luminanceThreshold() {
|
|
146
|
+
return this.effect.luminanceMaterial.threshold;
|
|
147
|
+
}
|
|
148
|
+
set luminanceThreshold(v) {
|
|
149
|
+
this.effect.luminanceMaterial.threshold = v;
|
|
150
|
+
}
|
|
151
|
+
get luminanceSmoothing() {
|
|
152
|
+
return this.effect.luminanceMaterial.smoothing;
|
|
153
|
+
}
|
|
154
|
+
set luminanceSmoothing(v) {
|
|
155
|
+
this.effect.luminanceMaterial.smoothing = v;
|
|
156
|
+
}
|
|
157
|
+
constructor(props){
|
|
158
|
+
super();
|
|
159
|
+
this.install = ()=>{
|
|
160
|
+
this.effect = new BloomEffect({
|
|
161
|
+
blendFunction: BlendFunction.ADD,
|
|
162
|
+
...props
|
|
163
|
+
});
|
|
164
|
+
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, this.effect));
|
|
165
|
+
};
|
|
166
|
+
this.uninstall = ()=>{
|
|
167
|
+
this.composer.removePass(this.pass);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
__decorate([
|
|
172
|
+
property({
|
|
173
|
+
min: 0,
|
|
174
|
+
max: 2,
|
|
175
|
+
step: 0.01
|
|
176
|
+
})
|
|
177
|
+
], BloomPlugin.prototype, "intensity", null);
|
|
178
|
+
__decorate([
|
|
179
|
+
property({
|
|
180
|
+
min: 0,
|
|
181
|
+
max: 10,
|
|
182
|
+
step: 0.01
|
|
183
|
+
})
|
|
184
|
+
], BloomPlugin.prototype, "luminanceThreshold", null);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({
|
|
187
|
+
min: 0,
|
|
188
|
+
max: 10,
|
|
189
|
+
step: 0.01
|
|
190
|
+
})
|
|
191
|
+
], BloomPlugin.prototype, "luminanceSmoothing", null);
|
|
192
|
+
|
|
193
|
+
class FXAAPlugin extends PassPlugin {
|
|
194
|
+
constructor(){
|
|
195
|
+
super();
|
|
196
|
+
this.install = ()=>{
|
|
197
|
+
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, new FXAAEffect()));
|
|
198
|
+
};
|
|
199
|
+
this.uninstall = ()=>{
|
|
200
|
+
this.composer.removePass(this.pass);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
class SMAAPlugin extends PassPlugin {
|
|
206
|
+
get preset() {
|
|
207
|
+
return this._preset;
|
|
208
|
+
}
|
|
209
|
+
set preset(v) {
|
|
210
|
+
if (this._preset !== v) {
|
|
211
|
+
this._preset = v;
|
|
212
|
+
this.effect.applyPreset(v);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
get edgeDetectionMode() {
|
|
216
|
+
return this.effect.edgeDetectionMaterial.edgeDetectionMode;
|
|
217
|
+
}
|
|
218
|
+
set edgeDetectionMode(v) {
|
|
219
|
+
this.effect.edgeDetectionMaterial.edgeDetectionMode = v;
|
|
220
|
+
}
|
|
221
|
+
get predicationMode() {
|
|
222
|
+
return this.effect.edgeDetectionMaterial.predicationMode;
|
|
223
|
+
}
|
|
224
|
+
set predicationMode(v) {
|
|
225
|
+
this.effect.edgeDetectionMaterial.predicationMode = v;
|
|
226
|
+
}
|
|
227
|
+
constructor(props = {}){
|
|
228
|
+
super();
|
|
229
|
+
this._preset = SMAAPreset.MEDIUM;
|
|
230
|
+
this.install = ()=>{
|
|
231
|
+
this.effect = new SMAAEffect(props);
|
|
232
|
+
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, this.effect));
|
|
233
|
+
};
|
|
234
|
+
this.uninstall = ()=>{
|
|
235
|
+
this.composer.removePass(this.pass);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
__decorate([
|
|
240
|
+
property({
|
|
241
|
+
value: SMAAPreset
|
|
242
|
+
})
|
|
243
|
+
], SMAAPlugin.prototype, "preset", null);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({
|
|
246
|
+
value: EdgeDetectionMode
|
|
247
|
+
})
|
|
248
|
+
], SMAAPlugin.prototype, "edgeDetectionMode", null);
|
|
249
|
+
__decorate([
|
|
250
|
+
property({
|
|
251
|
+
value: PredicationMode
|
|
252
|
+
})
|
|
253
|
+
], SMAAPlugin.prototype, "predicationMode", null);
|
|
254
|
+
|
|
255
|
+
class MSAAPlugin extends Plugin {
|
|
256
|
+
get enable() {
|
|
257
|
+
return this.composer.multisampling > 0;
|
|
258
|
+
}
|
|
259
|
+
set enable(v) {
|
|
260
|
+
this.composer.multisampling = v ? this._maxSamples : 0;
|
|
261
|
+
}
|
|
262
|
+
get composer() {
|
|
263
|
+
return EffectComposerPlugin.Instance(this.viewer);
|
|
264
|
+
}
|
|
265
|
+
constructor(){
|
|
266
|
+
super();
|
|
267
|
+
this._maxSamples = 4;
|
|
268
|
+
this.install = ()=>{
|
|
269
|
+
const { renderer } = this.viewer;
|
|
270
|
+
this._maxSamples = Math.min(4, renderer.capabilities.maxSamples);
|
|
271
|
+
this.composer.multisampling = this._maxSamples;
|
|
272
|
+
};
|
|
273
|
+
this.uninstall = ()=>{
|
|
274
|
+
this.composer.multisampling = 0;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
__decorate([
|
|
279
|
+
property
|
|
280
|
+
], MSAAPlugin.prototype, "enable", null);
|
|
281
|
+
|
|
18
282
|
// from: https://news.ycombinator.com/item?id=17876741
|
|
19
283
|
// reference: http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
|
20
284
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -296,7 +560,10 @@ class TemporalReprojectPass extends Pass {
|
|
|
296
560
|
this._scene = scene;
|
|
297
561
|
this._camera = camera;
|
|
298
562
|
this.textureCount = textureCount;
|
|
299
|
-
options =
|
|
563
|
+
options = {
|
|
564
|
+
...defaultTemporalReprojectPassOptions,
|
|
565
|
+
...options
|
|
566
|
+
};
|
|
300
567
|
this.renderTarget = new WebGLRenderTarget(1, 1, {
|
|
301
568
|
count: textureCount,
|
|
302
569
|
minFilter: NearestFilter,
|
|
@@ -389,15 +656,21 @@ class TRAAEffect extends Effect {
|
|
|
389
656
|
this._scene = scene;
|
|
390
657
|
this._camera = camera;
|
|
391
658
|
this.velocityDepthNormalPass = velocityDepthNormalPass;
|
|
392
|
-
options =
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
659
|
+
options = {
|
|
660
|
+
...options,
|
|
661
|
+
...{
|
|
662
|
+
maxBlend: 0.9,
|
|
663
|
+
neighborhoodClamp: true,
|
|
664
|
+
neighborhoodClampIntensity: 1,
|
|
665
|
+
neighborhoodClampRadius: 1,
|
|
666
|
+
logTransform: true,
|
|
667
|
+
confidencePower: 4
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
this.options = {
|
|
671
|
+
...defaultTemporalReprojectPassOptions,
|
|
672
|
+
...options
|
|
673
|
+
};
|
|
401
674
|
this.setSize(options.width, options.height);
|
|
402
675
|
}
|
|
403
676
|
}
|
|
@@ -410,8 +683,8 @@ class CubeToEquirectEnvPass extends Pass {
|
|
|
410
683
|
generateEquirectEnvMap(renderer, cubeMap, width = null, height = null, maxWidth = 4096) {
|
|
411
684
|
if (width === null && height === null) {
|
|
412
685
|
const w = cubeMap.source.data[0].width;
|
|
413
|
-
const widthEquirect =
|
|
414
|
-
const heightEquirect =
|
|
686
|
+
const widthEquirect = 2 ** Math.ceil(Math.log2(2 * w * 3 ** 0.5));
|
|
687
|
+
const heightEquirect = 2 ** Math.ceil(Math.log2(w * 3 ** 0.5));
|
|
415
688
|
width = widthEquirect;
|
|
416
689
|
height = heightEquirect;
|
|
417
690
|
}
|
|
@@ -523,7 +796,10 @@ const setupBlueNoise = (fragmentShader)=>{
|
|
|
523
796
|
const useBlueNoise = (material)=>{
|
|
524
797
|
const { fragmentShader, uniforms } = setupBlueNoise(material.fragmentShader);
|
|
525
798
|
material.fragmentShader = fragmentShader;
|
|
526
|
-
material.uniforms =
|
|
799
|
+
material.uniforms = {
|
|
800
|
+
...material.uniforms,
|
|
801
|
+
...uniforms
|
|
802
|
+
};
|
|
527
803
|
material.needsUpdate = true;
|
|
528
804
|
};
|
|
529
805
|
|
|
@@ -600,7 +876,10 @@ class GBufferMaterial extends MeshPhysicalMaterial {
|
|
|
600
876
|
|
|
601
877
|
gl_FragColor = gBuffer;`);
|
|
602
878
|
const { uniforms, fragmentShader } = setupBlueNoise(shader.fragmentShader);
|
|
603
|
-
shader.uniforms =
|
|
879
|
+
shader.uniforms = {
|
|
880
|
+
...shader.uniforms,
|
|
881
|
+
...uniforms
|
|
882
|
+
};
|
|
604
883
|
shader.fragmentShader = fragmentShader;
|
|
605
884
|
}
|
|
606
885
|
}
|
|
@@ -1266,11 +1545,14 @@ const velocity_uniforms = {
|
|
|
1266
1545
|
class VelocityDepthNormalMaterial extends ShaderMaterial {
|
|
1267
1546
|
constructor(camera){
|
|
1268
1547
|
super({
|
|
1269
|
-
uniforms:
|
|
1270
|
-
|
|
1271
|
-
|
|
1548
|
+
uniforms: {
|
|
1549
|
+
...UniformsUtils.clone(velocity_uniforms),
|
|
1550
|
+
...{
|
|
1551
|
+
cameraMatrixWorld: {
|
|
1552
|
+
value: camera.matrixWorld
|
|
1553
|
+
}
|
|
1272
1554
|
}
|
|
1273
|
-
}
|
|
1555
|
+
},
|
|
1274
1556
|
vertexShader: /* glsl */ `
|
|
1275
1557
|
#include <common>
|
|
1276
1558
|
#include <uv_pars_vertex>
|
|
@@ -1734,7 +2016,10 @@ class PoissonDenoisePass extends Pass {
|
|
|
1734
2016
|
super("PoissonBlurPass");
|
|
1735
2017
|
this.iterations = defaultPoissonBlurOptions.iterations;
|
|
1736
2018
|
this.index = 0;
|
|
1737
|
-
options =
|
|
2019
|
+
options = {
|
|
2020
|
+
...defaultPoissonBlurOptions,
|
|
2021
|
+
...options
|
|
2022
|
+
};
|
|
1738
2023
|
this.textures = textures;
|
|
1739
2024
|
let isTextureSpecular = [
|
|
1740
2025
|
false,
|
|
@@ -1878,13 +2163,16 @@ class Denoiser {
|
|
|
1878
2163
|
}
|
|
1879
2164
|
constructor(scene, camera, texture, options = defaultDenosierOptions){
|
|
1880
2165
|
var _this_denoisePass;
|
|
1881
|
-
options =
|
|
2166
|
+
options = {
|
|
2167
|
+
...defaultDenosierOptions,
|
|
2168
|
+
...options
|
|
2169
|
+
};
|
|
1882
2170
|
this.options = options;
|
|
1883
2171
|
var _options_velocityDepthNormalPass;
|
|
1884
2172
|
this.velocityDepthNormalPass = (_options_velocityDepthNormalPass = options.velocityDepthNormalPass) != null ? _options_velocityDepthNormalPass : new VelocityDepthNormalPass(scene, camera);
|
|
1885
2173
|
this.isOwnVelocityDepthNormalPass = !options.velocityDepthNormalPass;
|
|
1886
2174
|
const textureCount = options.inputType === "diffuseSpecular" ? 2 : 1;
|
|
1887
|
-
this.temporalReprojectPass = new TemporalReprojectPass(scene, camera, this.velocityDepthNormalPass, texture, textureCount,
|
|
2175
|
+
this.temporalReprojectPass = new TemporalReprojectPass(scene, camera, this.velocityDepthNormalPass, texture, textureCount, {
|
|
1888
2176
|
fullAccumulate: true,
|
|
1889
2177
|
logTransform: true,
|
|
1890
2178
|
copyTextures: !options.denoise,
|
|
@@ -1897,8 +2185,9 @@ class Denoiser {
|
|
|
1897
2185
|
true
|
|
1898
2186
|
],
|
|
1899
2187
|
neighborhoodClampRadius: 2,
|
|
1900
|
-
neighborhoodClampIntensity: 0.5
|
|
1901
|
-
|
|
2188
|
+
neighborhoodClampIntensity: 0.5,
|
|
2189
|
+
...options
|
|
2190
|
+
});
|
|
1902
2191
|
const textures = this.temporalReprojectPass.renderTarget.texture.slice(0, textureCount);
|
|
1903
2192
|
if (this.options.denoiseMode === "full" || this.options.denoiseMode === "denoised") {
|
|
1904
2193
|
this.denoisePass = new PoissonDenoisePass(camera, textures, options);
|
|
@@ -2276,7 +2565,10 @@ class SSGIEffect extends Effect {
|
|
|
2276
2565
|
}
|
|
2277
2566
|
constructor(composer, scene, camera, options){
|
|
2278
2567
|
var _scene_fog;
|
|
2279
|
-
options =
|
|
2568
|
+
options = {
|
|
2569
|
+
...defaultSSGIOptions,
|
|
2570
|
+
...options
|
|
2571
|
+
};
|
|
2280
2572
|
let fragmentShader = ssgi_compose.replace("#include <fog_pars_fragment>", ShaderChunk.fog_pars_fragment.replace("varying", ""));
|
|
2281
2573
|
// delete the line starting with gl_FragColor using a regex
|
|
2282
2574
|
fragmentShader = fragmentShader.replace("#include <fog_fragment>", ShaderChunk.fog_fragment.replace(/.*gl_FragColor.*/g, ""));
|
|
@@ -2374,10 +2666,11 @@ class SSGIEffect extends Effect {
|
|
|
2374
2666
|
}
|
|
2375
2667
|
}
|
|
2376
2668
|
this.ssgiPass = new SSGIPass(this, options);
|
|
2377
|
-
this.denoiser = new Denoiser(scene, camera, this.ssgiPass.texture,
|
|
2669
|
+
this.denoiser = new Denoiser(scene, camera, this.ssgiPass.texture, {
|
|
2378
2670
|
gBufferPass: this.ssgiPass.gBufferPass,
|
|
2379
|
-
velocityDepthNormalPass: options.velocityDepthNormalPass
|
|
2380
|
-
|
|
2671
|
+
velocityDepthNormalPass: options.velocityDepthNormalPass,
|
|
2672
|
+
...options
|
|
2673
|
+
});
|
|
2381
2674
|
this.lastSize = {
|
|
2382
2675
|
width: options.width,
|
|
2383
2676
|
height: options.height,
|
|
@@ -2461,7 +2754,10 @@ class MotionBlurEffect extends Effect {
|
|
|
2461
2754
|
}
|
|
2462
2755
|
}
|
|
2463
2756
|
constructor(velocityPass, options = defaultOptions){
|
|
2464
|
-
options =
|
|
2757
|
+
options = {
|
|
2758
|
+
...defaultOptions,
|
|
2759
|
+
...options
|
|
2760
|
+
};
|
|
2465
2761
|
const { fragmentShader, uniforms } = setupBlueNoise(motion_blur);
|
|
2466
2762
|
// convert the uniforms from type { uniform: value,... } to type ["uniform", value,...]
|
|
2467
2763
|
const formattedUniforms = [];
|
|
@@ -2522,7 +2818,7 @@ class MotionBlurEffect extends Effect {
|
|
|
2522
2818
|
|
|
2523
2819
|
var ao_compose = "#define GLSLIFY 1\nuniform sampler2D inputTexture;uniform highp sampler2D depthTexture;uniform float power;uniform vec3 color;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float unpackedDepth=textureLod(depthTexture,uv,0.).r;float ao=unpackedDepth>0.9999 ? 1.0 : textureLod(inputTexture,uv,0.0).a;ao=pow(ao,power);vec3 aoColor=mix(color,vec3(1.),ao);aoColor*=inputColor.rgb;outputColor=vec4(aoColor,inputColor.a);}"; // eslint-disable-line
|
|
2524
2820
|
|
|
2525
|
-
const defaultAOOptions =
|
|
2821
|
+
const defaultAOOptions = {
|
|
2526
2822
|
resolutionScale: 1,
|
|
2527
2823
|
spp: 8,
|
|
2528
2824
|
distance: 2,
|
|
@@ -2533,8 +2829,9 @@ const defaultAOOptions = _extends({
|
|
|
2533
2829
|
color: new Color("black"),
|
|
2534
2830
|
useNormalPass: false,
|
|
2535
2831
|
velocityDepthNormalPass: null,
|
|
2536
|
-
normalTexture: null
|
|
2537
|
-
|
|
2832
|
+
normalTexture: null,
|
|
2833
|
+
...PoissonDenoisePass.DefaultOptions
|
|
2834
|
+
};
|
|
2538
2835
|
class AOEffect extends Effect {
|
|
2539
2836
|
makeOptionsReactive(options) {
|
|
2540
2837
|
for (const key of Object.keys(options)){
|
|
@@ -2557,431 +2854,158 @@ class AOEffect extends Effect {
|
|
|
2557
2854
|
this.setSize(this.lastSize.width, this.lastSize.height);
|
|
2558
2855
|
break;
|
|
2559
2856
|
case "power":
|
|
2560
|
-
this.uniforms.get("power").value = value;
|
|
2561
|
-
break;
|
|
2562
|
-
case "color":
|
|
2563
|
-
this.uniforms.get("color").value.copy(new Color(value));
|
|
2564
|
-
break;
|
|
2565
|
-
// denoiser
|
|
2566
|
-
case "iterations":
|
|
2567
|
-
case "radius":
|
|
2568
|
-
case "rings":
|
|
2569
|
-
case "samples":
|
|
2570
|
-
this.PoissonDenoisePass[key] = value;
|
|
2571
|
-
break;
|
|
2572
|
-
case "lumaPhi":
|
|
2573
|
-
case "depthPhi":
|
|
2574
|
-
case "normalPhi":
|
|
2575
|
-
this.PoissonDenoisePass.fullscreenMaterial.uniforms[key].value = Math.max(value, 0.0001);
|
|
2576
|
-
break;
|
|
2577
|
-
default:
|
|
2578
|
-
if (key in this.aoPass.fullscreenMaterial.uniforms) {
|
|
2579
|
-
this.aoPass.fullscreenMaterial.uniforms[key].value = value;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
},
|
|
2583
|
-
configurable: true
|
|
2584
|
-
});
|
|
2585
|
-
// apply all uniforms and defines
|
|
2586
|
-
this[key] = options[key];
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
setSize(width, height) {
|
|
2590
|
-
var _this_normalPass;
|
|
2591
|
-
if (width === undefined || height === undefined) return;
|
|
2592
|
-
if (width === this.lastSize.width && height === this.lastSize.height && this.resolutionScale === this.lastSize.resolutionScale) {
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
|
-
(_this_normalPass = this.normalPass) == null ? void 0 : _this_normalPass.setSize(width, height);
|
|
2596
|
-
this.aoPass.setSize(width * this.resolutionScale, height * this.resolutionScale);
|
|
2597
|
-
this.PoissonDenoisePass.setSize(width, height);
|
|
2598
|
-
this.lastSize = {
|
|
2599
|
-
width,
|
|
2600
|
-
height,
|
|
2601
|
-
resolutionScale: this.resolutionScale
|
|
2602
|
-
};
|
|
2603
|
-
}
|
|
2604
|
-
get texture() {
|
|
2605
|
-
if (this.iterations > 0) {
|
|
2606
|
-
return this.PoissonDenoisePass.texture;
|
|
2607
|
-
}
|
|
2608
|
-
return this.aoPass.texture;
|
|
2609
|
-
}
|
|
2610
|
-
update(renderer) {
|
|
2611
|
-
var _this_normalPass;
|
|
2612
|
-
// check if TRAA is being used so we can animate the noise
|
|
2613
|
-
const hasTRAA = this.composer.passes.some((pass)=>{
|
|
2614
|
-
var _pass_effects;
|
|
2615
|
-
return pass.enabled && !pass.skipRendering && ((_pass_effects = pass.effects) == null ? void 0 : _pass_effects.some((effect)=>effect instanceof TRAAEffect));
|
|
2616
|
-
});
|
|
2617
|
-
// set animated noise depending on TRAA
|
|
2618
|
-
if (hasTRAA && !("animatedNoise" in this.aoPass.fullscreenMaterial.defines)) {
|
|
2619
|
-
this.aoPass.fullscreenMaterial.defines.animatedNoise = "";
|
|
2620
|
-
this.aoPass.fullscreenMaterial.needsUpdate = true;
|
|
2621
|
-
} else if (!hasTRAA && "animatedNoise" in this.aoPass.fullscreenMaterial.defines) {
|
|
2622
|
-
delete this.aoPass.fullscreenMaterial.defines.animatedNoise;
|
|
2623
|
-
this.aoPass.fullscreenMaterial.needsUpdate = true;
|
|
2624
|
-
}
|
|
2625
|
-
this.uniforms.get("inputTexture").value = this.texture;
|
|
2626
|
-
(_this_normalPass = this.normalPass) == null ? void 0 : _this_normalPass.render(renderer);
|
|
2627
|
-
this.aoPass.render(renderer);
|
|
2628
|
-
this.PoissonDenoisePass.render(renderer);
|
|
2629
|
-
}
|
|
2630
|
-
constructor(composer, camera, scene, aoPass, options = defaultAOOptions){
|
|
2631
|
-
super("AOEffect", ao_compose, {
|
|
2632
|
-
type: "FinalAOMaterial",
|
|
2633
|
-
uniforms: new Map([
|
|
2634
|
-
[
|
|
2635
|
-
"inputTexture",
|
|
2636
|
-
new Uniform(null)
|
|
2637
|
-
],
|
|
2638
|
-
[
|
|
2639
|
-
"depthTexture",
|
|
2640
|
-
new Uniform(null)
|
|
2641
|
-
],
|
|
2642
|
-
[
|
|
2643
|
-
"power",
|
|
2644
|
-
new Uniform(0)
|
|
2645
|
-
],
|
|
2646
|
-
[
|
|
2647
|
-
"color",
|
|
2648
|
-
new Uniform(new Color("black"))
|
|
2649
|
-
]
|
|
2650
|
-
])
|
|
2651
|
-
});
|
|
2652
|
-
this.lastSize = {
|
|
2653
|
-
width: 0,
|
|
2654
|
-
height: 0,
|
|
2655
|
-
resolutionScale: 0
|
|
2656
|
-
};
|
|
2657
|
-
this.composer = composer;
|
|
2658
|
-
this.aoPass = aoPass;
|
|
2659
|
-
options = _extends({}, defaultAOOptions, options);
|
|
2660
|
-
// set up depth texture
|
|
2661
|
-
if (!composer.depthTexture) composer.createDepthTexture();
|
|
2662
|
-
this.aoPass.fullscreenMaterial.uniforms.depthTexture.value = composer.depthTexture;
|
|
2663
|
-
this.uniforms.get("depthTexture").value = composer.depthTexture;
|
|
2664
|
-
// set up optional normal texture
|
|
2665
|
-
if (options.useNormalPass || options.normalTexture) {
|
|
2666
|
-
if (options.useNormalPass) this.normalPass = new NormalPass(scene, camera);
|
|
2667
|
-
var _options_normalTexture;
|
|
2668
|
-
const normalTexture = (_options_normalTexture = options.normalTexture) != null ? _options_normalTexture : this.normalPass.texture;
|
|
2669
|
-
this.aoPass.fullscreenMaterial.uniforms.normalTexture.value = normalTexture;
|
|
2670
|
-
this.aoPass.fullscreenMaterial.defines.useNormalTexture = "";
|
|
2671
|
-
}
|
|
2672
|
-
this.PoissonDenoisePass = new PoissonDenoisePass(camera, this.aoPass.texture, composer.depthTexture, {
|
|
2673
|
-
normalInRgb: true
|
|
2674
|
-
});
|
|
2675
|
-
this.makeOptionsReactive(options);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
AOEffect.DefaultOptions = defaultAOOptions;
|
|
2679
|
-
|
|
2680
|
-
class EffectComposerPlugin extends Plugin {
|
|
2681
|
-
static Instance(viewer) {
|
|
2682
|
-
return viewer.getPlugin(EffectComposerPlugin, true);
|
|
2683
|
-
}
|
|
2684
|
-
get multisampling() {
|
|
2685
|
-
return this._composer.multisampling;
|
|
2686
|
-
}
|
|
2687
|
-
set multisampling(v) {
|
|
2688
|
-
this._composer.multisampling = v;
|
|
2689
|
-
}
|
|
2690
|
-
getPass(constructor) {
|
|
2691
|
-
return this._composer.passes.find((v)=>v.constructor === constructor);
|
|
2692
|
-
}
|
|
2693
|
-
addPass(pass) {
|
|
2694
|
-
this._composer.addPass(pass, this._composer.passes.length - 1);
|
|
2695
|
-
this._checkOutputPass();
|
|
2696
|
-
return pass;
|
|
2697
|
-
}
|
|
2698
|
-
removePass(pass) {
|
|
2699
|
-
this._composer.removePass(pass);
|
|
2700
|
-
this._checkOutputPass();
|
|
2701
|
-
}
|
|
2702
|
-
activePass(pass, v) {
|
|
2703
|
-
pass.enabled = v;
|
|
2704
|
-
this._checkOutputPass();
|
|
2705
|
-
return pass;
|
|
2706
|
-
}
|
|
2707
|
-
getVelocityDepthNormalPass(autoAdd = false) {
|
|
2708
|
-
let vdnPass = this.getPass(VelocityDepthNormalPass);
|
|
2709
|
-
if (vdnPass === undefined && autoAdd) {
|
|
2710
|
-
vdnPass = this.addPass(new VelocityDepthNormalPass(this.viewer.scene, this.viewer.camera));
|
|
2711
|
-
}
|
|
2712
|
-
return vdnPass;
|
|
2713
|
-
}
|
|
2714
|
-
_checkOutputPass() {
|
|
2715
|
-
const vdnPass = this.getVelocityDepthNormalPass();
|
|
2716
|
-
const count = this._composer.passes.filter((v)=>v.enabled && v !== vdnPass && v !== this._outputPass).length;
|
|
2717
|
-
this._outputPass.enabled = this._composer.multisampling > 0 && count === 1;
|
|
2718
|
-
this._setRenderToScreen();
|
|
2719
|
-
}
|
|
2720
|
-
_setRenderToScreen() {
|
|
2721
|
-
const vdnPass = this.getVelocityDepthNormalPass();
|
|
2722
|
-
const passes = this._composer.passes;
|
|
2723
|
-
for(let k = 0, i = passes.length; i--;){
|
|
2724
|
-
let pass = passes[i];
|
|
2725
|
-
if (pass.enabled && pass !== vdnPass && k === 0) {
|
|
2726
|
-
k = i;
|
|
2727
|
-
}
|
|
2728
|
-
pass.renderToScreen = k === i;
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
constructor(props){
|
|
2732
|
-
super();
|
|
2733
|
-
this.install = ()=>{
|
|
2734
|
-
const { renderer, scene, camera } = this.viewer;
|
|
2735
|
-
this._renderPass = new RenderPass(scene, camera);
|
|
2736
|
-
this._outputPass = new EffectPass(camera);
|
|
2737
|
-
this._composer = new EffectComposer(renderer, Object.assign({
|
|
2738
|
-
frameBufferType: HalfFloatType
|
|
2739
|
-
}, props));
|
|
2740
|
-
this._composer.addPass(this._renderPass);
|
|
2741
|
-
this._composer.addPass(this._outputPass);
|
|
2742
|
-
this.viewer._onResize = (width, height)=>this._composer.setSize(width, height);
|
|
2743
|
-
this.viewer._onRender = (dt)=>this._composer.render(dt);
|
|
2744
|
-
};
|
|
2745
|
-
this.uninstall = ()=>{
|
|
2746
|
-
this._composer.dispose();
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
/******************************************************************************
|
|
2752
|
-
Copyright (c) Microsoft Corporation.
|
|
2753
|
-
|
|
2754
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2755
|
-
purpose with or without fee is hereby granted.
|
|
2756
|
-
|
|
2757
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2758
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2759
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2760
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2761
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2762
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2763
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2764
|
-
***************************************************************************** */
|
|
2765
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
function __decorate(decorators, target, key, desc) {
|
|
2769
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2770
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2771
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2772
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2773
|
-
}
|
|
2774
|
-
|
|
2775
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2776
|
-
var e = new Error(message);
|
|
2777
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2778
|
-
};
|
|
2779
|
-
|
|
2780
|
-
class PassPlugin extends Plugin {
|
|
2781
|
-
get enable() {
|
|
2782
|
-
return this.pass.enabled;
|
|
2783
|
-
}
|
|
2784
|
-
set enable(v) {
|
|
2785
|
-
this.setEnable(v);
|
|
2786
|
-
}
|
|
2787
|
-
get composer() {
|
|
2788
|
-
return EffectComposerPlugin.Instance(this.viewer);
|
|
2789
|
-
}
|
|
2790
|
-
setEnable(v) {
|
|
2791
|
-
this.composer.activePass(this.pass, v);
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
__decorate([
|
|
2795
|
-
property
|
|
2796
|
-
], PassPlugin.prototype, "enable", null);
|
|
2797
|
-
|
|
2798
|
-
class ToneMappingPlugin extends PassPlugin {
|
|
2799
|
-
get mode() {
|
|
2800
|
-
return this.effect.mode;
|
|
2801
|
-
}
|
|
2802
|
-
set mode(v) {
|
|
2803
|
-
this.effect.mode = v;
|
|
2804
|
-
}
|
|
2805
|
-
constructor(props){
|
|
2806
|
-
super();
|
|
2807
|
-
this.install = ()=>{
|
|
2808
|
-
this.effect = new ToneMappingEffect(props);
|
|
2809
|
-
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, this.effect));
|
|
2810
|
-
};
|
|
2811
|
-
this.uninstall = ()=>{
|
|
2812
|
-
this.composer.removePass(this.pass);
|
|
2813
|
-
};
|
|
2857
|
+
this.uniforms.get("power").value = value;
|
|
2858
|
+
break;
|
|
2859
|
+
case "color":
|
|
2860
|
+
this.uniforms.get("color").value.copy(new Color(value));
|
|
2861
|
+
break;
|
|
2862
|
+
// denoiser
|
|
2863
|
+
case "iterations":
|
|
2864
|
+
case "radius":
|
|
2865
|
+
case "rings":
|
|
2866
|
+
case "samples":
|
|
2867
|
+
this.PoissonDenoisePass[key] = value;
|
|
2868
|
+
break;
|
|
2869
|
+
case "lumaPhi":
|
|
2870
|
+
case "depthPhi":
|
|
2871
|
+
case "normalPhi":
|
|
2872
|
+
this.PoissonDenoisePass.fullscreenMaterial.uniforms[key].value = Math.max(value, 0.0001);
|
|
2873
|
+
break;
|
|
2874
|
+
default:
|
|
2875
|
+
if (key in this.aoPass.fullscreenMaterial.uniforms) {
|
|
2876
|
+
this.aoPass.fullscreenMaterial.uniforms[key].value = value;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
},
|
|
2880
|
+
configurable: true
|
|
2881
|
+
});
|
|
2882
|
+
// apply all uniforms and defines
|
|
2883
|
+
this[key] = options[key];
|
|
2884
|
+
}
|
|
2814
2885
|
}
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
};
|
|
2829
|
-
this.uninstall = ()=>{
|
|
2830
|
-
this.composer.removePass(this.pass);
|
|
2886
|
+
setSize(width, height) {
|
|
2887
|
+
var _this_normalPass;
|
|
2888
|
+
if (width === undefined || height === undefined) return;
|
|
2889
|
+
if (width === this.lastSize.width && height === this.lastSize.height && this.resolutionScale === this.lastSize.resolutionScale) {
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
(_this_normalPass = this.normalPass) == null ? void 0 : _this_normalPass.setSize(width, height);
|
|
2893
|
+
this.aoPass.setSize(width * this.resolutionScale, height * this.resolutionScale);
|
|
2894
|
+
this.PoissonDenoisePass.setSize(width, height);
|
|
2895
|
+
this.lastSize = {
|
|
2896
|
+
width,
|
|
2897
|
+
height,
|
|
2898
|
+
resolutionScale: this.resolutionScale
|
|
2831
2899
|
};
|
|
2832
2900
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
return this.
|
|
2838
|
-
}
|
|
2839
|
-
set intensity(v) {
|
|
2840
|
-
this.effect.intensity = v;
|
|
2841
|
-
}
|
|
2842
|
-
get luminanceThreshold() {
|
|
2843
|
-
return this.effect.luminanceMaterial.threshold;
|
|
2844
|
-
}
|
|
2845
|
-
set luminanceThreshold(v) {
|
|
2846
|
-
this.effect.luminanceMaterial.threshold = v;
|
|
2847
|
-
}
|
|
2848
|
-
get luminanceSmoothing() {
|
|
2849
|
-
return this.effect.luminanceMaterial.smoothing;
|
|
2901
|
+
get texture() {
|
|
2902
|
+
if (this.iterations > 0) {
|
|
2903
|
+
return this.PoissonDenoisePass.texture;
|
|
2904
|
+
}
|
|
2905
|
+
return this.aoPass.texture;
|
|
2850
2906
|
}
|
|
2851
|
-
|
|
2852
|
-
|
|
2907
|
+
update(renderer) {
|
|
2908
|
+
var _this_normalPass;
|
|
2909
|
+
// check if TRAA is being used so we can animate the noise
|
|
2910
|
+
const hasTRAA = this.composer.passes.some((pass)=>{
|
|
2911
|
+
var _pass_effects;
|
|
2912
|
+
return pass.enabled && !pass.skipRendering && ((_pass_effects = pass.effects) == null ? void 0 : _pass_effects.some((effect)=>effect instanceof TRAAEffect));
|
|
2913
|
+
});
|
|
2914
|
+
// set animated noise depending on TRAA
|
|
2915
|
+
if (hasTRAA && !("animatedNoise" in this.aoPass.fullscreenMaterial.defines)) {
|
|
2916
|
+
this.aoPass.fullscreenMaterial.defines.animatedNoise = "";
|
|
2917
|
+
this.aoPass.fullscreenMaterial.needsUpdate = true;
|
|
2918
|
+
} else if (!hasTRAA && "animatedNoise" in this.aoPass.fullscreenMaterial.defines) {
|
|
2919
|
+
delete this.aoPass.fullscreenMaterial.defines.animatedNoise;
|
|
2920
|
+
this.aoPass.fullscreenMaterial.needsUpdate = true;
|
|
2921
|
+
}
|
|
2922
|
+
this.uniforms.get("inputTexture").value = this.texture;
|
|
2923
|
+
(_this_normalPass = this.normalPass) == null ? void 0 : _this_normalPass.render(renderer);
|
|
2924
|
+
this.aoPass.render(renderer);
|
|
2925
|
+
this.PoissonDenoisePass.render(renderer);
|
|
2853
2926
|
}
|
|
2854
|
-
constructor(
|
|
2855
|
-
super(
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2927
|
+
constructor(composer, camera, scene, aoPass, options = defaultAOOptions){
|
|
2928
|
+
super("AOEffect", ao_compose, {
|
|
2929
|
+
type: "FinalAOMaterial",
|
|
2930
|
+
uniforms: new Map([
|
|
2931
|
+
[
|
|
2932
|
+
"inputTexture",
|
|
2933
|
+
new Uniform(null)
|
|
2934
|
+
],
|
|
2935
|
+
[
|
|
2936
|
+
"depthTexture",
|
|
2937
|
+
new Uniform(null)
|
|
2938
|
+
],
|
|
2939
|
+
[
|
|
2940
|
+
"power",
|
|
2941
|
+
new Uniform(0)
|
|
2942
|
+
],
|
|
2943
|
+
[
|
|
2944
|
+
"color",
|
|
2945
|
+
new Uniform(new Color("black"))
|
|
2946
|
+
]
|
|
2947
|
+
])
|
|
2948
|
+
});
|
|
2949
|
+
this.lastSize = {
|
|
2950
|
+
width: 0,
|
|
2951
|
+
height: 0,
|
|
2952
|
+
resolutionScale: 0
|
|
2861
2953
|
};
|
|
2862
|
-
this.
|
|
2863
|
-
|
|
2954
|
+
this.composer = composer;
|
|
2955
|
+
this.aoPass = aoPass;
|
|
2956
|
+
options = {
|
|
2957
|
+
...defaultAOOptions,
|
|
2958
|
+
...options
|
|
2864
2959
|
};
|
|
2960
|
+
// set up depth texture
|
|
2961
|
+
if (!composer.depthTexture) composer.createDepthTexture();
|
|
2962
|
+
this.aoPass.fullscreenMaterial.uniforms.depthTexture.value = composer.depthTexture;
|
|
2963
|
+
this.uniforms.get("depthTexture").value = composer.depthTexture;
|
|
2964
|
+
// set up optional normal texture
|
|
2965
|
+
if (options.useNormalPass || options.normalTexture) {
|
|
2966
|
+
if (options.useNormalPass) this.normalPass = new NormalPass(scene, camera);
|
|
2967
|
+
var _options_normalTexture;
|
|
2968
|
+
const normalTexture = (_options_normalTexture = options.normalTexture) != null ? _options_normalTexture : this.normalPass.texture;
|
|
2969
|
+
this.aoPass.fullscreenMaterial.uniforms.normalTexture.value = normalTexture;
|
|
2970
|
+
this.aoPass.fullscreenMaterial.defines.useNormalTexture = "";
|
|
2971
|
+
}
|
|
2972
|
+
this.PoissonDenoisePass = new PoissonDenoisePass(camera, this.aoPass.texture, composer.depthTexture, {
|
|
2973
|
+
normalInRgb: true
|
|
2974
|
+
});
|
|
2975
|
+
this.makeOptionsReactive(options);
|
|
2865
2976
|
}
|
|
2866
2977
|
}
|
|
2867
|
-
|
|
2868
|
-
property({
|
|
2869
|
-
min: 0,
|
|
2870
|
-
max: 2,
|
|
2871
|
-
step: 0.01
|
|
2872
|
-
})
|
|
2873
|
-
], BloomPlugin.prototype, "intensity", null);
|
|
2874
|
-
__decorate([
|
|
2875
|
-
property({
|
|
2876
|
-
min: 0,
|
|
2877
|
-
max: 10,
|
|
2878
|
-
step: 0.01
|
|
2879
|
-
})
|
|
2880
|
-
], BloomPlugin.prototype, "luminanceThreshold", null);
|
|
2881
|
-
__decorate([
|
|
2882
|
-
property({
|
|
2883
|
-
min: 0,
|
|
2884
|
-
max: 10,
|
|
2885
|
-
step: 0.01
|
|
2886
|
-
})
|
|
2887
|
-
], BloomPlugin.prototype, "luminanceSmoothing", null);
|
|
2978
|
+
AOEffect.DefaultOptions = defaultAOOptions;
|
|
2888
2979
|
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
};
|
|
2895
|
-
this.uninstall = ()=>{
|
|
2896
|
-
this.composer.removePass(this.pass);
|
|
2897
|
-
};
|
|
2980
|
+
function getVelocityDepthNormalPass(viewer, autoAdd = true) {
|
|
2981
|
+
const composer = EffectComposerPlugin.Instance(viewer);
|
|
2982
|
+
let vdnPass = composer.getPass(VelocityDepthNormalPass);
|
|
2983
|
+
if (vdnPass === undefined && autoAdd) {
|
|
2984
|
+
vdnPass = composer.addPass(new VelocityDepthNormalPass(viewer.scene, viewer.camera));
|
|
2898
2985
|
}
|
|
2986
|
+
return vdnPass;
|
|
2899
2987
|
}
|
|
2900
2988
|
|
|
2901
|
-
class
|
|
2902
|
-
get preset() {
|
|
2903
|
-
return this._preset;
|
|
2904
|
-
}
|
|
2905
|
-
set preset(v) {
|
|
2906
|
-
if (this._preset !== v) {
|
|
2907
|
-
this._preset = v;
|
|
2908
|
-
this.effect.applyPreset(v);
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
get edgeDetectionMode() {
|
|
2912
|
-
return this.effect.edgeDetectionMaterial.edgeDetectionMode;
|
|
2913
|
-
}
|
|
2914
|
-
set edgeDetectionMode(v) {
|
|
2915
|
-
this.effect.edgeDetectionMaterial.edgeDetectionMode = v;
|
|
2916
|
-
}
|
|
2917
|
-
get predicationMode() {
|
|
2918
|
-
return this.effect.edgeDetectionMaterial.predicationMode;
|
|
2919
|
-
}
|
|
2920
|
-
set predicationMode(v) {
|
|
2921
|
-
this.effect.edgeDetectionMaterial.predicationMode = v;
|
|
2922
|
-
}
|
|
2989
|
+
class TRAAPlugin extends PassPlugin {
|
|
2923
2990
|
constructor(props = {}){
|
|
2924
2991
|
super();
|
|
2925
|
-
this._preset = SMAAPreset.MEDIUM;
|
|
2926
2992
|
this.install = ()=>{
|
|
2927
|
-
|
|
2928
|
-
this.
|
|
2993
|
+
const { scene, camera } = this.viewer;
|
|
2994
|
+
this._effect = new TRAAEffect(scene, camera, getVelocityDepthNormalPass(this.viewer), props);
|
|
2995
|
+
this.pass = this.composer.addPass(new EffectPass(camera, this._effect));
|
|
2929
2996
|
};
|
|
2930
2997
|
this.uninstall = ()=>{
|
|
2931
2998
|
this.composer.removePass(this.pass);
|
|
2932
2999
|
};
|
|
2933
3000
|
}
|
|
2934
3001
|
}
|
|
2935
|
-
__decorate([
|
|
2936
|
-
property({
|
|
2937
|
-
value: SMAAPreset
|
|
2938
|
-
})
|
|
2939
|
-
], SMAAPlugin.prototype, "preset", null);
|
|
2940
|
-
__decorate([
|
|
2941
|
-
property({
|
|
2942
|
-
value: EdgeDetectionMode
|
|
2943
|
-
})
|
|
2944
|
-
], SMAAPlugin.prototype, "edgeDetectionMode", null);
|
|
2945
|
-
__decorate([
|
|
2946
|
-
property({
|
|
2947
|
-
value: PredicationMode
|
|
2948
|
-
})
|
|
2949
|
-
], SMAAPlugin.prototype, "predicationMode", null);
|
|
2950
3002
|
|
|
2951
|
-
class
|
|
2952
|
-
get enable() {
|
|
2953
|
-
return this.composer.multisampling > 0;
|
|
2954
|
-
}
|
|
2955
|
-
set enable(v) {
|
|
2956
|
-
this.composer.multisampling = v ? this._maxSamples : 0;
|
|
2957
|
-
}
|
|
2958
|
-
get composer() {
|
|
2959
|
-
return EffectComposerPlugin.Instance(this.viewer);
|
|
2960
|
-
}
|
|
3003
|
+
class MotionBlurPlugin extends PassPlugin {
|
|
2961
3004
|
constructor(){
|
|
2962
|
-
super();
|
|
2963
|
-
this._maxSamples = 4;
|
|
2964
|
-
this.install = ()=>{
|
|
2965
|
-
const { renderer } = this.viewer;
|
|
2966
|
-
this._maxSamples = Math.min(4, renderer.capabilities.maxSamples);
|
|
2967
|
-
this.composer.multisampling = this._maxSamples;
|
|
2968
|
-
};
|
|
2969
|
-
this.uninstall = ()=>{
|
|
2970
|
-
this.composer.multisampling = 0;
|
|
2971
|
-
};
|
|
2972
|
-
}
|
|
2973
|
-
}
|
|
2974
|
-
__decorate([
|
|
2975
|
-
property
|
|
2976
|
-
], MSAAPlugin.prototype, "enable", null);
|
|
2977
|
-
|
|
2978
|
-
class TRAAPlugin extends PassPlugin {
|
|
2979
|
-
constructor(props = {}){
|
|
2980
3005
|
super();
|
|
2981
3006
|
this.install = ()=>{
|
|
2982
|
-
const
|
|
2983
|
-
this.
|
|
2984
|
-
this.pass = this.composer.addPass(new EffectPass(camera, this._effect));
|
|
3007
|
+
const effect = new MotionBlurEffect(getVelocityDepthNormalPass(this.viewer));
|
|
3008
|
+
this.pass = this.composer.addPass(new EffectPass(this.viewer.camera, effect));
|
|
2985
3009
|
};
|
|
2986
3010
|
this.uninstall = ()=>{
|
|
2987
3011
|
this.composer.removePass(this.pass);
|