@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.18.2 → 3.19.1
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/LICENSE +73 -73
- package/README.md +3 -3
- package/dist/RenderingEngine.d.ts +5 -5
- package/dist/RenderingEngine.d.ts.map +1 -1
- package/dist/RenderingEngine.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/injectors/TextureUnifierInjector.js +57 -57
- package/dist/interfaces/IRenderingEngine.d.ts +2 -2
- package/dist/interfaces/IRenderingEngine.d.ts.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.d.ts +1 -1
- package/dist/loaders/EnvironmentMapLoader.d.ts.map +1 -1
- package/dist/loaders/EnvironmentMapLoader.js.map +1 -1
- package/dist/loaders/GeometryLoader.d.ts +2 -2
- package/dist/loaders/GeometryLoader.d.ts.map +1 -1
- package/dist/loaders/GeometryLoader.js +43 -43
- package/dist/loaders/GeometryLoader.js.map +1 -1
- package/dist/loaders/HTMLElementAnchorLoader.d.ts +2 -2
- package/dist/loaders/HTMLElementAnchorLoader.d.ts.map +1 -1
- package/dist/loaders/HTMLElementAnchorLoader.js.map +1 -1
- package/dist/loaders/LightLoader.d.ts +2 -2
- package/dist/loaders/LightLoader.d.ts.map +1 -1
- package/dist/loaders/LightLoader.js.map +1 -1
- package/dist/loaders/MaterialLoader.d.ts +7 -7
- package/dist/loaders/MaterialLoader.d.ts.map +1 -1
- package/dist/loaders/MaterialLoader.js +42 -42
- package/dist/loaders/MaterialLoader.js.map +1 -1
- package/dist/managers/ARManager.d.ts +1 -1
- package/dist/managers/ARManager.d.ts.map +1 -1
- package/dist/managers/ARManager.js.map +1 -1
- package/dist/managers/CameraManager.d.ts +1 -1
- package/dist/managers/CameraManager.d.ts.map +1 -1
- package/dist/managers/CameraManager.js.map +1 -1
- package/dist/managers/EnvironmentGeometryManager.d.ts +2 -2
- package/dist/managers/EnvironmentGeometryManager.d.ts.map +1 -1
- package/dist/managers/EnvironmentGeometryManager.js.map +1 -1
- package/dist/managers/FlagManager.d.ts +1 -1
- package/dist/managers/FlagManager.d.ts.map +1 -1
- package/dist/managers/FlagManager.js.map +1 -1
- package/dist/managers/PostProcessingManager.d.ts +2 -2
- package/dist/managers/PostProcessingManager.d.ts.map +1 -1
- package/dist/managers/PostProcessingManager.js.map +1 -1
- package/dist/managers/RenderingManager.d.ts +2 -1
- package/dist/managers/RenderingManager.d.ts.map +1 -1
- package/dist/managers/RenderingManager.js +12 -0
- package/dist/managers/RenderingManager.js.map +1 -1
- package/dist/managers/SceneTracingManager.d.ts +3 -3
- package/dist/managers/SceneTracingManager.d.ts.map +1 -1
- package/dist/managers/SceneTracingManager.js.map +1 -1
- package/dist/managers/SceneTreeManager.d.ts +3 -3
- package/dist/managers/SceneTreeManager.d.ts.map +1 -1
- package/dist/managers/SceneTreeManager.js.map +1 -1
- package/dist/managers/SettingsManager.d.ts +2 -2
- package/dist/managers/SettingsManager.d.ts.map +1 -1
- package/dist/managers/SettingsManager.js.map +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.d.ts +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/ContactShadow.js +3 -3
- package/dist/managers/environmentGeometry/Grid.d.ts +2 -2
- package/dist/managers/environmentGeometry/Grid.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlane.d.ts +2 -2
- package/dist/managers/environmentGeometry/GroundPlane.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlane.js.map +1 -1
- package/dist/managers/environmentGeometry/GroundPlaneShadow.d.ts +2 -2
- package/dist/managers/environmentGeometry/GroundPlaneShadow.d.ts.map +1 -1
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.d.ts +1 -1
- package/dist/managers/environmentGeometry/IEnvironmentGeometry.d.ts.map +1 -1
- package/dist/managers/postprocessing/GodRaysManager.d.ts +1 -1
- package/dist/managers/postprocessing/GodRaysManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/OutlineManager.d.ts +1 -1
- package/dist/managers/postprocessing/OutlineManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.d.ts +1 -1
- package/dist/managers/postprocessing/SelectiveBloomManager.d.ts.map +1 -1
- package/dist/managers/postprocessing/ao/ao/shader/ao_compose.js +18 -18
- package/dist/managers/postprocessing/ao/ao/shader/ao_utils.js +81 -81
- package/dist/managers/postprocessing/ao/hbao/shader/hbao.js +154 -154
- package/dist/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.js +152 -152
- package/dist/managers/postprocessing/ao/ssao/shader/ssao.js +115 -115
- package/dist/managers/postprocessing/ao/utils/shader/basic.js +10 -10
- package/dist/managers/postprocessing/ao/utils/shader/sampleBlueNoise.js +37 -37
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js +92 -92
- package/dist/managers/postprocessing/utils/CopyMaterial.js +36 -36
- package/dist/managers/postprocessing/utils/CopyShader.js +23 -23
- package/dist/managers/sceneTree/SDTFUtils.d.ts +2 -2
- package/dist/managers/sceneTree/SDTFUtils.d.ts.map +1 -1
- package/dist/managers/sceneTree/SDTFUtils.js.map +1 -1
- package/dist/managers/sceneTree/SceenTreeManagerUtils.d.ts +1 -1
- package/dist/managers/sceneTree/SceenTreeManagerUtils.d.ts.map +1 -1
- package/dist/managers/sceneTree/SceenTreeManagerUtils.js.map +1 -1
- package/dist/objects/SDColor.d.ts +1 -1
- package/dist/objects/SDColor.d.ts.map +1 -1
- package/dist/objects/SDObject.d.ts +1 -1
- package/dist/objects/SDObject.d.ts.map +1 -1
- package/dist/shaders/PCSS.js +121 -121
- package/dist/shaders/gem.js +576 -576
- package/dist/shaders/multi_points.js +288 -288
- package/dist/styling/viewport-css.js +112 -112
- package/dist/types/IThreejsData.d.ts +1 -1
- package/dist/types/IThreejsData.d.ts.map +1 -1
- package/dist/types/ThreejsData.d.ts +1 -1
- package/dist/types/ThreejsData.d.ts.map +1 -1
- package/package.json +17 -17
|
@@ -1,120 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ssao = void 0;
|
|
4
|
-
exports.ssao = `
|
|
5
|
-
varying vec2 vUv;
|
|
6
|
-
|
|
7
|
-
uniform highp sampler2D depthTexture;
|
|
8
|
-
uniform mat4 projectionViewMatrix;
|
|
9
|
-
uniform mat4 cameraMatrixWorld;
|
|
10
|
-
|
|
11
|
-
uniform sampler2D blueNoiseTexture;
|
|
12
|
-
uniform vec2 blueNoiseRepeat;
|
|
13
|
-
uniform vec2 texSize;
|
|
14
|
-
uniform float aoDistance;
|
|
15
|
-
uniform float distancePower;
|
|
16
|
-
uniform float cameraNear;
|
|
17
|
-
uniform float cameraFar;
|
|
18
|
-
uniform int frame;
|
|
19
|
-
|
|
20
|
-
uniform vec3[spp] samples;
|
|
21
|
-
uniform float[spp] samplesR;
|
|
22
|
-
|
|
23
|
-
#include <common>
|
|
24
|
-
#include <packing>
|
|
25
|
-
#include <sampleBlueNoise>
|
|
26
|
-
#include <ao_utils>
|
|
27
|
-
|
|
28
|
-
highp float linearize_depth(highp float d, highp float zNear, highp float zFar) {
|
|
29
|
-
highp float z_n = 2.0 * d - 1.0;
|
|
30
|
-
return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
void main() {
|
|
34
|
-
float depth = textureLod(depthTexture, vUv, 0.).x;
|
|
35
|
-
vec3 normal = computeNormal(vUv);
|
|
36
|
-
|
|
37
|
-
// filter out background
|
|
38
|
-
if (depth == 1.0) {
|
|
39
|
-
gl_FragColor = vec4(normal, 1.0);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
vec3 worldPos = computeWorldPosition(depth, vUv);
|
|
44
|
-
vec3 screenSpaceNormal = getUnpackedNormal(vUv);
|
|
45
|
-
|
|
46
|
-
#ifdef animatedNoise
|
|
47
|
-
int seed = frame;
|
|
48
|
-
#else
|
|
49
|
-
int seed = 0;
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
vec4 noise = sampleBlueNoise(blueNoiseTexture, seed, blueNoiseRepeat, texSize);
|
|
53
|
-
|
|
54
|
-
vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0);
|
|
55
|
-
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
|
56
|
-
vec3 bitangent = cross(normal, tangent);
|
|
57
|
-
mat3 tbn = mat3(tangent, bitangent, normal);
|
|
58
|
-
|
|
59
|
-
float occluded = 0.0;
|
|
60
|
-
float totalWeight = 0.0;
|
|
61
|
-
|
|
62
|
-
vec3 samplePos;
|
|
63
|
-
|
|
64
|
-
float sppF = float(spp);
|
|
65
|
-
|
|
66
|
-
for (float i = 0.0; i < sppF; i++) {
|
|
67
|
-
vec3 sampleDirection = tbn * samples[int(i)];
|
|
68
|
-
|
|
69
|
-
// make sure sample direction is in the same hemisphere as the normal
|
|
70
|
-
if (dot(sampleDirection, normal) < 0.0) sampleDirection *= -1.0;
|
|
71
|
-
|
|
72
|
-
float moveAmt = samplesR[int(mod(i + noise.a * sppF, sppF))];
|
|
73
|
-
samplePos = worldPos + aoDistance * moveAmt * sampleDirection;
|
|
74
|
-
|
|
75
|
-
vec4 offset = projectionViewMatrix * vec4(samplePos, 1.0);
|
|
76
|
-
offset.xyz /= offset.w;
|
|
77
|
-
offset.xyz = offset.xyz * 0.5 + 0.5;
|
|
78
|
-
|
|
79
|
-
float sampleDepth = textureLod(depthTexture, offset.xy, 0.0).x;
|
|
80
|
-
|
|
81
|
-
if(sampleDepth == 1.0) {
|
|
82
|
-
occluded += 0.0;
|
|
83
|
-
totalWeight += 1.0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
vec3 sampleNormal = getUnpackedNormal(offset.xy);
|
|
88
|
-
|
|
89
|
-
float distSample = linearize_depth(sampleDepth, cameraNear, cameraFar);
|
|
90
|
-
float distWorld = linearize_depth(offset.z, cameraNear, cameraFar);
|
|
91
|
-
|
|
92
|
-
float depthBias = 0.001;
|
|
93
|
-
float rangeCheck = smoothstep(0.0, 1.0, aoDistance / (abs(distSample - distWorld) + depthBias));
|
|
94
|
-
rangeCheck = pow(rangeCheck, distancePower);
|
|
95
|
-
rangeCheck = clamp(rangeCheck, 0.0, 1.0);
|
|
96
|
-
float weight = dot(sampleDirection, normal);
|
|
97
|
-
weight = clamp(weight, 0.0, 1.0);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// check if the normals are in the same direction
|
|
101
|
-
float dotProduct = dot(screenSpaceNormal, normalize(sampleNormal));
|
|
102
|
-
if (dotProduct < 0.9999) {
|
|
103
|
-
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
104
|
-
totalWeight += weight;
|
|
105
|
-
} else {
|
|
106
|
-
if(areDepthsOnSamePlane(depth, sampleDepth, vUv, offset.xy, normal, 0.1)) {
|
|
107
|
-
occluded += 0.0;
|
|
108
|
-
totalWeight += 1.0;
|
|
109
|
-
} else {
|
|
110
|
-
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
111
|
-
totalWeight += weight;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0);
|
|
117
|
-
gl_FragColor = vec4(normal, occ);
|
|
118
|
-
}
|
|
4
|
+
exports.ssao = `
|
|
5
|
+
varying vec2 vUv;
|
|
6
|
+
|
|
7
|
+
uniform highp sampler2D depthTexture;
|
|
8
|
+
uniform mat4 projectionViewMatrix;
|
|
9
|
+
uniform mat4 cameraMatrixWorld;
|
|
10
|
+
|
|
11
|
+
uniform sampler2D blueNoiseTexture;
|
|
12
|
+
uniform vec2 blueNoiseRepeat;
|
|
13
|
+
uniform vec2 texSize;
|
|
14
|
+
uniform float aoDistance;
|
|
15
|
+
uniform float distancePower;
|
|
16
|
+
uniform float cameraNear;
|
|
17
|
+
uniform float cameraFar;
|
|
18
|
+
uniform int frame;
|
|
19
|
+
|
|
20
|
+
uniform vec3[spp] samples;
|
|
21
|
+
uniform float[spp] samplesR;
|
|
22
|
+
|
|
23
|
+
#include <common>
|
|
24
|
+
#include <packing>
|
|
25
|
+
#include <sampleBlueNoise>
|
|
26
|
+
#include <ao_utils>
|
|
27
|
+
|
|
28
|
+
highp float linearize_depth(highp float d, highp float zNear, highp float zFar) {
|
|
29
|
+
highp float z_n = 2.0 * d - 1.0;
|
|
30
|
+
return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void main() {
|
|
34
|
+
float depth = textureLod(depthTexture, vUv, 0.).x;
|
|
35
|
+
vec3 normal = computeNormal(vUv);
|
|
36
|
+
|
|
37
|
+
// filter out background
|
|
38
|
+
if (depth == 1.0) {
|
|
39
|
+
gl_FragColor = vec4(normal, 1.0);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vec3 worldPos = computeWorldPosition(depth, vUv);
|
|
44
|
+
vec3 screenSpaceNormal = getUnpackedNormal(vUv);
|
|
45
|
+
|
|
46
|
+
#ifdef animatedNoise
|
|
47
|
+
int seed = frame;
|
|
48
|
+
#else
|
|
49
|
+
int seed = 0;
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
vec4 noise = sampleBlueNoise(blueNoiseTexture, seed, blueNoiseRepeat, texSize);
|
|
53
|
+
|
|
54
|
+
vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0);
|
|
55
|
+
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
|
56
|
+
vec3 bitangent = cross(normal, tangent);
|
|
57
|
+
mat3 tbn = mat3(tangent, bitangent, normal);
|
|
58
|
+
|
|
59
|
+
float occluded = 0.0;
|
|
60
|
+
float totalWeight = 0.0;
|
|
61
|
+
|
|
62
|
+
vec3 samplePos;
|
|
63
|
+
|
|
64
|
+
float sppF = float(spp);
|
|
65
|
+
|
|
66
|
+
for (float i = 0.0; i < sppF; i++) {
|
|
67
|
+
vec3 sampleDirection = tbn * samples[int(i)];
|
|
68
|
+
|
|
69
|
+
// make sure sample direction is in the same hemisphere as the normal
|
|
70
|
+
if (dot(sampleDirection, normal) < 0.0) sampleDirection *= -1.0;
|
|
71
|
+
|
|
72
|
+
float moveAmt = samplesR[int(mod(i + noise.a * sppF, sppF))];
|
|
73
|
+
samplePos = worldPos + aoDistance * moveAmt * sampleDirection;
|
|
74
|
+
|
|
75
|
+
vec4 offset = projectionViewMatrix * vec4(samplePos, 1.0);
|
|
76
|
+
offset.xyz /= offset.w;
|
|
77
|
+
offset.xyz = offset.xyz * 0.5 + 0.5;
|
|
78
|
+
|
|
79
|
+
float sampleDepth = textureLod(depthTexture, offset.xy, 0.0).x;
|
|
80
|
+
|
|
81
|
+
if(sampleDepth == 1.0) {
|
|
82
|
+
occluded += 0.0;
|
|
83
|
+
totalWeight += 1.0;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
vec3 sampleNormal = getUnpackedNormal(offset.xy);
|
|
88
|
+
|
|
89
|
+
float distSample = linearize_depth(sampleDepth, cameraNear, cameraFar);
|
|
90
|
+
float distWorld = linearize_depth(offset.z, cameraNear, cameraFar);
|
|
91
|
+
|
|
92
|
+
float depthBias = 0.001;
|
|
93
|
+
float rangeCheck = smoothstep(0.0, 1.0, aoDistance / (abs(distSample - distWorld) + depthBias));
|
|
94
|
+
rangeCheck = pow(rangeCheck, distancePower);
|
|
95
|
+
rangeCheck = clamp(rangeCheck, 0.0, 1.0);
|
|
96
|
+
float weight = dot(sampleDirection, normal);
|
|
97
|
+
weight = clamp(weight, 0.0, 1.0);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// check if the normals are in the same direction
|
|
101
|
+
float dotProduct = dot(screenSpaceNormal, normalize(sampleNormal));
|
|
102
|
+
if (dotProduct < 0.9999) {
|
|
103
|
+
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
104
|
+
totalWeight += weight;
|
|
105
|
+
} else {
|
|
106
|
+
if(areDepthsOnSamePlane(depth, sampleDepth, vUv, offset.xy, normal, 0.1)) {
|
|
107
|
+
occluded += 0.0;
|
|
108
|
+
totalWeight += 1.0;
|
|
109
|
+
} else {
|
|
110
|
+
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
111
|
+
totalWeight += weight;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0);
|
|
117
|
+
gl_FragColor = vec4(normal, occ);
|
|
118
|
+
}
|
|
119
119
|
`;
|
|
120
120
|
//# sourceMappingURL=ssao.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.basic = void 0;
|
|
4
|
-
exports.basic = `
|
|
5
|
-
varying vec2 vUv;
|
|
6
|
-
|
|
7
|
-
out mat4 viewMatrixInverse;
|
|
8
|
-
|
|
9
|
-
void main() {
|
|
10
|
-
viewMatrixInverse = inverse(viewMatrix);
|
|
11
|
-
vUv = position.xy * 0.5 + 0.5;
|
|
12
|
-
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
13
|
-
}
|
|
4
|
+
exports.basic = `
|
|
5
|
+
varying vec2 vUv;
|
|
6
|
+
|
|
7
|
+
out mat4 viewMatrixInverse;
|
|
8
|
+
|
|
9
|
+
void main() {
|
|
10
|
+
viewMatrixInverse = inverse(viewMatrix);
|
|
11
|
+
vUv = position.xy * 0.5 + 0.5;
|
|
12
|
+
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
13
|
+
}
|
|
14
14
|
`;
|
|
15
15
|
//# sourceMappingURL=basic.js.map
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sampleBlueNoise = void 0;
|
|
4
|
-
exports.sampleBlueNoise = `
|
|
5
|
-
const float g = 1.6180339887498948482;
|
|
6
|
-
const float a1 = 1.0 / g;
|
|
7
|
-
|
|
8
|
-
// reference: https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
|
9
|
-
float r1(float n) {
|
|
10
|
-
// 7th harmonious number
|
|
11
|
-
return fract(1.1127756842787055 + a1 * n);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);
|
|
15
|
-
|
|
16
|
-
vec4 sampleBlueNoise(sampler2D texture, int seed, vec2 repeat, vec2 texSize) {
|
|
17
|
-
vec2 size = vUv * texSize;
|
|
18
|
-
vec2 blueNoiseSize = texSize / repeat;
|
|
19
|
-
float blueNoiseIndex = floor(floor(size.y / blueNoiseSize.y) * repeat.x) + floor(size.x / blueNoiseSize.x);
|
|
20
|
-
|
|
21
|
-
// get the offset of this pixel's blue noise tile
|
|
22
|
-
// int blueNoiseTileOffset = int(r1(blueNoiseIndex + 1.0) * 65536.);
|
|
23
|
-
|
|
24
|
-
vec2 blueNoiseUv = vUv * repeat;
|
|
25
|
-
|
|
26
|
-
// fetch blue noise for this pixel
|
|
27
|
-
vec4 blueNoise = textureLod(texture, blueNoiseUv, 0.);
|
|
28
|
-
|
|
29
|
-
// animate blue noise
|
|
30
|
-
if (seed != 0) {
|
|
31
|
-
blueNoise = fract(blueNoise + hn * float(seed));
|
|
32
|
-
|
|
33
|
-
blueNoise.r = (blueNoise.r > 0.5 ? 1.0 - blueNoise.r : blueNoise.r) * 2.0;
|
|
34
|
-
blueNoise.g = (blueNoise.g > 0.5 ? 1.0 - blueNoise.g : blueNoise.g) * 2.0;
|
|
35
|
-
blueNoise.b = (blueNoise.b > 0.5 ? 1.0 - blueNoise.b : blueNoise.b) * 2.0;
|
|
36
|
-
blueNoise.a = (blueNoise.a > 0.5 ? 1.0 - blueNoise.a : blueNoise.a) * 2.0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return blueNoise;
|
|
40
|
-
}
|
|
4
|
+
exports.sampleBlueNoise = `
|
|
5
|
+
const float g = 1.6180339887498948482;
|
|
6
|
+
const float a1 = 1.0 / g;
|
|
7
|
+
|
|
8
|
+
// reference: https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
|
9
|
+
float r1(float n) {
|
|
10
|
+
// 7th harmonious number
|
|
11
|
+
return fract(1.1127756842787055 + a1 * n);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);
|
|
15
|
+
|
|
16
|
+
vec4 sampleBlueNoise(sampler2D texture, int seed, vec2 repeat, vec2 texSize) {
|
|
17
|
+
vec2 size = vUv * texSize;
|
|
18
|
+
vec2 blueNoiseSize = texSize / repeat;
|
|
19
|
+
float blueNoiseIndex = floor(floor(size.y / blueNoiseSize.y) * repeat.x) + floor(size.x / blueNoiseSize.x);
|
|
20
|
+
|
|
21
|
+
// get the offset of this pixel's blue noise tile
|
|
22
|
+
// int blueNoiseTileOffset = int(r1(blueNoiseIndex + 1.0) * 65536.);
|
|
23
|
+
|
|
24
|
+
vec2 blueNoiseUv = vUv * repeat;
|
|
25
|
+
|
|
26
|
+
// fetch blue noise for this pixel
|
|
27
|
+
vec4 blueNoise = textureLod(texture, blueNoiseUv, 0.);
|
|
28
|
+
|
|
29
|
+
// animate blue noise
|
|
30
|
+
if (seed != 0) {
|
|
31
|
+
blueNoise = fract(blueNoise + hn * float(seed));
|
|
32
|
+
|
|
33
|
+
blueNoise.r = (blueNoise.r > 0.5 ? 1.0 - blueNoise.r : blueNoise.r) * 2.0;
|
|
34
|
+
blueNoise.g = (blueNoise.g > 0.5 ? 1.0 - blueNoise.g : blueNoise.g) * 2.0;
|
|
35
|
+
blueNoise.b = (blueNoise.b > 0.5 ? 1.0 - blueNoise.b : blueNoise.b) * 2.0;
|
|
36
|
+
blueNoise.a = (blueNoise.a > 0.5 ? 1.0 - blueNoise.a : blueNoise.a) * 2.0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return blueNoise;
|
|
40
|
+
}
|
|
41
41
|
`;
|
|
42
42
|
//# sourceMappingURL=sampleBlueNoise.js.map
|
|
@@ -1,97 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
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
|
-
}
|
|
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
96
|
`;
|
|
97
97
|
//# sourceMappingURL=tone-mapping.js.map
|
|
@@ -2,43 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CopyMaterial = void 0;
|
|
4
4
|
const three_1 = require("three");
|
|
5
|
-
const vertexShader = `
|
|
6
|
-
varying vec2 vUv;
|
|
7
|
-
|
|
8
|
-
void main() {
|
|
9
|
-
|
|
10
|
-
vUv = position.xy * 0.5 + 0.5;
|
|
11
|
-
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
const vertexShader = `
|
|
6
|
+
varying vec2 vUv;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
|
|
10
|
+
vUv = position.xy * 0.5 + 0.5;
|
|
11
|
+
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
12
|
+
|
|
13
|
+
}
|
|
14
14
|
`;
|
|
15
|
-
const fragmentShader = `
|
|
16
|
-
#include <common>
|
|
17
|
-
#include <dithering_pars_fragment>
|
|
18
|
-
|
|
19
|
-
#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
20
|
-
|
|
21
|
-
uniform mediump sampler2D inputBuffer;
|
|
22
|
-
|
|
23
|
-
#else
|
|
24
|
-
|
|
25
|
-
uniform lowp sampler2D inputBuffer;
|
|
26
|
-
|
|
27
|
-
#endif
|
|
28
|
-
|
|
29
|
-
uniform float opacity;
|
|
30
|
-
|
|
31
|
-
varying vec2 vUv;
|
|
32
|
-
|
|
33
|
-
void main() {
|
|
34
|
-
|
|
35
|
-
vec4 texel = texture2D(inputBuffer, vUv);
|
|
36
|
-
gl_FragColor = opacity * texel;
|
|
37
|
-
|
|
38
|
-
#include <colorspace_fragment>
|
|
39
|
-
#include <dithering_fragment>
|
|
40
|
-
|
|
41
|
-
}
|
|
15
|
+
const fragmentShader = `
|
|
16
|
+
#include <common>
|
|
17
|
+
#include <dithering_pars_fragment>
|
|
18
|
+
|
|
19
|
+
#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
20
|
+
|
|
21
|
+
uniform mediump sampler2D inputBuffer;
|
|
22
|
+
|
|
23
|
+
#else
|
|
24
|
+
|
|
25
|
+
uniform lowp sampler2D inputBuffer;
|
|
26
|
+
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
uniform float opacity;
|
|
30
|
+
|
|
31
|
+
varying vec2 vUv;
|
|
32
|
+
|
|
33
|
+
void main() {
|
|
34
|
+
|
|
35
|
+
vec4 texel = texture2D(inputBuffer, vUv);
|
|
36
|
+
gl_FragColor = opacity * texel;
|
|
37
|
+
|
|
38
|
+
#include <colorspace_fragment>
|
|
39
|
+
#include <dithering_fragment>
|
|
40
|
+
|
|
41
|
+
}
|
|
42
42
|
`;
|
|
43
43
|
/**
|
|
44
44
|
* A simple copy shader material.
|
|
@@ -7,30 +7,30 @@ exports.CopyShader = {
|
|
|
7
7
|
tDiffuse: { value: null },
|
|
8
8
|
opacity: { value: 1.0 },
|
|
9
9
|
},
|
|
10
|
-
vertexShader: /* glsl */ `
|
|
11
|
-
|
|
12
|
-
varying vec2 vUv;
|
|
13
|
-
|
|
14
|
-
void main() {
|
|
15
|
-
|
|
16
|
-
vUv = uv;
|
|
17
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
18
|
-
|
|
10
|
+
vertexShader: /* glsl */ `
|
|
11
|
+
|
|
12
|
+
varying vec2 vUv;
|
|
13
|
+
|
|
14
|
+
void main() {
|
|
15
|
+
|
|
16
|
+
vUv = uv;
|
|
17
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
18
|
+
|
|
19
19
|
}`,
|
|
20
|
-
fragmentShader: /* glsl */ `
|
|
21
|
-
|
|
22
|
-
uniform float opacity;
|
|
23
|
-
|
|
24
|
-
uniform sampler2D tDiffuse;
|
|
25
|
-
|
|
26
|
-
varying vec2 vUv;
|
|
27
|
-
|
|
28
|
-
void main() {
|
|
29
|
-
|
|
30
|
-
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
31
|
-
gl_FragColor.a *= opacity;
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
fragmentShader: /* glsl */ `
|
|
21
|
+
|
|
22
|
+
uniform float opacity;
|
|
23
|
+
|
|
24
|
+
uniform sampler2D tDiffuse;
|
|
25
|
+
|
|
26
|
+
varying vec2 vUv;
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
|
|
30
|
+
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
31
|
+
gl_FragColor.a *= opacity;
|
|
32
|
+
|
|
33
|
+
|
|
34
34
|
}`,
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=CopyShader.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ITreeNode, ITreeNodeData, SDTFItemData } from "@shapediver/viewer.shared.node-tree";
|
|
2
|
-
import { ISDTFOverview } from "@shapediver/viewer.shared.types";
|
|
1
|
+
import { type ITreeNode, type ITreeNodeData, SDTFItemData } from "@shapediver/viewer.shared.node-tree";
|
|
2
|
+
import { type ISDTFOverview } from "@shapediver/viewer.shared.types";
|
|
3
3
|
import { RenderingEngine } from "../..";
|
|
4
4
|
export declare const collectSDTFItemData: (node: ITreeNode) => SDTFItemData | undefined;
|
|
5
5
|
export declare const createSDTFOverview: (node: ITreeNode) => ISDTFOverview;
|