@meimu/mutracer 0.1.1 → 0.1.3
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/assets/bvh.worker.js +1 -1
- package/dist/mutracer.umd.js +3525 -3484
- package/docs/materials.md +27 -7
- package/docs/threejs.md +13 -2
- package/docs/viewer.md +53 -0
- package/lib/oidn.d.ts +1 -1
- package/lib/oidnBundledWeights.cdn.d.ts +2 -2
- package/lib/renderer/MaterialTable.d.ts +1 -0
- package/lib/renderer/MaterialTable.js +2 -1
- package/lib/renderer/MaterialTable.js.map +1 -1
- package/lib/renderer/WGPUBloomPass.js +18 -18
- package/lib/renderer/WGPUFullQuadPass.js +3 -3
- package/lib/renderer/WGPUJNLMDenoiser.js +62 -62
- package/lib/renderer/WGPURayTraceOutput.js +14 -12
- package/lib/renderer/WGPURayTraceOutput.js.map +1 -1
- package/lib/renderer/WGPURayTracePass.js +2 -2
- package/lib/renderer/WGPURayTracePass.js.map +1 -1
- package/lib/renderer/WGPURenderingPipeline.js +20 -18
- package/lib/renderer/WGPURenderingPipeline.js.map +1 -1
- package/lib/renderer/WebGLJNLMDenoiser.js +61 -61
- package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
- package/lib/renderer/WebGLRayTracePass.js +3 -1
- package/lib/renderer/WebGLRayTracePass.js.map +1 -1
- package/lib/renderer/glsl/chunks/cameraRay.glsl.js +9 -9
- package/lib/renderer/glsl/chunks/envMap.glsl.js +45 -45
- package/lib/renderer/glsl/chunks/intersect.glsl.js +262 -262
- package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +111 -111
- package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +436 -436
- package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
- package/lib/renderer/glsl/chunks/random.glsl.js +3 -3
- package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +32 -32
- package/lib/renderer/glsl/chunks/sampleLight.glsl.js +54 -54
- package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +71 -71
- package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +12 -12
- package/lib/renderer/glsl/chunks/sampling.glsl.js +64 -64
- package/lib/renderer/glsl/chunks/sobol.glsl.js +49 -49
- package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
- package/lib/renderer/glsl/chunks/uvProjection.glsl.js +5 -5
- package/lib/renderer/glsl/depthQuery.frag.js +2 -2
- package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +8 -8
- package/lib/renderer/glsl/rayTrace.frag.js +128 -128
- package/lib/renderer/glsl/shadowCatcher.frag.js +12 -12
- package/lib/renderer/glsl/webglPipeline.frag.js +49 -49
- package/lib/renderer/lightsUtil.js +1 -1
- package/lib/renderer/lightsUtil.js.map +1 -1
- package/lib/renderer/materialComparison.generated.js +5 -0
- package/lib/renderer/materialComparison.generated.js.map +1 -1
- package/lib/renderer/materialLayout.js +2 -1
- package/lib/renderer/materialLayout.js.map +1 -1
- package/lib/renderer/prepareMeshBVH.d.ts +4 -2
- package/lib/renderer/prepareMeshBVH.js +44 -20
- package/lib/renderer/prepareMeshBVH.js.map +1 -1
- package/lib/renderer/scratchSampling.js +6 -6
- package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
- package/lib/renderer/wgsl/chunks/envMap.wgsl.js +29 -29
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js +376 -379
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +5 -5
- package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +51 -51
- package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +453 -453
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +1 -1
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +122 -117
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
- package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +13 -13
- package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +94 -94
- package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +119 -119
- package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +5 -5
- package/lib/renderer/wgsl/chunks/sampling.wgsl.js +62 -62
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.d.ts +3 -3
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js +2 -2
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/chunks/sobol.wgsl.js +53 -53
- package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +5 -5
- package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +2 -2
- package/lib/renderer/wgsl/compose.frag.wgsl.js +120 -92
- package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -1
- package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
- package/lib/renderer/wgsl/depthQuery.wgsl.js +3 -3
- package/lib/renderer/wgsl/offlineAdaptive.compute.js +26 -26
- package/lib/renderer/wgsl/rayTrace.compute.js +220 -211
- package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
- package/lib/scene/OpenPBRMaterial.d.ts +4 -2
- package/lib/scene/OpenPBRMaterial.js +4 -2
- package/lib/scene/OpenPBRMaterial.js.map +1 -1
- package/lib/scene/openPbrSchema.d.ts +7 -2
- package/lib/scene/openPbrSchema.js +2 -1
- package/lib/scene/openPbrSchema.js.map +1 -1
- package/lib/util/fromTHREE.d.ts +1 -0
- package/lib/util/fromTHREE.js +24 -6
- package/lib/util/fromTHREE.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +5 -4
|
@@ -26,10 +26,10 @@ const uint BOUNCE_STRIDE = 64u;
|
|
|
26
26
|
|
|
27
27
|
uvec2 bc;
|
|
28
28
|
uint bd;
|
|
29
|
-
uint
|
|
29
|
+
uint cF = 0u;
|
|
30
30
|
uint em = 0u;
|
|
31
|
-
uint eg(uint
|
|
32
|
-
uint x =
|
|
31
|
+
uint eg(uint kk) {
|
|
32
|
+
uint x = kk;
|
|
33
33
|
x ^= x >> 16u; x *= 0x7feb352du;
|
|
34
34
|
x ^= x >> 15u; x *= 0x846ca68bu;
|
|
35
35
|
return x ^ (x >> 16u);
|
|
@@ -37,28 +37,28 @@ return x ^ (x >> 16u);
|
|
|
37
37
|
uint aq(uint a, uint b) {
|
|
38
38
|
return eg(a ^ eg(b + 0x9e3779b9u));
|
|
39
39
|
}
|
|
40
|
-
uint iA(uint
|
|
41
|
-
uint x =
|
|
40
|
+
uint iA(uint kk, uint ic) {
|
|
41
|
+
uint x = kk + ic;
|
|
42
42
|
x ^= x * 0x6c50b47cu; x ^= x * 0xb82f1e52u;
|
|
43
43
|
x ^= x * 0xc7afe638u; x ^= x * 0x8d22f6e6u;
|
|
44
44
|
return x;
|
|
45
45
|
}
|
|
46
|
-
uint
|
|
47
|
-
return reverseBits(iA(reverseBits(x),
|
|
46
|
+
uint sC(uint x, uint ic) {
|
|
47
|
+
return reverseBits(iA(reverseBits(x), ic));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
uint
|
|
51
|
-
uint r = reverseBits(
|
|
50
|
+
uint rb(uint kk) {
|
|
51
|
+
uint r = reverseBits(kk);
|
|
52
52
|
${sobolD1Steps.map(([shift, mask]) => `r ^= (r << ${shift}u) & 0x${mask.toString(16)}u;`).join("\n ")}
|
|
53
53
|
return r;
|
|
54
54
|
}
|
|
55
|
-
vec2
|
|
56
|
-
uint i =
|
|
57
|
-
uint x = reverseBits(iA(i, aq(
|
|
58
|
-
uint y =
|
|
55
|
+
vec2 vI(uint index, uint ic) {
|
|
56
|
+
uint i = sC(index, aq(ic, 0u));
|
|
57
|
+
uint x = reverseBits(iA(i, aq(ic, 1u)));
|
|
58
|
+
uint y = sC(rb(i), aq(ic, 2u));
|
|
59
59
|
return vec2(float(x >> 8u), float(y >> 8u)) * (1.0 / 16777216.0);
|
|
60
60
|
}
|
|
61
|
-
uint
|
|
61
|
+
uint tp(uvec2 p) {
|
|
62
62
|
uvec2 v = p & uvec2(255u);
|
|
63
63
|
v = (v | (v << uvec2(4u))) & uvec2(0x0f0fu);
|
|
64
64
|
v = (v | (v << uvec2(2u))) & uvec2(0x3333u);
|
|
@@ -66,35 +66,35 @@ v = (v | (v << uvec2(1u))) & uvec2(0x5555u);
|
|
|
66
66
|
return v.x | (v.y << 1u);
|
|
67
67
|
}
|
|
68
68
|
${zSobolPackedPermutations.map((v, i) => `const uint Z_PERM_${i} = ${v}u;`).join("\n")}
|
|
69
|
-
uint
|
|
70
|
-
uint group =
|
|
69
|
+
uint km(uint tu) {
|
|
70
|
+
uint group = tu >> 2u;
|
|
71
71
|
uint word = Z_PERM_5;
|
|
72
72
|
${[0, 1, 2, 3, 4].map(i => `word = group == ${i}u ? Z_PERM_${i} : word;`).join("\n ")}
|
|
73
|
-
return (word >> ((
|
|
73
|
+
return (word >> ((tu & 3u) * 8u)) & 255u;
|
|
74
74
|
}
|
|
75
|
-
uint
|
|
75
|
+
uint pO(uint kE, uint dim, uint logSPP) {
|
|
76
76
|
uint odd = logSPP & 1u;
|
|
77
|
-
uint
|
|
77
|
+
uint uf = 8u + ((logSPP + 1u) >> 1u);
|
|
78
78
|
uint result = 0u;
|
|
79
|
-
for (int digit = int(
|
|
79
|
+
for (int digit = int(uf) - 1; digit >= int(odd); digit--) {
|
|
80
80
|
uint shift = 2u*uint(digit) - odd;
|
|
81
81
|
|
|
82
|
-
uint
|
|
83
|
-
if (shift < 30u) {
|
|
84
|
-
uint
|
|
85
|
-
uint d = (
|
|
86
|
-
result |= ((
|
|
82
|
+
uint sj = 0u;
|
|
83
|
+
if (shift < 30u) { sj = kE >> (shift + 2u); }
|
|
84
|
+
uint tu = (eg(sj ^ (0x55555555u * dim)) >> 24u) % 24u;
|
|
85
|
+
uint d = (kE >> shift) & 3u;
|
|
86
|
+
result |= ((km(tu) >> (2u*d)) & 3u) << shift;
|
|
87
87
|
}
|
|
88
88
|
if (odd != 0u) {
|
|
89
|
-
result |= (
|
|
89
|
+
result |= (kE & 1u) ^ (eg((kE >> 1u) ^ (0x55555555u * dim)) & 1u);
|
|
90
90
|
}
|
|
91
91
|
return result;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
uint
|
|
97
|
-
return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) +
|
|
96
|
+
uint cw(uint slot) {
|
|
97
|
+
return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) + cF * BOUNCE_STRIDE + slot;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
uvec4 hh;
|
|
@@ -102,41 +102,41 @@ uint hi;
|
|
|
102
102
|
bool fv = false;
|
|
103
103
|
bool df = false;
|
|
104
104
|
uint dE;
|
|
105
|
-
uint
|
|
105
|
+
uint gq;
|
|
106
106
|
vec2 eN;
|
|
107
107
|
void dw(uint dim) {
|
|
108
108
|
|
|
109
|
-
uint
|
|
110
|
-
uvec4 key = uvec4(dim, bd,
|
|
109
|
+
uint jW = bc.x + bc.y * uint(round(1.0 / pixelSize.x));
|
|
110
|
+
uvec4 key = uvec4(dim, bd, jW, uint(sequenceSeed));
|
|
111
111
|
if (fv && all(equal(hh, key)) && hi == uint(zSobolLogSPP)) { return; }
|
|
112
112
|
hh = key; hi = uint(zSobolLogSPP);
|
|
113
113
|
fv = true; df = false;
|
|
114
|
-
uint
|
|
114
|
+
uint ic = aq(aq(jW, dim), uint(sequenceSeed));
|
|
115
115
|
uint index = bd;
|
|
116
116
|
if (samplingPattern == 1) {
|
|
117
117
|
uint logSPP = uint(zSobolLogSPP);
|
|
118
118
|
if (index == 0u) { logSPP = 0u; }
|
|
119
119
|
else { index -= 1u; }
|
|
120
120
|
|
|
121
|
-
uint
|
|
121
|
+
uint iW = index >> logSPP;
|
|
122
122
|
uint mask = (1u << logSPP) - 1u;
|
|
123
|
-
uint
|
|
124
|
-
index =
|
|
123
|
+
uint kE = (tp(bc) << logSPP) | (index & mask);
|
|
124
|
+
index = pO(kE, dim, logSPP);
|
|
125
125
|
uvec2 tile = bc >> uvec2(8u);
|
|
126
|
-
|
|
126
|
+
ic = aq(aq(dim, uint(sequenceSeed)), aq(tile.x, tile.y));
|
|
127
127
|
|
|
128
|
-
if (bd != 0u) {
|
|
129
|
-
|
|
128
|
+
if (bd != 0u) { iW += 1u; }
|
|
129
|
+
ic = aq(ic, iW);
|
|
130
130
|
}
|
|
131
|
-
dE =
|
|
132
|
-
|
|
133
|
-
uint x = reverseBits(iA(dE, aq(
|
|
131
|
+
dE = sC(index, aq(ic, 0u));
|
|
132
|
+
gq = ic;
|
|
133
|
+
uint x = reverseBits(iA(dE, aq(ic, 1u)));
|
|
134
134
|
eN.x = float(x >> 8u) * (1.0 / 16777216.0);
|
|
135
135
|
}
|
|
136
|
-
vec2
|
|
136
|
+
vec2 kJ(uint dim) {
|
|
137
137
|
dw(dim);
|
|
138
138
|
if (!df) {
|
|
139
|
-
uint y =
|
|
139
|
+
uint y = sC(rb(dE), aq(gq, 2u));
|
|
140
140
|
eN.y = float(y >> 8u) * (1.0 / 16777216.0);
|
|
141
141
|
df = true;
|
|
142
142
|
}
|
|
@@ -152,18 +152,18 @@ if (samplingPattern == 2) {
|
|
|
152
152
|
float x = dz(dim); float y = dz(dim);
|
|
153
153
|
return vec2(x,y);
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return kJ(dim);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
float eo(uint slot) {
|
|
159
|
-
uint dim = aq(aq(
|
|
159
|
+
uint dim = aq(aq(cF, slot), em) | 0x80000000u;
|
|
160
160
|
em += 1u;
|
|
161
161
|
if (samplingPattern == 2) { return EPS + (1.0 - 2.0*EPS)*rand(); }
|
|
162
162
|
|
|
163
|
-
uint
|
|
164
|
-
uint
|
|
165
|
-
uint i =
|
|
166
|
-
uint x = reverseBits(iA(i, aq(
|
|
163
|
+
uint jW = bc.x + bc.y * uint(round(1.0 / pixelSize.x));
|
|
164
|
+
uint ic = aq(aq(jW, dim), uint(sequenceSeed));
|
|
165
|
+
uint i = sC(bd, aq(ic, 0u));
|
|
166
|
+
uint x = reverseBits(iA(i, aq(ic, 1u)));
|
|
167
167
|
return EPS + (1.0 - 2.0*EPS) * (float(x >> 8u) * (1.0 / 16777216.0));
|
|
168
168
|
}
|
|
169
169
|
`;
|
|
@@ -9,16 +9,16 @@ vec4 textureLinear(sampler2D map, vec2 uv) {
|
|
|
9
9
|
return texture(map, uv);
|
|
10
10
|
#else
|
|
11
11
|
vec2 size = vec2(textureSize(map, 0));
|
|
12
|
-
vec2
|
|
12
|
+
vec2 pS = 1.0 / size;
|
|
13
13
|
|
|
14
14
|
uv = uv * size - 0.5;
|
|
15
15
|
vec2 f = fract(uv);
|
|
16
16
|
uv = floor(uv) + 0.5;
|
|
17
17
|
|
|
18
|
-
vec4 s1 = texture(map, (uv + vec2(0, 0)) *
|
|
19
|
-
vec4 s2 = texture(map, (uv + vec2(1, 0)) *
|
|
20
|
-
vec4 s3 = texture(map, (uv + vec2(0, 1)) *
|
|
21
|
-
vec4 s4 = texture(map, (uv + vec2(1, 1)) *
|
|
18
|
+
vec4 s1 = texture(map, (uv + vec2(0, 0)) * pS);
|
|
19
|
+
vec4 s2 = texture(map, (uv + vec2(1, 0)) * pS);
|
|
20
|
+
vec4 s3 = texture(map, (uv + vec2(0, 1)) * pS);
|
|
21
|
+
vec4 s4 = texture(map, (uv + vec2(1, 1)) * pS);
|
|
22
22
|
|
|
23
23
|
return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y);
|
|
24
24
|
#endif
|
|
@@ -8,7 +8,7 @@ float phi = acos(n.y) / PI;
|
|
|
8
8
|
return vec2(theta, 1.0 - phi);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
vec2
|
|
11
|
+
vec2 iM(vec3 pos, vec3 normal, vec2 uvScale) {
|
|
12
12
|
vec3 dm = abs(normal);
|
|
13
13
|
vec2 uv = vec2(0.0);
|
|
14
14
|
if (dm.x > dm.y && dm.x > dm.z) {
|
|
@@ -53,18 +53,18 @@ return fract(uv * uvScale);
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
vec2
|
|
56
|
+
vec2 hz(vec3 pos, vec3 normal) {
|
|
57
57
|
float theta = atan(pos.z, pos.x) / (2.0 * PI) + 0.5;
|
|
58
58
|
return vec2(theta, pos.y);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
vec2
|
|
61
|
+
vec2 gC(int fh, vec3 pos, vec3 normal, vec2 uvScale) {
|
|
62
62
|
if (fh == ${uvProjectionConstants.triplanar + ''}) {
|
|
63
|
-
return
|
|
63
|
+
return iM(pos, normal, uvScale);
|
|
64
64
|
} else if (fh == ${uvProjectionConstants.spherical + ''}) {
|
|
65
65
|
return sphericalProjection(pos) * uvScale;
|
|
66
66
|
} else if (fh == ${uvProjectionConstants.cylindrical + ''}) {
|
|
67
|
-
return
|
|
67
|
+
return hz(pos, normal) * uvScale;
|
|
68
68
|
}
|
|
69
69
|
return vec2(0.0);
|
|
70
70
|
}
|
|
@@ -35,7 +35,7 @@ vec4 target = viewProjectionInv * vec4(uv * 2.0 - 1.0, 1.0, 1.0);
|
|
|
35
35
|
Ray ray;
|
|
36
36
|
iw(ray, origin.xyz / origin.w, normalize(target.xyz * origin.w - origin.xyz * target.w));
|
|
37
37
|
vec3 eye = viewInv[3].xyz;
|
|
38
|
-
vec3
|
|
38
|
+
vec3 nY = -normalize(viewInv[2].xyz);
|
|
39
39
|
ad si;
|
|
40
40
|
si.triangleIndex = -1;
|
|
41
41
|
for (int layer = 0; layer < 32; layer++) {
|
|
@@ -44,7 +44,7 @@ if (!si.hit) return;
|
|
|
44
44
|
J material;
|
|
45
45
|
eT(material, si.materialIndex, si.uv, si.uv1, si.instanceIndex);
|
|
46
46
|
if (material.materialType != SHADOW_CATCHER && material.alpha > 0.0) {
|
|
47
|
-
out_depth.r = max(dot(si.position - eye,
|
|
47
|
+
out_depth.r = max(dot(si.position - eye, nY), 0.0);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
ray.o = si.position + ray.d * (EPS * 0.02);
|
|
@@ -16,22 +16,22 @@ const normalizeRayTraceOutput = new FragmentShader({
|
|
|
16
16
|
main: glsl `
|
|
17
17
|
void main() {
|
|
18
18
|
vec2 uv = lightScale * v_Texcoord;
|
|
19
|
-
vec4
|
|
20
|
-
float hit =
|
|
21
|
-
vec4
|
|
19
|
+
vec4 rN = sample_albedoTex(uv);
|
|
20
|
+
float hit = rN.a;
|
|
21
|
+
vec4 rR = sample_normalTex(uv);
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
float
|
|
26
|
-
vec3 albedo =
|
|
27
|
-
vec3 normal =
|
|
25
|
+
float sh = max(rR.a, 1.0);
|
|
26
|
+
vec3 albedo = rN.rgb / sh;
|
|
27
|
+
vec3 normal = rR.rgb / sh;
|
|
28
28
|
vec4 shadowCatcher= sample_shadowCatcherTex(uv) / sampleCount;
|
|
29
|
-
vec4
|
|
29
|
+
vec4 sq = sample_colorTex(uv);
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
vec4 light = vec4(
|
|
34
|
+
vec4 light = vec4(sq.rgb / (hit > 0.0 ? hit : sampleCount), sq.a / sampleCount);
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|