@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.3.3 → 3.3.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/package.json +19 -20
- package/src/RenderingEngine.ts +0 -1336
- package/src/index.ts +0 -81
- package/src/injectors/Tag3dGeometryCreationInjector.ts +0 -154
- package/src/injectors/TextureUnifierInjector.ts +0 -214
- package/src/interfaces/ILoader.ts +0 -3
- package/src/interfaces/IPostProcessingEffectDefinitions.ts +0 -402
- package/src/interfaces/IRenderingEngine.ts +0 -48
- package/src/loaders/EnvironmentMapLoader.ts +0 -357
- package/src/loaders/GeometryLoader.ts +0 -585
- package/src/loaders/HTMLElementAnchorLoader.ts +0 -107
- package/src/loaders/LightLoader.ts +0 -171
- package/src/loaders/MaterialLoader.ts +0 -1413
- package/src/managers/CameraManager.ts +0 -178
- package/src/managers/EnvironmentGeometryManager.ts +0 -224
- package/src/managers/PostProcessingManager.ts +0 -1181
- package/src/managers/RenderingManager.ts +0 -657
- package/src/managers/SceneTracingManager.ts +0 -127
- package/src/managers/SceneTreeManager.ts +0 -576
- package/src/managers/postprocessing/GodRaysManager.ts +0 -52
- package/src/managers/postprocessing/OutlineManager.ts +0 -58
- package/src/managers/postprocessing/SSAARenderPass.ts +0 -339
- package/src/managers/postprocessing/SelectiveBloomManager.ts +0 -58
- package/src/managers/postprocessing/ao/ao/AOEffect.ts +0 -180
- package/src/managers/postprocessing/ao/ao/AOPass.ts +0 -128
- package/src/managers/postprocessing/ao/ao/shader/ao_compose.glsl +0 -17
- package/src/managers/postprocessing/ao/ao/shader/ao_compose.ts +0 -19
- package/src/managers/postprocessing/ao/hbao/HBAOEffect.ts +0 -41
- package/src/managers/postprocessing/ao/hbao/shader/hbao.glsl +0 -96
- package/src/managers/postprocessing/ao/hbao/shader/hbao.ts +0 -98
- package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.glsl +0 -92
- package/src/managers/postprocessing/ao/hbao/shader/hbao_utils.ts +0 -95
- package/src/managers/postprocessing/ao/poissionDenoise/PoissionDenoisePass.ts +0 -259
- package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.glsl +0 -125
- package/src/managers/postprocessing/ao/poissionDenoise/shader/poissionDenoise.ts +0 -127
- package/src/managers/postprocessing/ao/ssao/SSAOEffect.ts +0 -106
- package/src/managers/postprocessing/ao/ssao/shader/ssao.glsl +0 -128
- package/src/managers/postprocessing/ao/ssao/shader/ssao.ts +0 -130
- package/src/managers/postprocessing/ao/utils/shader/basic.glsl +0 -6
- package/src/managers/postprocessing/ao/utils/shader/basic.ts +0 -8
- package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.glsl +0 -36
- package/src/managers/postprocessing/ao/utils/shader/sampleBlueNoise.ts +0 -38
- package/src/managers/postprocessing/utils/CopyMaterial.ts +0 -130
- package/src/managers/postprocessing/utils/CopyShader.ts +0 -39
- package/src/managers/postprocessing/utils/FullScreenQuad.ts +0 -47
- package/src/managers/postprocessing/utils/NormalPass.ts +0 -222
- package/src/managers/postprocessing/utils/RenderPass.ts +0 -366
- package/src/materials/GemMaterial.ts +0 -268
- package/src/materials/MeshUnlitMaterialParameters.ts +0 -4
- package/src/materials/MultiPointsMaterial.ts +0 -646
- package/src/materials/SpecularGlossinessMaterial.ts +0 -182
- package/src/objects/SDBone.ts +0 -51
- package/src/objects/SDColor.ts +0 -54
- package/src/objects/SDData.ts +0 -44
- package/src/objects/SDObject.ts +0 -58
- package/src/shaders/PCSS.ts +0 -124
- package/src/shaders/gem.ts +0 -579
- package/src/shaders/gem_frag.glsl +0 -522
- package/src/shaders/gem_vert.glsl +0 -53
- package/src/shaders/multi_points.ts +0 -291
- package/src/shaders/multi_points_frag.glsl +0 -166
- package/src/shaders/multi_points_vert.glsl +0 -120
- package/src/styling/viewport-css.ts +0 -113
- package/src/styling/viewport.css +0 -111
- package/src/three/font.ts +0 -2
- package/src/three/geometries/TextGeometry.ts +0 -58
- package/src/three/loaders/FontLoader.ts +0 -205
- package/src/three/loaders/RGBELoader.ts +0 -496
- package/src/types/IThreejsData.ts +0 -16
- package/src/types/ThreejsData.ts +0 -43
- package/tsconfig.json +0 -20
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
varying vec2 vUv;
|
|
2
|
-
|
|
3
|
-
uniform sampler2D depthTexture;
|
|
4
|
-
uniform sampler2D normalTexture;
|
|
5
|
-
uniform mat4 projectionViewMatrix;
|
|
6
|
-
uniform mat4 cameraMatrixWorld;
|
|
7
|
-
|
|
8
|
-
uniform sampler2D blueNoiseTexture;
|
|
9
|
-
uniform vec2 blueNoiseRepeat;
|
|
10
|
-
uniform vec2 texSize;
|
|
11
|
-
uniform mat4 projectionMatrixInverse;
|
|
12
|
-
|
|
13
|
-
uniform float aoDistance;
|
|
14
|
-
uniform float distancePower;
|
|
15
|
-
uniform float cameraNear;
|
|
16
|
-
uniform float cameraFar;
|
|
17
|
-
uniform int frame;
|
|
18
|
-
|
|
19
|
-
uniform vec3[spp] samples;
|
|
20
|
-
uniform float[spp] samplesR;
|
|
21
|
-
|
|
22
|
-
#include <common>
|
|
23
|
-
#include <packing>
|
|
24
|
-
#include <sampleBlueNoise>
|
|
25
|
-
|
|
26
|
-
// source: https://github.com/N8python/ssao/blob/master/EffectShader.js#L52
|
|
27
|
-
vec3 getWorldPos(const float depth, const vec2 coord) {
|
|
28
|
-
float z = depth * 2.0 - 1.0;
|
|
29
|
-
vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
|
|
30
|
-
vec4 viewSpacePosition = projectionMatrixInverse * clipSpacePosition;
|
|
31
|
-
|
|
32
|
-
// Perspective division
|
|
33
|
-
vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;
|
|
34
|
-
worldSpacePosition.xyz /= worldSpacePosition.w;
|
|
35
|
-
|
|
36
|
-
return worldSpacePosition.xyz;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
vec3 computeNormal(vec3 worldPos, vec2 vUv) {
|
|
40
|
-
vec2 size = vec2(textureSize(depthTexture, 0));
|
|
41
|
-
ivec2 p = ivec2(vUv * size);
|
|
42
|
-
float c0 = texelFetch(depthTexture, p, 0).x;
|
|
43
|
-
float l2 = texelFetch(depthTexture, p - ivec2(2, 0), 0).x;
|
|
44
|
-
float l1 = texelFetch(depthTexture, p - ivec2(1, 0), 0).x;
|
|
45
|
-
float r1 = texelFetch(depthTexture, p + ivec2(1, 0), 0).x;
|
|
46
|
-
float r2 = texelFetch(depthTexture, p + ivec2(2, 0), 0).x;
|
|
47
|
-
float b2 = texelFetch(depthTexture, p - ivec2(0, 2), 0).x;
|
|
48
|
-
float b1 = texelFetch(depthTexture, p - ivec2(0, 1), 0).x;
|
|
49
|
-
float t1 = texelFetch(depthTexture, p + ivec2(0, 1), 0).x;
|
|
50
|
-
float t2 = texelFetch(depthTexture, p + ivec2(0, 2), 0).x;
|
|
51
|
-
float dl = abs((2.0 * l1 - l2) - c0);
|
|
52
|
-
float dr = abs((2.0 * r1 - r2) - c0);
|
|
53
|
-
float db = abs((2.0 * b1 - b2) - c0);
|
|
54
|
-
float dt = abs((2.0 * t1 - t2) - c0);
|
|
55
|
-
vec3 ce = getWorldPos(c0, vUv).xyz;
|
|
56
|
-
vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / size.x, 0.0))).xyz
|
|
57
|
-
: -ce + getWorldPos(r1, (vUv + vec2(1.0 / size.x, 0.0))).xyz;
|
|
58
|
-
vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / size.y))).xyz
|
|
59
|
-
: -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / size.y))).xyz;
|
|
60
|
-
return normalize(cross(dpdx, dpdy));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
highp float linearize_depth(highp float d, highp float zNear, highp float zFar) {
|
|
64
|
-
highp float z_n = 2.0 * d - 1.0;
|
|
65
|
-
return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
void main() {
|
|
69
|
-
float depth = textureLod(depthTexture, vUv, 0.).x;
|
|
70
|
-
|
|
71
|
-
// filter out background
|
|
72
|
-
if (depth == 1.0) {
|
|
73
|
-
discard;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
vec3 worldPos = getWorldPos(depth, vUv);
|
|
78
|
-
vec3 normal = computeNormal(worldPos, vUv);
|
|
79
|
-
|
|
80
|
-
#ifdef animatedNoise
|
|
81
|
-
int seed = frame;
|
|
82
|
-
#else
|
|
83
|
-
int seed = 0;
|
|
84
|
-
#endif
|
|
85
|
-
|
|
86
|
-
vec4 noise = sampleBlueNoise(blueNoiseTexture, seed, blueNoiseRepeat, texSize);
|
|
87
|
-
|
|
88
|
-
vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0);
|
|
89
|
-
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
|
90
|
-
vec3 bitangent = cross(normal, tangent);
|
|
91
|
-
mat3 tbn = mat3(tangent, bitangent, normal);
|
|
92
|
-
|
|
93
|
-
float occluded = 0.0;
|
|
94
|
-
float totalWeight = 0.0;
|
|
95
|
-
|
|
96
|
-
vec3 samplePos;
|
|
97
|
-
|
|
98
|
-
float sppF = float(spp);
|
|
99
|
-
|
|
100
|
-
for (float i = 0.0; i < sppF; i++) {
|
|
101
|
-
vec3 sampleDirection = tbn * samples[int(i)];
|
|
102
|
-
|
|
103
|
-
// make sure sample direction is in the same hemisphere as the normal
|
|
104
|
-
if (dot(sampleDirection, normal) < 0.0) sampleDirection *= -1.0;
|
|
105
|
-
|
|
106
|
-
float moveAmt = samplesR[int(mod(i + noise.a * sppF, sppF))];
|
|
107
|
-
samplePos = worldPos + aoDistance * moveAmt * sampleDirection;
|
|
108
|
-
|
|
109
|
-
vec4 offset = projectionViewMatrix * vec4(samplePos, 1.0);
|
|
110
|
-
offset.xyz /= offset.w;
|
|
111
|
-
offset.xyz = offset.xyz * 0.5 + 0.5;
|
|
112
|
-
|
|
113
|
-
float sampleDepth = textureLod(depthTexture, offset.xy, 0.0).x;
|
|
114
|
-
|
|
115
|
-
float distSample = linearize_depth(sampleDepth, cameraNear, cameraFar);
|
|
116
|
-
float distWorld = linearize_depth(offset.z, cameraNear, cameraFar);
|
|
117
|
-
|
|
118
|
-
float rangeCheck = smoothstep(0.0, 1.0, aoDistance / abs(distSample - distWorld));
|
|
119
|
-
rangeCheck = pow(rangeCheck, distancePower);
|
|
120
|
-
float weight = dot(sampleDirection, normal);
|
|
121
|
-
|
|
122
|
-
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
123
|
-
totalWeight += weight;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0);
|
|
127
|
-
gl_FragColor = vec4(normal, occ);
|
|
128
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export const ssao = `
|
|
2
|
-
varying vec2 vUv;
|
|
3
|
-
|
|
4
|
-
uniform highp sampler2D depthTexture;
|
|
5
|
-
uniform sampler2D normalTexture;
|
|
6
|
-
uniform mat4 projectionViewMatrix;
|
|
7
|
-
uniform mat4 cameraMatrixWorld;
|
|
8
|
-
|
|
9
|
-
uniform sampler2D blueNoiseTexture;
|
|
10
|
-
uniform vec2 blueNoiseRepeat;
|
|
11
|
-
uniform vec2 texSize;
|
|
12
|
-
uniform mat4 projectionMatrixInverse;
|
|
13
|
-
|
|
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
|
-
|
|
27
|
-
// source: https://github.com/N8python/ssao/blob/master/EffectShader.js#L52
|
|
28
|
-
vec3 getWorldPos(const float depth, const vec2 coord) {
|
|
29
|
-
float z = depth * 2.0 - 1.0;
|
|
30
|
-
vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
|
|
31
|
-
vec4 viewSpacePosition = projectionMatrixInverse * clipSpacePosition;
|
|
32
|
-
|
|
33
|
-
// Perspective division
|
|
34
|
-
vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;
|
|
35
|
-
worldSpacePosition.xyz /= worldSpacePosition.w;
|
|
36
|
-
|
|
37
|
-
return worldSpacePosition.xyz;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
vec3 computeNormal(vec3 worldPos, vec2 vUv) {
|
|
41
|
-
vec2 size = vec2(textureSize(depthTexture, 0));
|
|
42
|
-
ivec2 p = ivec2(vUv * size);
|
|
43
|
-
float c0 = texelFetch(depthTexture, p, 0).x;
|
|
44
|
-
float l2 = texelFetch(depthTexture, p - ivec2(2, 0), 0).x;
|
|
45
|
-
float l1 = texelFetch(depthTexture, p - ivec2(1, 0), 0).x;
|
|
46
|
-
float r1 = texelFetch(depthTexture, p + ivec2(1, 0), 0).x;
|
|
47
|
-
float r2 = texelFetch(depthTexture, p + ivec2(2, 0), 0).x;
|
|
48
|
-
float b2 = texelFetch(depthTexture, p - ivec2(0, 2), 0).x;
|
|
49
|
-
float b1 = texelFetch(depthTexture, p - ivec2(0, 1), 0).x;
|
|
50
|
-
float t1 = texelFetch(depthTexture, p + ivec2(0, 1), 0).x;
|
|
51
|
-
float t2 = texelFetch(depthTexture, p + ivec2(0, 2), 0).x;
|
|
52
|
-
float dl = abs((2.0 * l1 - l2) - c0);
|
|
53
|
-
float dr = abs((2.0 * r1 - r2) - c0);
|
|
54
|
-
float db = abs((2.0 * b1 - b2) - c0);
|
|
55
|
-
float dt = abs((2.0 * t1 - t2) - c0);
|
|
56
|
-
vec3 ce = getWorldPos(c0, vUv).xyz;
|
|
57
|
-
vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / size.x, 0.0))).xyz
|
|
58
|
-
: -ce + getWorldPos(r1, (vUv + vec2(1.0 / size.x, 0.0))).xyz;
|
|
59
|
-
vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / size.y))).xyz
|
|
60
|
-
: -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / size.y))).xyz;
|
|
61
|
-
return normalize(cross(dpdx, dpdy));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
highp float linearize_depth(highp float d, highp float zNear, highp float zFar) {
|
|
65
|
-
highp float z_n = 2.0 * d - 1.0;
|
|
66
|
-
return 2.0 * zNear * zFar / (zFar + zNear - z_n * (zFar - zNear));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
void main() {
|
|
70
|
-
float depth = textureLod(depthTexture, vUv, 0.).x;
|
|
71
|
-
|
|
72
|
-
// filter out background
|
|
73
|
-
if (depth == 1.0) {
|
|
74
|
-
discard;
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
vec3 worldPos = getWorldPos(depth, vUv);
|
|
79
|
-
vec3 normal = computeNormal(worldPos, vUv);
|
|
80
|
-
|
|
81
|
-
#ifdef animatedNoise
|
|
82
|
-
int seed = frame;
|
|
83
|
-
#else
|
|
84
|
-
int seed = 0;
|
|
85
|
-
#endif
|
|
86
|
-
|
|
87
|
-
vec4 noise = sampleBlueNoise(blueNoiseTexture, seed, blueNoiseRepeat, texSize);
|
|
88
|
-
|
|
89
|
-
vec3 randomVec = normalize(noise.rgb * 2.0 - 1.0);
|
|
90
|
-
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
|
91
|
-
vec3 bitangent = cross(normal, tangent);
|
|
92
|
-
mat3 tbn = mat3(tangent, bitangent, normal);
|
|
93
|
-
|
|
94
|
-
float occluded = 0.0;
|
|
95
|
-
float totalWeight = 0.0;
|
|
96
|
-
|
|
97
|
-
vec3 samplePos;
|
|
98
|
-
|
|
99
|
-
float sppF = float(spp);
|
|
100
|
-
|
|
101
|
-
for (float i = 0.0; i < sppF; i++) {
|
|
102
|
-
vec3 sampleDirection = tbn * samples[int(i)];
|
|
103
|
-
|
|
104
|
-
// make sure sample direction is in the same hemisphere as the normal
|
|
105
|
-
if (dot(sampleDirection, normal) < 0.0) sampleDirection *= -1.0;
|
|
106
|
-
|
|
107
|
-
float moveAmt = samplesR[int(mod(i + noise.a * sppF, sppF))];
|
|
108
|
-
samplePos = worldPos + aoDistance * moveAmt * sampleDirection;
|
|
109
|
-
|
|
110
|
-
vec4 offset = projectionViewMatrix * vec4(samplePos, 1.0);
|
|
111
|
-
offset.xyz /= offset.w;
|
|
112
|
-
offset.xyz = offset.xyz * 0.5 + 0.5;
|
|
113
|
-
|
|
114
|
-
float sampleDepth = textureLod(depthTexture, offset.xy, 0.0).x;
|
|
115
|
-
|
|
116
|
-
float distSample = linearize_depth(sampleDepth, cameraNear, cameraFar);
|
|
117
|
-
float distWorld = linearize_depth(offset.z, cameraNear, cameraFar);
|
|
118
|
-
|
|
119
|
-
float rangeCheck = smoothstep(0.0, 1.0, aoDistance / abs(distSample - distWorld));
|
|
120
|
-
rangeCheck = pow(rangeCheck, distancePower);
|
|
121
|
-
float weight = dot(sampleDirection, normal);
|
|
122
|
-
|
|
123
|
-
occluded += rangeCheck * weight * (distSample < distWorld ? 1.0 : 0.0);
|
|
124
|
-
totalWeight += weight;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
float occ = clamp(1.0 - occluded / totalWeight, 0.0, 1.0);
|
|
128
|
-
gl_FragColor = vec4(normal, occ);
|
|
129
|
-
}
|
|
130
|
-
`
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const float g = 1.6180339887498948482;
|
|
2
|
-
const float a1 = 1.0 / g;
|
|
3
|
-
|
|
4
|
-
// reference: https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
|
5
|
-
float r1(float n) {
|
|
6
|
-
// 7th harmonious number
|
|
7
|
-
return fract(1.1127756842787055 + a1 * n);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);
|
|
11
|
-
|
|
12
|
-
vec4 sampleBlueNoise(sampler2D texture, int seed, vec2 repeat, vec2 texSize) {
|
|
13
|
-
vec2 size = vUv * texSize;
|
|
14
|
-
vec2 blueNoiseSize = texSize / repeat;
|
|
15
|
-
float blueNoiseIndex = floor(floor(size.y / blueNoiseSize.y) * repeat.x) + floor(size.x / blueNoiseSize.x);
|
|
16
|
-
|
|
17
|
-
// get the offset of this pixel's blue noise tile
|
|
18
|
-
// int blueNoiseTileOffset = int(r1(blueNoiseIndex + 1.0) * 65536.);
|
|
19
|
-
|
|
20
|
-
vec2 blueNoiseUv = vUv * repeat;
|
|
21
|
-
|
|
22
|
-
// fetch blue noise for this pixel
|
|
23
|
-
vec4 blueNoise = textureLod(texture, blueNoiseUv, 0.);
|
|
24
|
-
|
|
25
|
-
// animate blue noise
|
|
26
|
-
if (seed != 0) {
|
|
27
|
-
blueNoise = fract(blueNoise + hn * float(seed));
|
|
28
|
-
|
|
29
|
-
blueNoise.r = (blueNoise.r > 0.5 ? 1.0 - blueNoise.r : blueNoise.r) * 2.0;
|
|
30
|
-
blueNoise.g = (blueNoise.g > 0.5 ? 1.0 - blueNoise.g : blueNoise.g) * 2.0;
|
|
31
|
-
blueNoise.b = (blueNoise.b > 0.5 ? 1.0 - blueNoise.b : blueNoise.b) * 2.0;
|
|
32
|
-
blueNoise.a = (blueNoise.a > 0.5 ? 1.0 - blueNoise.a : blueNoise.a) * 2.0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return blueNoise;
|
|
36
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export const sampleBlueNoise = `
|
|
2
|
-
const float g = 1.6180339887498948482;
|
|
3
|
-
const float a1 = 1.0 / g;
|
|
4
|
-
|
|
5
|
-
// reference: https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
|
6
|
-
float r1(float n) {
|
|
7
|
-
// 7th harmonious number
|
|
8
|
-
return fract(1.1127756842787055 + a1 * n);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const vec4 hn = vec4(0.618033988749895, 0.3247179572447458, 0.2207440846057596, 0.1673039782614187);
|
|
12
|
-
|
|
13
|
-
vec4 sampleBlueNoise(sampler2D texture, int seed, vec2 repeat, vec2 texSize) {
|
|
14
|
-
vec2 size = vUv * texSize;
|
|
15
|
-
vec2 blueNoiseSize = texSize / repeat;
|
|
16
|
-
float blueNoiseIndex = floor(floor(size.y / blueNoiseSize.y) * repeat.x) + floor(size.x / blueNoiseSize.x);
|
|
17
|
-
|
|
18
|
-
// get the offset of this pixel's blue noise tile
|
|
19
|
-
// int blueNoiseTileOffset = int(r1(blueNoiseIndex + 1.0) * 65536.);
|
|
20
|
-
|
|
21
|
-
vec2 blueNoiseUv = vUv * repeat;
|
|
22
|
-
|
|
23
|
-
// fetch blue noise for this pixel
|
|
24
|
-
vec4 blueNoise = textureLod(texture, blueNoiseUv, 0.);
|
|
25
|
-
|
|
26
|
-
// animate blue noise
|
|
27
|
-
if (seed != 0) {
|
|
28
|
-
blueNoise = fract(blueNoise + hn * float(seed));
|
|
29
|
-
|
|
30
|
-
blueNoise.r = (blueNoise.r > 0.5 ? 1.0 - blueNoise.r : blueNoise.r) * 2.0;
|
|
31
|
-
blueNoise.g = (blueNoise.g > 0.5 ? 1.0 - blueNoise.g : blueNoise.g) * 2.0;
|
|
32
|
-
blueNoise.b = (blueNoise.b > 0.5 ? 1.0 - blueNoise.b : blueNoise.b) * 2.0;
|
|
33
|
-
blueNoise.a = (blueNoise.a > 0.5 ? 1.0 - blueNoise.a : blueNoise.a) * 2.0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return blueNoise;
|
|
37
|
-
}
|
|
38
|
-
`
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { AddEquation, AdditiveBlending, CustomBlending, MultiplyBlending, NoBlending, NormalBlending, OneFactor, OneMinusSrcColorFactor, ShaderMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, SubtractiveBlending, Uniform, WebGLRenderTarget, ZeroFactor } from "three";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const vertexShader =
|
|
5
|
-
`
|
|
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
|
-
`
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const fragmentShader =
|
|
18
|
-
`
|
|
19
|
-
#include <common>
|
|
20
|
-
#include <dithering_pars_fragment>
|
|
21
|
-
|
|
22
|
-
#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
23
|
-
|
|
24
|
-
uniform mediump sampler2D inputBuffer;
|
|
25
|
-
|
|
26
|
-
#else
|
|
27
|
-
|
|
28
|
-
uniform lowp sampler2D inputBuffer;
|
|
29
|
-
|
|
30
|
-
#endif
|
|
31
|
-
|
|
32
|
-
uniform float opacity;
|
|
33
|
-
|
|
34
|
-
varying vec2 vUv;
|
|
35
|
-
|
|
36
|
-
void main() {
|
|
37
|
-
|
|
38
|
-
vec4 texel = texture2D(inputBuffer, vUv);
|
|
39
|
-
gl_FragColor = opacity * texel;
|
|
40
|
-
|
|
41
|
-
#include <colorspace_fragment>
|
|
42
|
-
#include <dithering_fragment>
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A simple copy shader material.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
export class CopyMaterial extends ShaderMaterial {
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Constructs a new copy material.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
constructor() {
|
|
58
|
-
|
|
59
|
-
super({
|
|
60
|
-
name: "CopyMaterial",
|
|
61
|
-
uniforms: {
|
|
62
|
-
inputBuffer: new Uniform(null),
|
|
63
|
-
opacity: new Uniform(1.0)
|
|
64
|
-
},
|
|
65
|
-
blending: CustomBlending,
|
|
66
|
-
blendEquation: AddEquation,
|
|
67
|
-
blendDst: ZeroFactor,
|
|
68
|
-
blendSrc: OneFactor,
|
|
69
|
-
toneMapped: false,
|
|
70
|
-
depthWrite: false,
|
|
71
|
-
depthTest: false,
|
|
72
|
-
transparent: true,
|
|
73
|
-
fragmentShader,
|
|
74
|
-
vertexShader
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The input buffer.
|
|
81
|
-
*
|
|
82
|
-
* @type {Texture}
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
set inputBuffer(value: WebGLRenderTarget) {
|
|
86
|
-
|
|
87
|
-
this.uniforms.inputBuffer.value = value;
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Sets the input buffer.
|
|
93
|
-
*
|
|
94
|
-
* @deprecated Use inputBuffer instead.
|
|
95
|
-
* @param {Number} value - The buffer.
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
setInputBuffer(value: WebGLRenderTarget) {
|
|
99
|
-
|
|
100
|
-
this.uniforms.inputBuffer.value = value;
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Returns the opacity.
|
|
106
|
-
*
|
|
107
|
-
* @deprecated Use opacity instead.
|
|
108
|
-
* @return {Number} The opacity.
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
getOpacity(value: number) {
|
|
112
|
-
|
|
113
|
-
return this.uniforms.opacity.value;
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Sets the opacity.
|
|
119
|
-
*
|
|
120
|
-
* @deprecated Use opacity instead.
|
|
121
|
-
* @param {Number} value - The opacity.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
setOpacity(value: number) {
|
|
125
|
-
|
|
126
|
-
this.uniforms.opacity.value = value;
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export const CopyShader = {
|
|
2
|
-
|
|
3
|
-
name: 'CopyShader',
|
|
4
|
-
|
|
5
|
-
uniforms: {
|
|
6
|
-
|
|
7
|
-
'tDiffuse': { value: null },
|
|
8
|
-
'opacity': { value: 1.0 }
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
vertexShader: /* glsl */`
|
|
13
|
-
|
|
14
|
-
varying vec2 vUv;
|
|
15
|
-
|
|
16
|
-
void main() {
|
|
17
|
-
|
|
18
|
-
vUv = uv;
|
|
19
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
20
|
-
|
|
21
|
-
}`,
|
|
22
|
-
|
|
23
|
-
fragmentShader: /* glsl */`
|
|
24
|
-
|
|
25
|
-
uniform float opacity;
|
|
26
|
-
|
|
27
|
-
uniform sampler2D tDiffuse;
|
|
28
|
-
|
|
29
|
-
varying vec2 vUv;
|
|
30
|
-
|
|
31
|
-
void main() {
|
|
32
|
-
|
|
33
|
-
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
34
|
-
gl_FragColor.a *= opacity;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}`
|
|
38
|
-
|
|
39
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Helper for passes that need to fill the viewport with a single quad.
|
|
3
|
-
|
|
4
|
-
import { OrthographicCamera, BufferGeometry, Float32BufferAttribute, Mesh, Material, WebGLRenderer } from "three";
|
|
5
|
-
|
|
6
|
-
const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
7
|
-
|
|
8
|
-
// https://github.com/mrdoob/three.js/pull/21358
|
|
9
|
-
|
|
10
|
-
const _geometry = new BufferGeometry();
|
|
11
|
-
_geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
|
|
12
|
-
_geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
|
|
13
|
-
|
|
14
|
-
export class FullScreenQuad {
|
|
15
|
-
_mesh: Mesh;
|
|
16
|
-
|
|
17
|
-
constructor( material: Material ) {
|
|
18
|
-
|
|
19
|
-
this._mesh = new Mesh( _geometry, material );
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
dispose() {
|
|
24
|
-
|
|
25
|
-
this._mesh.geometry.dispose();
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
render( renderer: WebGLRenderer ) {
|
|
30
|
-
|
|
31
|
-
renderer.render( this._mesh, _camera );
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get material() {
|
|
36
|
-
|
|
37
|
-
return this._mesh.material;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
set material( value ) {
|
|
42
|
-
|
|
43
|
-
this._mesh.material = value;
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|