rayzee 11.2.0 → 11.3.0
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/README.md +62 -33
- package/dist/ArchiveImporter-D735xX-4.js +7860 -0
- package/dist/BidirectionalIntegrator-M89c0AlP.js +954 -0
- package/dist/{BufferLayout-D_IBo2ci.js → BufferLayout-xPRH9jYD.js} +41 -5
- package/dist/{NeuralRetouch-DFGbnmLb.js → NeuralRetouch-DiBH63kz.js} +1 -1
- package/dist/{NeuralSuperRes-BtXvyJQl.js → NeuralSuperRes-CZNQP13W.js} +1 -1
- package/dist/{PathTracer-BHXGJtPN.js → PathTracer-BXCCVrPK.js} +4371 -4612
- package/dist/{PhysicalSky-DN6u8UX4.js → PhysicalSky-DqmaS0lb.js} +2 -2
- package/dist/{RayzeeRenderer-Dw1x8mVL.js → RayzeeRenderer-DUSMFhmc.js} +426 -363
- package/dist/SolarLimb-bZE6y63S.js +762 -0
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/rayzee-core.es.js +7 -7
- package/dist/rayzee.es.js +472 -468
- package/dist/rayzee.umd.js +106 -105
- package/dist/sceneCachePolicy-BAib5fCp.js +1602 -0
- package/package.json +1 -1
- package/src/EngineDefaults.js +1 -1
- package/src/PathTracerApp.js +4 -3
- package/src/Processor/ArchiveImporter.js +173 -94
- package/src/Processor/ArchiveReader.js +20 -23
- package/src/Processor/AssetLoader.js +48 -1
- package/src/Processor/BVHRefitter.js +109 -13
- package/src/Processor/BufferLayout.js +115 -0
- package/src/Processor/ChunkedRecords.js +3 -2
- package/src/Processor/EmissiveTriangleBuilder.js +6 -6
- package/src/Processor/GeometryExtractor.js +189 -79
- package/src/Processor/HostMemory.js +39 -9
- package/src/Processor/InstanceTable.js +714 -42
- package/src/Processor/PBRT/PBRTCurves.js +224 -6
- package/src/Processor/PBRT/PBRTMaterials.js +3 -0
- package/src/Processor/PBRT/PBRTSceneBuilder.js +82 -25
- package/src/Processor/PackedRayBuffer.js +5 -2
- package/src/Processor/SceneProcessor.js +747 -141
- package/src/Processor/TLASBuilder.js +32 -17
- package/src/Processor/USD/USDLayer.js +1149 -0
- package/src/Processor/USD/USDScene.js +1655 -0
- package/src/Processor/USD/USDStage.js +682 -0
- package/src/Processor/USD/USDText.js +674 -0
- package/src/Processor/USD/index.js +138 -0
- package/src/Processor/Workers/BVHRefitWorker.js +3 -3
- package/src/RayzeeRenderer.js +168 -27
- package/src/Stages/NormalDepth.js +7 -12
- package/src/Stages/PathTracer.js +12 -17
- package/src/Stages/PathTracerStage.js +273 -96
- package/src/Storage/GeometrySpill.js +46 -14
- package/src/Storage/SceneGraphCodec.js +17 -3
- package/src/Storage/SpillStore.js +9 -0
- package/src/TSL/BVHTraversal.js +183 -7
- package/src/TSL/Common.js +57 -13
- package/src/TSL/ShadeKernel.js +3 -2
- package/src/TSL/TextureSampling.js +11 -8
- package/src/TSL/patches.js +84 -0
- package/src/integrators/BidirectionalIntegrator.js +20 -2
- package/src/managers/DenoisingManager.js +4 -4
- package/src/managers/InteractionManager.js +19 -6
- package/src/managers/MaterialDataManager.js +22 -5
- package/src/managers/UniformManager.js +3 -0
- package/dist/ArchiveImporter-eNlu0_6F.js +0 -5198
- package/dist/BidirectionalIntegrator-D1-6UySB.js +0 -946
- package/dist/SolarLimb-CPaeZVwz.js +0 -721
- package/dist/sceneCachePolicy-DA7iGoL4.js +0 -485
|
@@ -1,721 +0,0 @@
|
|
|
1
|
-
import { i as e, r as t } from "./Logger-dDDGj9Av.js";
|
|
2
|
-
import { i as n } from "./BufferLayout-D_IBo2ci.js";
|
|
3
|
-
import { ContextNode as r, StorageInstancedBufferAttribute as i, WebGPUBackend as a } from "three/webgpu";
|
|
4
|
-
import { Fn as o, If as s, bool as c, clamp as l, dot as u, exp2 as d, float as f, floatBitsToUint as p, floor as m, int as h, log2 as g, mat3 as _, max as v, packSnorm2x16 as ee, packUnorm2x16 as y, select as b, storage as x, struct as te, uint as S, uintBitsToFloat as C, unpackSnorm2x16 as w, unpackUnorm2x16 as T, uvec4 as E, vec2 as D, vec3 as O, vec4 as k, wgslFn as A } from "three/tsl";
|
|
5
|
-
//#region src/TSL/patches.js
|
|
6
|
-
var ne = a.prototype.createNodeBuilder;
|
|
7
|
-
a.prototype.createNodeBuilder = function(e, t) {
|
|
8
|
-
let n = ne.call(this, e, t);
|
|
9
|
-
return Object.defineProperty(n, "allowGlobalVariables", {
|
|
10
|
-
get() {
|
|
11
|
-
return this.material !== null;
|
|
12
|
-
},
|
|
13
|
-
set() {},
|
|
14
|
-
configurable: !0
|
|
15
|
-
}), n;
|
|
16
|
-
};
|
|
17
|
-
function j(e, t, n = Float32Array) {
|
|
18
|
-
let r = new i(new n(0), t);
|
|
19
|
-
return r.count = e, r.gpuByteLength = e * t * n.BYTES_PER_ELEMENT, r.isGPUOnly = !0, r;
|
|
20
|
-
}
|
|
21
|
-
var M = a.prototype.createStorageAttribute;
|
|
22
|
-
a.prototype.createStorageAttribute = function(e) {
|
|
23
|
-
let t = this.attributeUtils._getBufferAttribute(e);
|
|
24
|
-
if (!t.isGPUOnly) return M.call(this, e);
|
|
25
|
-
let n = this.get(t);
|
|
26
|
-
n.buffer === void 0 && (n.buffer = this.device.createBuffer({
|
|
27
|
-
label: t.name,
|
|
28
|
-
size: t.gpuByteLength,
|
|
29
|
-
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST
|
|
30
|
-
}));
|
|
31
|
-
};
|
|
32
|
-
function N(e, t, n) {
|
|
33
|
-
let r = e.backend;
|
|
34
|
-
r.createStorageAttribute(t);
|
|
35
|
-
let i = r.get(t).buffer, a = 0;
|
|
36
|
-
for (let e of n) r.device.queue.writeBuffer(i, a, e, 0, e.length), a += e.byteLength;
|
|
37
|
-
if (a !== t.gpuByteLength) throw RangeError(`uploadStorageChunks wrote ${a} bytes into a ${t.gpuByteLength}-byte buffer`);
|
|
38
|
-
}
|
|
39
|
-
function P(e, t, n, r, i) {
|
|
40
|
-
let a = e.backend;
|
|
41
|
-
a.createStorageAttribute(t);
|
|
42
|
-
let o = a.get(t).buffer, s = n.recordsPerChunk * n.lanesPerRecord, c = n.chunks[0].BYTES_PER_ELEMENT, l = r + i, u = r;
|
|
43
|
-
for (; u < l;) {
|
|
44
|
-
let e = Math.floor(u / s), t = n.chunks[e], r = u - e * s, i = Math.min(t.length - r, l - u);
|
|
45
|
-
a.device.queue.writeBuffer(o, u * c, t, r, i), u += i;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
var F = a.prototype.updateAttribute;
|
|
49
|
-
a.prototype.updateAttribute = function(e) {
|
|
50
|
-
if (!this.attributeUtils._getBufferAttribute(e).isGPUOnly) return F.call(this, e);
|
|
51
|
-
};
|
|
52
|
-
var I = 4096;
|
|
53
|
-
function re(e) {
|
|
54
|
-
if (!this.trackTimestamp || this.isDisposed || this.currentQueryIndex + 2 > this.maxQueries) return null;
|
|
55
|
-
let t = this.currentQueryIndex;
|
|
56
|
-
return this.currentQueryIndex += 2, this.queryOffsets.set(e, t), t;
|
|
57
|
-
}
|
|
58
|
-
var ie = a.prototype.initTimestampQuery;
|
|
59
|
-
a.prototype.initTimestampQuery = function(e, t, n) {
|
|
60
|
-
let r = this.trackTimestamp && !this.timestampQueryPool[e];
|
|
61
|
-
if (ie.call(this, e, t, n), r) {
|
|
62
|
-
let r = this.timestampQueryPool[e];
|
|
63
|
-
if (r && r.maxQueries < I && n.timestampWrites) {
|
|
64
|
-
let i = r.constructor, a = new i(this.device, e, I);
|
|
65
|
-
a.allocateQueriesForContext = re, a.allocateQueriesForContext(t), this.timestampQueryPool[e] = a, n.timestampWrites.querySet = a.querySet, r.dispose();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
let i = n.timestampWrites;
|
|
69
|
-
i && i.beginningOfPassWriteIndex == null && (n.timestampWrites = void 0);
|
|
70
|
-
};
|
|
71
|
-
function L(e, t) {
|
|
72
|
-
return new Proxy(e, { get(e, n, r) {
|
|
73
|
-
if (typeof n == "string" && t.has(n)) return e.get(n);
|
|
74
|
-
let i = Reflect.get(e, n, r);
|
|
75
|
-
return n === "toVar" && typeof i == "function" ? (...n) => L(i.apply(e, n), t) : i;
|
|
76
|
-
} });
|
|
77
|
-
}
|
|
78
|
-
function R(e, t = null) {
|
|
79
|
-
let n = te(e, t), r = new Set(Object.keys(e)), i = (...e) => L(n(...e), r);
|
|
80
|
-
return i.layout = n.layout, i.isStruct = !0, i.wrap = (e) => L(e, r), i;
|
|
81
|
-
}
|
|
82
|
-
r.prototype.setup = function(e) {
|
|
83
|
-
let t = e.addContext(this.value);
|
|
84
|
-
this.node.build(e), e.setContext(t);
|
|
85
|
-
};
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/TSL/Struct.js
|
|
88
|
-
var ae = R({
|
|
89
|
-
origin: "vec3",
|
|
90
|
-
direction: "vec3"
|
|
91
|
-
}), z = R({
|
|
92
|
-
color: "vec4",
|
|
93
|
-
emissive: "vec3",
|
|
94
|
-
emissiveIntensity: "float",
|
|
95
|
-
roughness: "float",
|
|
96
|
-
metalness: "float",
|
|
97
|
-
ior: "float",
|
|
98
|
-
transmission: "float",
|
|
99
|
-
thickness: "float",
|
|
100
|
-
clearcoat: "float",
|
|
101
|
-
clearcoatRoughness: "float",
|
|
102
|
-
opacity: "float",
|
|
103
|
-
transparent: "bool",
|
|
104
|
-
attenuationColor: "vec3",
|
|
105
|
-
attenuationDistance: "float",
|
|
106
|
-
dispersion: "float",
|
|
107
|
-
sheen: "float",
|
|
108
|
-
sheenRoughness: "float",
|
|
109
|
-
sheenColor: "vec3",
|
|
110
|
-
specularIntensity: "float",
|
|
111
|
-
specularColor: "vec3",
|
|
112
|
-
alphaTest: "float",
|
|
113
|
-
alphaMode: "int",
|
|
114
|
-
side: "int",
|
|
115
|
-
depthWrite: "int",
|
|
116
|
-
albedoMapIndex: "int",
|
|
117
|
-
emissiveMapIndex: "int",
|
|
118
|
-
normalMapIndex: "int",
|
|
119
|
-
bumpMapIndex: "int",
|
|
120
|
-
bumpScale: "float",
|
|
121
|
-
displacementScale: "float",
|
|
122
|
-
metalnessMapIndex: "int",
|
|
123
|
-
roughnessMapIndex: "int",
|
|
124
|
-
displacementMapIndex: "int",
|
|
125
|
-
normalScale: "vec2",
|
|
126
|
-
albedoTransform: "mat3",
|
|
127
|
-
emissiveTransform: "mat3",
|
|
128
|
-
normalTransform: "mat3",
|
|
129
|
-
bumpTransform: "mat3",
|
|
130
|
-
metalnessTransform: "mat3",
|
|
131
|
-
roughnessTransform: "mat3",
|
|
132
|
-
displacementTransform: "mat3",
|
|
133
|
-
iridescence: "float",
|
|
134
|
-
iridescenceIOR: "float",
|
|
135
|
-
iridescenceThicknessRange: "vec2",
|
|
136
|
-
subsurface: "float",
|
|
137
|
-
subsurfaceColor: "vec3",
|
|
138
|
-
subsurfaceRadius: "vec3",
|
|
139
|
-
subsurfaceRadiusScale: "float",
|
|
140
|
-
subsurfaceAnisotropy: "float",
|
|
141
|
-
anisotropy: "float",
|
|
142
|
-
anisotropyRotation: "float",
|
|
143
|
-
anisotropyMapIndex: "int",
|
|
144
|
-
transmissionMapIndex: "int",
|
|
145
|
-
clearcoatMapIndex: "int",
|
|
146
|
-
clearcoatRoughnessMapIndex: "int",
|
|
147
|
-
sheenColorMapIndex: "int",
|
|
148
|
-
sheenRoughnessMapIndex: "int",
|
|
149
|
-
iridescenceMapIndex: "int",
|
|
150
|
-
iridescenceThicknessMapIndex: "int",
|
|
151
|
-
specularIntensityMapIndex: "int",
|
|
152
|
-
specularColorMapIndex: "int",
|
|
153
|
-
diffuseTransmission: "float",
|
|
154
|
-
diffuseTransmissionColor: "vec3",
|
|
155
|
-
diffuseTransmissionMapIndex: "int",
|
|
156
|
-
diffuseTransmissionColorMapIndex: "int"
|
|
157
|
-
}), oe = R({
|
|
158
|
-
transmission: "float",
|
|
159
|
-
clearcoat: "float",
|
|
160
|
-
clearcoatRoughness: "float",
|
|
161
|
-
sheenColor: "vec3",
|
|
162
|
-
sheenRoughness: "float",
|
|
163
|
-
iridescence: "float",
|
|
164
|
-
iridescenceThickness: "float",
|
|
165
|
-
specularIntensity: "float",
|
|
166
|
-
specularColor: "vec3",
|
|
167
|
-
diffuseTransmission: "float",
|
|
168
|
-
diffuseTransmissionColor: "vec3"
|
|
169
|
-
}), se = R({
|
|
170
|
-
color: "vec4",
|
|
171
|
-
ior: "float",
|
|
172
|
-
transmission: "float",
|
|
173
|
-
attenuationColor: "vec3",
|
|
174
|
-
attenuationDistance: "float",
|
|
175
|
-
albedoMapIndex: "int",
|
|
176
|
-
opacity: "float",
|
|
177
|
-
transparent: "bool",
|
|
178
|
-
alphaTest: "float",
|
|
179
|
-
alphaMode: "int",
|
|
180
|
-
albedoTransform: "mat3"
|
|
181
|
-
}), ce = R({
|
|
182
|
-
shadowed: "vec3",
|
|
183
|
-
unoccluded: "vec3"
|
|
184
|
-
});
|
|
185
|
-
R({
|
|
186
|
-
position: "vec3",
|
|
187
|
-
radius: "float",
|
|
188
|
-
material: z
|
|
189
|
-
});
|
|
190
|
-
var le = R({
|
|
191
|
-
didHit: "bool",
|
|
192
|
-
dst: "float",
|
|
193
|
-
hitPoint: "vec3",
|
|
194
|
-
normal: "vec3",
|
|
195
|
-
uv: "vec2",
|
|
196
|
-
materialIndex: "int",
|
|
197
|
-
meshIndex: "int",
|
|
198
|
-
instanceLeaf: "int",
|
|
199
|
-
triangleIndex: "int",
|
|
200
|
-
boxTests: "int",
|
|
201
|
-
triTests: "int"
|
|
202
|
-
});
|
|
203
|
-
R({
|
|
204
|
-
posA: "vec3",
|
|
205
|
-
posB: "vec3",
|
|
206
|
-
posC: "vec3",
|
|
207
|
-
uvA: "vec2",
|
|
208
|
-
uvB: "vec2",
|
|
209
|
-
uvC: "vec2",
|
|
210
|
-
normalA: "vec3",
|
|
211
|
-
normalB: "vec3",
|
|
212
|
-
normalC: "vec3",
|
|
213
|
-
material: z,
|
|
214
|
-
materialIndex: "int",
|
|
215
|
-
meshIndex: "int"
|
|
216
|
-
}), R({
|
|
217
|
-
color: "vec4",
|
|
218
|
-
samples: "int"
|
|
219
|
-
});
|
|
220
|
-
var ue = R({
|
|
221
|
-
direction: "vec3",
|
|
222
|
-
value: "vec3",
|
|
223
|
-
pdf: "float",
|
|
224
|
-
isTransmission: "bool",
|
|
225
|
-
colorWeight: "vec3",
|
|
226
|
-
isDiffuseTransmission: "bool"
|
|
227
|
-
}), de = R({
|
|
228
|
-
specular: "float",
|
|
229
|
-
diffuse: "float",
|
|
230
|
-
sheen: "float",
|
|
231
|
-
clearcoat: "float",
|
|
232
|
-
transmission: "float",
|
|
233
|
-
iridescence: "float",
|
|
234
|
-
diffuseTransmission: "float"
|
|
235
|
-
}), B = R({
|
|
236
|
-
Ta: "vec3",
|
|
237
|
-
Ba: "vec3"
|
|
238
|
-
}), V = R({
|
|
239
|
-
NoL: "float",
|
|
240
|
-
NoV: "float",
|
|
241
|
-
NoH: "float",
|
|
242
|
-
VoH: "float",
|
|
243
|
-
LoH: "float",
|
|
244
|
-
ToH: "float",
|
|
245
|
-
BoH: "float",
|
|
246
|
-
ToV: "float",
|
|
247
|
-
BoV: "float",
|
|
248
|
-
ToL: "float",
|
|
249
|
-
BoL: "float"
|
|
250
|
-
}), fe = R({
|
|
251
|
-
compensation: "vec3",
|
|
252
|
-
E_total: "vec3"
|
|
253
|
-
}), pe = R({
|
|
254
|
-
f0: "vec3",
|
|
255
|
-
f90: "float",
|
|
256
|
-
eta: "float",
|
|
257
|
-
F0m: "vec3",
|
|
258
|
-
F0: "vec3"
|
|
259
|
-
}), me = R({
|
|
260
|
-
albedo: "vec4",
|
|
261
|
-
emissive: "vec3",
|
|
262
|
-
metalness: "float",
|
|
263
|
-
roughness: "float",
|
|
264
|
-
normal: "vec3",
|
|
265
|
-
hasTextures: "bool"
|
|
266
|
-
}), he = R({
|
|
267
|
-
isMetallic: "bool",
|
|
268
|
-
isRough: "bool",
|
|
269
|
-
isSmooth: "bool",
|
|
270
|
-
isTransmissive: "bool",
|
|
271
|
-
hasClearcoat: "bool",
|
|
272
|
-
isEmissive: "bool",
|
|
273
|
-
complexityScore: "float"
|
|
274
|
-
}), ge = R({
|
|
275
|
-
albedoUV: "vec2",
|
|
276
|
-
normalUV: "vec2",
|
|
277
|
-
metalnessUV: "vec2",
|
|
278
|
-
emissiveUV: "vec2",
|
|
279
|
-
bumpUV: "vec2",
|
|
280
|
-
roughnessUV: "vec2",
|
|
281
|
-
normalBumpSameUV: "bool",
|
|
282
|
-
metalRoughSameUV: "bool",
|
|
283
|
-
albedoEmissiveSameUV: "bool",
|
|
284
|
-
allSameUV: "bool"
|
|
285
|
-
}), _e = R({
|
|
286
|
-
invRoughness: "float",
|
|
287
|
-
metalFactor: "float",
|
|
288
|
-
iorFactor: "float",
|
|
289
|
-
maxSheenColor: "float"
|
|
290
|
-
});
|
|
291
|
-
R({
|
|
292
|
-
traversals: "int",
|
|
293
|
-
transmissiveTraversals: "int",
|
|
294
|
-
rayType: "int",
|
|
295
|
-
isPrimaryRay: "bool",
|
|
296
|
-
actualBounceDepth: "int"
|
|
297
|
-
});
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/TSL/Common.js
|
|
300
|
-
var ve = /* @__PURE__ */ A("\n fn offsetRayOrigin( p: vec3f, n: vec3f ) -> vec3f {\n let step = select( vec3<i32>( 32 ), vec3<i32>( -32 ), ( p < vec3f( 0.0 ) ) != ( n < vec3f( 0.0 ) ) );\n let far = bitcast<vec3f>( bitcast<vec3<i32>>( p ) + step );\n return select( far, p + n * 1e-5, abs( p ) < vec3f( 1.0 ) );\n }\n"), ye = .9999, H = 3.14159, be = 1 / H, xe = 2 * H, U = 1e-6, Se = .05, Ce = .089, we = .001, Te = O(.2126, .7152, .0722), Ee = 65504, W = (e, t = 1e7) => b(e.equal(e), e, f(0)).clamp(0, t), De = (e, t = 1e7) => O(W(e.x, t), W(e.y, t), W(e.z, t)), G = n.SLOTS_PER_MATERIAL, Oe = n.SLOT, K = Oe, ke = _(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252);
|
|
301
|
-
A("\n fn sRGBToLinear( srgbColor: vec3f ) -> vec3f {\n\n return pow( srgbColor, vec3f( 2.2 ) );\n\n }\n"), A("\n fn gammaCorrection( color: vec3f ) -> vec3f {\n\n return pow( color, vec3f( 1.0 / 2.2 ) );\n\n }\n");
|
|
302
|
-
var Ae = A("\n fn square( x: f32 ) -> f32 {\n\n return x * x;\n\n }\n");
|
|
303
|
-
A("\n fn squareVec3( x: vec3f ) -> vec3f {\n\n return x * x;\n\n }\n"), A("\n fn maxComponent( v: vec3f ) -> f32 {\n\n return max( max( v.r, v.g ), v.b );\n\n }\n"), A("\n fn minComponent( v: vec3f ) -> f32 {\n\n return min( min( v.r, v.g ), v.b );\n\n }\n");
|
|
304
|
-
var je = A("\n fn luminance( color: vec3f ) -> f32 {\n\n return dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );\n\n }\n"), Me = A(`
|
|
305
|
-
fn powerHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
|
|
306
|
-
|
|
307
|
-
let p1 = pdf1 * pdf1;
|
|
308
|
-
let p2 = pdf2 * pdf2;
|
|
309
|
-
return p1 / max( p1 + p2, ${we} );
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
`), Ne = A(`
|
|
313
|
-
fn balanceHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
|
|
314
|
-
|
|
315
|
-
return pdf1 / max( pdf1 + pdf2, ${we} );
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
`);
|
|
319
|
-
A("\n fn applyDithering( color: vec3f, uv: vec2f, ditheringAmount: f32, resolution: vec2f ) -> vec3f {\n\n let bayerRow0 = vec4f( 0.0 / 16.0, 8.0 / 16.0, 2.0 / 16.0, 10.0 / 16.0 );\n let bayerRow1 = vec4f( 12.0 / 16.0, 4.0 / 16.0, 14.0 / 16.0, 6.0 / 16.0 );\n let bayerRow2 = vec4f( 3.0 / 16.0, 11.0 / 16.0, 1.0 / 16.0, 9.0 / 16.0 );\n let bayerRow3 = vec4f( 15.0 / 16.0, 7.0 / 16.0, 13.0 / 16.0, 5.0 / 16.0 );\n let bayer = mat4x4f( bayerRow0, bayerRow1, bayerRow2, bayerRow3 );\n\n let pixelCoord = vec2i( uv * resolution );\n let dither = bayer[ pixelCoord.x % 4 ][ pixelCoord.y % 4 ];\n\n return color + ( dither - 0.5 ) * ditheringAmount / 255.0;\n\n }\n");
|
|
320
|
-
var Pe = A("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3f;\n if ( abs( N.x ) < 0.999 ) {\n majorAxis = vec3f( 1.0, 0.0, 0.0 );\n } else {\n majorAxis = vec3f( 0.0, 1.0, 0.0 );\n }\n let T = normalize( cross( N, majorAxis ) );\n let B = normalize( cross( N, T ) );\n return mat3x3f( T, B, N );\n\n }\n");
|
|
321
|
-
o(([e, t, n]) => {
|
|
322
|
-
let r = t.add(n).toVar(), i = u(r, r).toVar();
|
|
323
|
-
return r.assign(i.greaterThan(U).select(r.div(i.sqrt()), O(0, 0, 1))), V({
|
|
324
|
-
NoL: v(u(e, n), .001),
|
|
325
|
-
NoV: v(u(e, t), .001),
|
|
326
|
-
NoH: v(u(e, r), .001),
|
|
327
|
-
VoH: v(u(t, r), .001),
|
|
328
|
-
LoH: v(u(n, r), .001),
|
|
329
|
-
ToH: f(0),
|
|
330
|
-
BoH: f(0),
|
|
331
|
-
ToV: f(0),
|
|
332
|
-
BoV: f(0),
|
|
333
|
-
ToL: f(0),
|
|
334
|
-
BoL: f(0)
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
var Fe = o(([e, t]) => {
|
|
338
|
-
let n = e.x.abs().lessThan(.999).select(O(1, 0, 0), O(0, 1, 0)), r = e.cross(n).normalize(), i = e.cross(r).normalize(), a = t.cos(), o = t.sin();
|
|
339
|
-
return B({
|
|
340
|
-
Ta: r.mul(a).add(i.mul(o)),
|
|
341
|
-
Ba: i.mul(a).sub(r.mul(o))
|
|
342
|
-
});
|
|
343
|
-
}), Ie = o(([e, t, n, r]) => {
|
|
344
|
-
let i = t.add(n).toVar(), a = u(i, i).toVar();
|
|
345
|
-
i.assign(a.greaterThan(U).select(i.div(a.sqrt()), O(0, 0, 1)));
|
|
346
|
-
let o = f(0).toVar(), c = f(0).toVar(), l = f(0).toVar(), d = f(0).toVar(), p = f(0).toVar(), m = f(0).toVar();
|
|
347
|
-
return s(r.anisotropy.greaterThan(0), () => {
|
|
348
|
-
let a = B.wrap(Fe(e, r.anisotropyRotation));
|
|
349
|
-
o.assign(u(a.Ta, i)), c.assign(u(a.Ba, i)), l.assign(u(a.Ta, t)), d.assign(u(a.Ba, t)), p.assign(u(a.Ta, n)), m.assign(u(a.Ba, n));
|
|
350
|
-
}), V({
|
|
351
|
-
NoL: v(u(e, n), .001),
|
|
352
|
-
NoV: v(u(e, t), .001),
|
|
353
|
-
NoH: v(u(e, i), .001),
|
|
354
|
-
VoH: v(u(t, i), .001),
|
|
355
|
-
LoH: v(u(n, i), .001),
|
|
356
|
-
ToH: o,
|
|
357
|
-
BoH: c,
|
|
358
|
-
ToV: l,
|
|
359
|
-
BoV: d,
|
|
360
|
-
ToL: p,
|
|
361
|
-
BoL: m
|
|
362
|
-
});
|
|
363
|
-
}), Le = A("\n fn calculateFireflyThreshold( baseThreshold: f32, bounceIndex: i32, frame: i32 ) -> f32 {\n\n let depthFactor = 1.0 / ( 1.0 + f32( bounceIndex ) * 0.1 );\n let relaxation = sqrt( f32( frame + 1 ) );\n return baseThreshold * depthFactor * relaxation;\n\n }\n"), Re = A("\n fn applySoftSuppression( value: f32, threshold: f32, dampingFactor: f32 ) -> f32 {\n\n if ( value <= threshold ) {\n return value;\n }\n let excess = value - threshold;\n let suppressionFactor = threshold / ( threshold + excess * dampingFactor );\n return value * suppressionFactor;\n\n }\n"), ze = A(`
|
|
364
|
-
fn applySoftSuppressionRGB( color: vec3f, threshold: f32, dampingFactor: f32 ) -> vec3f {
|
|
365
|
-
|
|
366
|
-
let lum = dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );
|
|
367
|
-
if ( lum <= threshold ) {
|
|
368
|
-
return color;
|
|
369
|
-
}
|
|
370
|
-
let suppressedLum = applySoftSuppression( lum, threshold, dampingFactor );
|
|
371
|
-
if ( lum > ${U} ) {
|
|
372
|
-
return color * ( suppressedLum / lum );
|
|
373
|
-
}
|
|
374
|
-
return color;
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
`, [Re]), Be = o(([e, t, n, r, i, a]) => {
|
|
378
|
-
let o = e.greaterThan(.7).toVar(), c = t.greaterThan(.8), u = t.lessThan(.3).toVar(), d = n.greaterThan(.5).toVar(), p = r.greaterThan(.5).toVar(), m = a.greaterThan(0), h = i.x.add(i.y).add(i.z).greaterThan(0).toVar(), g = f(.15).mul(f(o)).add(f(.25).mul(f(u))).add(f(.45).mul(f(d))).add(f(.35).mul(f(p))).add(f(.3).mul(f(h))).add(f(.4).mul(f(m))), _ = f(0).toVar();
|
|
379
|
-
return s(o.and(u), () => {
|
|
380
|
-
_.addAssign(.15);
|
|
381
|
-
}), s(d.and(p), () => {
|
|
382
|
-
_.addAssign(.2);
|
|
383
|
-
}), s(h.and(d.or(o)), () => {
|
|
384
|
-
_.addAssign(.1);
|
|
385
|
-
}), he({
|
|
386
|
-
isMetallic: o,
|
|
387
|
-
isRough: c,
|
|
388
|
-
isSmooth: u,
|
|
389
|
-
isTransmissive: d,
|
|
390
|
-
hasClearcoat: p,
|
|
391
|
-
isEmissive: h,
|
|
392
|
-
complexityScore: l(g.add(_), 0, 1)
|
|
393
|
-
});
|
|
394
|
-
}), q = o(([e, t, n, r]) => {
|
|
395
|
-
let i = t.mul(r).add(n);
|
|
396
|
-
return e.element(i);
|
|
397
|
-
}), Ve = (e, t, n) => n < 3 ? q(e.geo, t, h(n), h(3)) : q(e.shade, t, h(n - 3), h(2)), J = /* @__PURE__ */ A("\n fn packNormalOct( n: vec3f ) -> u32 {\n\n let s = abs( n.x ) + abs( n.y ) + abs( n.z );\n var p = n.xy / max( s, 1e-20 );\n\n if ( n.z < 0.0 ) {\n\n let px = ( 1.0 - abs( p.y ) ) * select( -1.0, 1.0, p.x >= 0.0 );\n let py = ( 1.0 - abs( p.x ) ) * select( -1.0, 1.0, p.y >= 0.0 );\n p = vec2f( px, py );\n\n }\n\n return pack2x16snorm( p );\n\n }\n"), Y = /* @__PURE__ */ A("\n fn unpackTriangleNormal( packed: u32 ) -> vec3f {\n\n let e = unpack2x16snorm( packed );\n var nx = e.x;\n var ny = e.y;\n let nz = 1.0 - abs( e.x ) - abs( e.y );\n\n if ( nz < 0.0 ) {\n\n let tx = ( 1.0 - abs( ny ) ) * select( -1.0, 1.0, nx >= 0.0 );\n let ty = ( 1.0 - abs( nx ) ) * select( -1.0, 1.0, ny >= 0.0 );\n nx = tx;\n ny = ty;\n\n }\n\n return normalize( vec3f( nx, ny, nz ) );\n\n }\n"), X = A("\n fn arrayToMat3( data1: vec4f, data2: vec4f ) -> mat3x3f {\n\n return mat3x3f(\n data1.xyz,\n vec3f( data1.w, data2.xy ),\n vec3f( data2.zw, 1.0 )\n );\n\n }\n"), He = o(([e, t]) => {
|
|
398
|
-
let n = q(t, e, h(K.COLOR_METALNESS), h(G)).toVar(), r = q(t, e, h(K.EMISSIVE_ROUGHNESS), h(G)).toVar(), i = q(t, e, h(K.IOR_TRANSMISSION), h(G)).toVar(), a = q(t, e, h(K.ATTENUATION), h(G)).toVar(), o = q(t, e, h(K.DISPERSION_SHEEN), h(G)).toVar(), c = q(t, e, h(K.SHEEN_COLOR), h(G)).toVar(), l = q(t, e, h(K.SPECULAR), h(G)).toVar(), u = q(t, e, h(K.IRIDESCENCE), h(G)).toVar(), d = q(t, e, h(K.MAP_INDICES_A), h(G)).toVar(), f = q(t, e, h(K.MAP_INDICES_B), h(G)).toVar(), p = q(t, e, h(K.OPACITY_ALPHA), h(G)).toVar(), m = q(t, e, h(K.ALPHA_MODE), h(G)).toVar(), g = q(t, e, h(K.BUMP_DISPLACEMENT), h(G)).toVar(), _ = q(t, e, h(K.ALBEDO_TRANSFORM_A), h(G)).toVar(), v = q(t, e, h(K.ALBEDO_TRANSFORM_B), h(G)).toVar(), ee = q(t, e, h(K.NORMAL_TRANSFORM_A), h(G)).toVar(), y = q(t, e, h(K.NORMAL_TRANSFORM_B), h(G)).toVar(), b = q(t, e, h(K.ROUGHNESS_TRANSFORM_A), h(G)).toVar(), x = q(t, e, h(K.ROUGHNESS_TRANSFORM_B), h(G)).toVar(), te = q(t, e, h(K.METALNESS_TRANSFORM_A), h(G)).toVar(), S = q(t, e, h(K.METALNESS_TRANSFORM_B), h(G)).toVar(), C = q(t, e, h(K.EMISSIVE_TRANSFORM_A), h(G)).toVar(), w = q(t, e, h(K.EMISSIVE_TRANSFORM_B), h(G)).toVar(), T = q(t, e, h(K.BUMP_TRANSFORM_A), h(G)).toVar(), E = q(t, e, h(K.BUMP_TRANSFORM_B), h(G)).toVar(), O = q(t, e, h(K.DISPLACEMENT_TRANSFORM_A), h(G)).toVar(), A = q(t, e, h(K.DISPLACEMENT_TRANSFORM_B), h(G)).toVar(), ne = q(t, e, h(K.SUBSURFACE_A), h(G)).toVar(), j = q(t, e, h(K.SUBSURFACE_B), h(G)).toVar(), M = q(t, e, h(K.SUBSURFACE_C), h(G)).toVar(), N = q(t, e, h(K.EXT_MAP_INDICES_A), h(G)).toVar(), P = q(t, e, h(K.EXT_MAP_INDICES_B), h(G)).toVar(), F = q(t, e, h(K.EXT_MAP_INDICES_C), h(G)).toVar(), I = k(-1, -1, 0, 0).toVar();
|
|
399
|
-
return s(c.a.greaterThan(0), () => {
|
|
400
|
-
I.assign(q(t, e, h(K.EXT_MAP_INDICES_D), h(G)));
|
|
401
|
-
}), z({
|
|
402
|
-
color: k(n.rgb, 1),
|
|
403
|
-
metalness: n.a,
|
|
404
|
-
emissive: r.rgb,
|
|
405
|
-
roughness: r.a,
|
|
406
|
-
ior: i.r,
|
|
407
|
-
transmission: i.g,
|
|
408
|
-
thickness: i.b,
|
|
409
|
-
emissiveIntensity: i.a,
|
|
410
|
-
attenuationColor: a.rgb,
|
|
411
|
-
attenuationDistance: a.a,
|
|
412
|
-
dispersion: o.r,
|
|
413
|
-
sheen: o.b,
|
|
414
|
-
sheenRoughness: o.a,
|
|
415
|
-
sheenColor: c.rgb,
|
|
416
|
-
specularIntensity: l.r,
|
|
417
|
-
specularColor: l.gba,
|
|
418
|
-
iridescence: u.r,
|
|
419
|
-
iridescenceIOR: u.g,
|
|
420
|
-
iridescenceThicknessRange: u.ba,
|
|
421
|
-
subsurfaceColor: ne.rgb,
|
|
422
|
-
subsurface: ne.a,
|
|
423
|
-
subsurfaceRadius: j.rgb,
|
|
424
|
-
subsurfaceRadiusScale: j.a,
|
|
425
|
-
subsurfaceAnisotropy: M.r,
|
|
426
|
-
anisotropy: M.g,
|
|
427
|
-
anisotropyRotation: M.b,
|
|
428
|
-
anisotropyMapIndex: h(M.a),
|
|
429
|
-
transmissionMapIndex: h(N.r),
|
|
430
|
-
clearcoatMapIndex: h(N.g),
|
|
431
|
-
clearcoatRoughnessMapIndex: h(N.b),
|
|
432
|
-
sheenColorMapIndex: h(N.a),
|
|
433
|
-
sheenRoughnessMapIndex: h(P.r),
|
|
434
|
-
iridescenceMapIndex: h(P.g),
|
|
435
|
-
iridescenceThicknessMapIndex: h(P.b),
|
|
436
|
-
specularIntensityMapIndex: h(P.a),
|
|
437
|
-
specularColorMapIndex: h(F.r),
|
|
438
|
-
diffuseTransmission: c.a,
|
|
439
|
-
diffuseTransmissionColor: F.gba,
|
|
440
|
-
diffuseTransmissionMapIndex: h(I.r),
|
|
441
|
-
diffuseTransmissionColorMapIndex: h(I.g),
|
|
442
|
-
albedoMapIndex: h(d.r),
|
|
443
|
-
normalMapIndex: h(d.g),
|
|
444
|
-
roughnessMapIndex: h(d.b),
|
|
445
|
-
metalnessMapIndex: h(d.a),
|
|
446
|
-
emissiveMapIndex: h(f.r),
|
|
447
|
-
bumpMapIndex: h(f.g),
|
|
448
|
-
clearcoat: f.b,
|
|
449
|
-
clearcoatRoughness: f.a,
|
|
450
|
-
opacity: p.r,
|
|
451
|
-
side: h(p.g),
|
|
452
|
-
transparent: p.b,
|
|
453
|
-
alphaTest: p.a,
|
|
454
|
-
alphaMode: h(m.r),
|
|
455
|
-
depthWrite: h(m.g),
|
|
456
|
-
normalScale: D(m.b, m.b),
|
|
457
|
-
bumpScale: g.r,
|
|
458
|
-
displacementScale: g.g,
|
|
459
|
-
displacementMapIndex: h(g.b),
|
|
460
|
-
albedoTransform: X({
|
|
461
|
-
data1: _,
|
|
462
|
-
data2: v
|
|
463
|
-
}),
|
|
464
|
-
normalTransform: X({
|
|
465
|
-
data1: ee,
|
|
466
|
-
data2: y
|
|
467
|
-
}),
|
|
468
|
-
roughnessTransform: X({
|
|
469
|
-
data1: b,
|
|
470
|
-
data2: x
|
|
471
|
-
}),
|
|
472
|
-
metalnessTransform: X({
|
|
473
|
-
data1: te,
|
|
474
|
-
data2: S
|
|
475
|
-
}),
|
|
476
|
-
emissiveTransform: X({
|
|
477
|
-
data1: C,
|
|
478
|
-
data2: w
|
|
479
|
-
}),
|
|
480
|
-
bumpTransform: X({
|
|
481
|
-
data1: T,
|
|
482
|
-
data2: E
|
|
483
|
-
}),
|
|
484
|
-
displacementTransform: X({
|
|
485
|
-
data1: O,
|
|
486
|
-
data2: A
|
|
487
|
-
})
|
|
488
|
-
});
|
|
489
|
-
}), Ue = o(() => {
|
|
490
|
-
let e = _(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
491
|
-
return z({
|
|
492
|
-
color: k(1, 1, 1, 1),
|
|
493
|
-
emissive: O(0),
|
|
494
|
-
emissiveIntensity: f(0),
|
|
495
|
-
roughness: f(1),
|
|
496
|
-
metalness: f(0),
|
|
497
|
-
ior: f(1.5),
|
|
498
|
-
transmission: f(0),
|
|
499
|
-
thickness: f(0),
|
|
500
|
-
clearcoat: f(0),
|
|
501
|
-
clearcoatRoughness: f(0),
|
|
502
|
-
opacity: f(1),
|
|
503
|
-
transparent: f(0),
|
|
504
|
-
attenuationColor: O(1),
|
|
505
|
-
attenuationDistance: f(0),
|
|
506
|
-
dispersion: f(0),
|
|
507
|
-
sheen: f(0),
|
|
508
|
-
sheenRoughness: f(1),
|
|
509
|
-
sheenColor: O(0),
|
|
510
|
-
specularIntensity: f(1),
|
|
511
|
-
specularColor: O(1),
|
|
512
|
-
alphaTest: f(0),
|
|
513
|
-
alphaMode: h(0),
|
|
514
|
-
side: h(0),
|
|
515
|
-
depthWrite: h(1),
|
|
516
|
-
albedoMapIndex: h(-1),
|
|
517
|
-
emissiveMapIndex: h(-1),
|
|
518
|
-
normalMapIndex: h(-1),
|
|
519
|
-
bumpMapIndex: h(-1),
|
|
520
|
-
bumpScale: f(1),
|
|
521
|
-
displacementScale: f(0),
|
|
522
|
-
metalnessMapIndex: h(-1),
|
|
523
|
-
roughnessMapIndex: h(-1),
|
|
524
|
-
displacementMapIndex: h(-1),
|
|
525
|
-
normalScale: D(1, 1),
|
|
526
|
-
albedoTransform: e,
|
|
527
|
-
emissiveTransform: e,
|
|
528
|
-
normalTransform: e,
|
|
529
|
-
bumpTransform: e,
|
|
530
|
-
metalnessTransform: e,
|
|
531
|
-
roughnessTransform: e,
|
|
532
|
-
displacementTransform: e,
|
|
533
|
-
iridescence: f(0),
|
|
534
|
-
iridescenceIOR: f(1.3),
|
|
535
|
-
iridescenceThicknessRange: D(100, 400),
|
|
536
|
-
subsurface: f(0),
|
|
537
|
-
subsurfaceColor: O(1),
|
|
538
|
-
subsurfaceRadius: O(1, .2, .1),
|
|
539
|
-
subsurfaceRadiusScale: f(1),
|
|
540
|
-
subsurfaceAnisotropy: f(0),
|
|
541
|
-
anisotropy: f(0),
|
|
542
|
-
anisotropyRotation: f(0),
|
|
543
|
-
anisotropyMapIndex: h(-1),
|
|
544
|
-
transmissionMapIndex: h(-1),
|
|
545
|
-
clearcoatMapIndex: h(-1),
|
|
546
|
-
clearcoatRoughnessMapIndex: h(-1),
|
|
547
|
-
sheenColorMapIndex: h(-1),
|
|
548
|
-
sheenRoughnessMapIndex: h(-1),
|
|
549
|
-
iridescenceMapIndex: h(-1),
|
|
550
|
-
iridescenceThicknessMapIndex: h(-1),
|
|
551
|
-
specularIntensityMapIndex: h(-1),
|
|
552
|
-
specularColorMapIndex: h(-1),
|
|
553
|
-
diffuseTransmission: f(0),
|
|
554
|
-
diffuseTransmissionColor: O(1),
|
|
555
|
-
diffuseTransmissionMapIndex: h(-1),
|
|
556
|
-
diffuseTransmissionColorMapIndex: h(-1)
|
|
557
|
-
});
|
|
558
|
-
}), We = o(([e, t]) => {
|
|
559
|
-
let n = q(t, e, h(K.IOR_TRANSMISSION), h(G)).toVar(), r = q(t, e, h(K.ATTENUATION), h(G)).toVar(), i = q(t, e, h(K.MAP_INDICES_A), h(G)).toVar(), a = q(t, e, h(K.OPACITY_ALPHA), h(G)).toVar(), o = q(t, e, h(K.ALPHA_MODE), h(G)).toVar(), s = q(t, e, h(K.ALBEDO_TRANSFORM_A), h(G)).toVar(), c = q(t, e, h(K.ALBEDO_TRANSFORM_B), h(G)).toVar();
|
|
560
|
-
return se({
|
|
561
|
-
color: k(1),
|
|
562
|
-
ior: n.r,
|
|
563
|
-
transmission: n.g,
|
|
564
|
-
attenuationColor: r.rgb,
|
|
565
|
-
attenuationDistance: r.a,
|
|
566
|
-
albedoMapIndex: h(i.r),
|
|
567
|
-
opacity: a.r,
|
|
568
|
-
transparent: a.b,
|
|
569
|
-
alphaTest: a.a,
|
|
570
|
-
alphaMode: h(o.r),
|
|
571
|
-
albedoTransform: X({
|
|
572
|
-
data1: s,
|
|
573
|
-
data2: c
|
|
574
|
-
})
|
|
575
|
-
});
|
|
576
|
-
}), Ge = (e, t) => {
|
|
577
|
-
let n = (t) => e.shiftRight(S(t)).bitAnd(S(1)).equal(S(1)), r = t ? t.equal(h(0)) : c(!0);
|
|
578
|
-
return n(26).or(n(27).and(r));
|
|
579
|
-
}, Ke = (e, t) => [
|
|
580
|
-
q(e, t, h(1), h(4)),
|
|
581
|
-
q(e, t, h(2), h(4)),
|
|
582
|
-
q(e, t, h(3), h(4))
|
|
583
|
-
], qe = (e, t) => O(O(e[0].x, e[1].x, e[2].x).dot(t), O(e[0].y, e[1].y, e[2].y).dot(t), O(e[0].z, e[1].z, e[2].z).dot(t)), Je = (e, t) => {
|
|
584
|
-
let n = e[0].xyz.dot(e[1].xyz.cross(e[2].xyz));
|
|
585
|
-
return qe(e, t).mul(n.sign());
|
|
586
|
-
}, Ye = /* @__PURE__ */ A("\n fn instanceDirToWorld( r0: vec3f, r1: vec3f, r2: vec3f, v: vec3f ) -> vec3f {\n\n // Rows of world-to-object; its inverse has columns cross(r1,r2), cross(r2,r0), cross(r0,r1).\n let c0 = cross( r1, r2 );\n let det = dot( r0, c0 );\n // Relative: for a uniform scale s this determinant is s⁻³, so a fixed floor would call a\n // heavily scaled-up instance singular and leave the direction untransformed.\n let magnitude = length( r0 ) * length( r1 ) * length( r2 );\n if ( abs( det ) <= 1e-12f * magnitude ) { return v; }\n\n let inv = 1.0f / det;\n return ( c0 * v.x + cross( r2, r0 ) * v.y + cross( r0, r1 ) * v.z ) * inv;\n\n }\n"), Xe = (e, t) => Ye({
|
|
587
|
-
r0: e[0].xyz,
|
|
588
|
-
r1: e[1].xyz,
|
|
589
|
-
r2: e[2].xyz,
|
|
590
|
-
v: t.sub(O(e[0].w, e[1].w, e[2].w))
|
|
591
|
-
}), Ze = t("gpu"), Z = {
|
|
592
|
-
ORIGIN_META: 0,
|
|
593
|
-
DIR_FLAGS: 1,
|
|
594
|
-
THROUGHPUT_PDF: 2,
|
|
595
|
-
RADIANCE_ALPHA: 3,
|
|
596
|
-
MEDIUM_STACK: 4,
|
|
597
|
-
MEDIUM_SIGMA_A: 5,
|
|
598
|
-
SSS_SIGMA_S: 6
|
|
599
|
-
}, Q = {
|
|
600
|
-
DIST_TRI_BARY: 0,
|
|
601
|
-
NORMAL_MAT: 1,
|
|
602
|
-
RNG: 2,
|
|
603
|
-
VERTEX: 3
|
|
604
|
-
}, Qe = 0, $e = 0, $ = (e, t) => t === 0 ? e : e.add(t * Qe);
|
|
605
|
-
function et(e, t) {
|
|
606
|
-
t && e?._attributes?.delete?.(t);
|
|
607
|
-
}
|
|
608
|
-
var tt = class {
|
|
609
|
-
constructor(e = 0, t = null, n = 0) {
|
|
610
|
-
this.capacity = 0, this.lightVertices = 0, this._renderer = t, this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, e > 0 && this.allocate(e, n);
|
|
611
|
-
}
|
|
612
|
-
allocate(t, n = 0) {
|
|
613
|
-
this.dispose(), this.capacity = t, this.lightVertices = n, Qe = t;
|
|
614
|
-
let r = n > 0 ? 7 : 3;
|
|
615
|
-
$e = t * r;
|
|
616
|
-
let i = t * 7, a = j(i, 4);
|
|
617
|
-
this._attrs.ray = a, this.rayBuffer = {
|
|
618
|
-
rw: x(a, "vec4"),
|
|
619
|
-
ro: x(a, "vec4").toReadOnly()
|
|
620
|
-
};
|
|
621
|
-
let o = t * r + n * 4, s = j(o, 4, Uint32Array);
|
|
622
|
-
this._attrs.hit = s, this.hitBuffer = {
|
|
623
|
-
rw: x(s, "uvec4"),
|
|
624
|
-
ro: x(s, "uvec4").toReadOnly()
|
|
625
|
-
}, this.rayBytes = i * 16, this.hitBytes = o * 16, this.totalBytes = this.rayBytes + this.hitBytes, Ze.debug(`ray pool capacity ${e.n(t)} · ${e.mb(this.totalBytes)} (rays ${e.mb(this.rayBytes)} · hits ${e.mb(this.hitBytes)})`);
|
|
626
|
-
}
|
|
627
|
-
resize(e, t = 0) {
|
|
628
|
-
return e <= this.capacity && this.capacity > 0 && t === this.lightVertices ? !1 : (this.allocate(e, t), !0);
|
|
629
|
-
}
|
|
630
|
-
dispose() {
|
|
631
|
-
et(this._renderer, this._attrs.ray), et(this._renderer, this._attrs.hit), this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, this.capacity = 0, this.lightVertices = 0;
|
|
632
|
-
}
|
|
633
|
-
}, nt = (e, t) => e.element($(t, Z.ORIGIN_META)).xyz, rt = (e, t) => e.element($(t, Z.DIR_FLAGS)).xyz, it = (e, t) => p(e.element($(t, Z.DIR_FLAGS)).w), at = (e, t) => e.element($(t, Z.THROUGHPUT_PDF)).xyz, ot = (e, t) => e.element($(t, Z.THROUGHPUT_PDF)).w, st = (e, t) => e.element($(t, Z.RADIANCE_ALPHA)), ct = (e) => S(e).mul(1), lt = (e, t, n, r, i, a = null) => {
|
|
634
|
-
let o = ct(t), s = a === null ? T(e.element(o).w).y : f(a);
|
|
635
|
-
return e.element(o).assign(E(ee(D(n.x, n.y)), ee(D(n.z, r)), y(D(i.x, i.y)), y(D(i.z, s))));
|
|
636
|
-
}, ut = (e, t, n) => {
|
|
637
|
-
let r = ct(t), i = e.element(r).toVar();
|
|
638
|
-
return e.element(r).assign(E(i.x, i.y, i.z, y(D(T(i.w).x, n))));
|
|
639
|
-
}, dt = (e, t) => e.element(ct(t)), ft = (e) => T(e.w).y, pt = (e) => {
|
|
640
|
-
let t = w(e.x), n = w(e.y);
|
|
641
|
-
return k(O(t.x, t.y, n.x).mul(.5).add(.5), n.y);
|
|
642
|
-
}, mt = (e) => O(T(e.z), T(e.w).x), ht = (e) => {
|
|
643
|
-
let t = l(m(g(v(e, 1e-6))), -8, 7), n = l(f(e).mul(d(t.negate())).sub(1).mul(64), 0, 63);
|
|
644
|
-
return b(f(e).lessThan(.004), S(0), S(t.add(8)).shiftLeft(6).bitOr(S(n)));
|
|
645
|
-
}, gt = (e, t) => {
|
|
646
|
-
let n = p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(22), r = f(n.shiftRight(6).bitAnd(S(15))).sub(8), i = f(n.bitAnd(S(63))).div(64).add(1);
|
|
647
|
-
return b(n.equal(S(0)), f(0), i.mul(d(r)));
|
|
648
|
-
}, _t = (e, t, n, r, i, a = S(0), o = null) => {
|
|
649
|
-
let s = S(r).bitAnd(S(255)).bitOr(S(i).bitAnd(S(255)).shiftLeft(8)).bitOr(S(a).bitAnd(S(63)).shiftLeft(16));
|
|
650
|
-
return o !== null && (s = s.bitOr(ht(o).shiftLeft(22))), e.element($(t, Z.ORIGIN_META)).assign(k(n, C(s)));
|
|
651
|
-
}, vt = (e, t, n, r) => e.element($(t, Z.DIR_FLAGS)).assign(k(n, C(r))), yt = (e, t, n, r) => e.element($(t, Z.THROUGHPUT_PDF)).assign(k(n, r)), bt = (e, t, n) => e.element($(t, Z.RADIANCE_ALPHA)).assign(n), xt = (e, t) => C(e.element($(t, Q.DIST_TRI_BARY)).x), St = (e, t) => e.element($(t, Q.DIST_TRI_BARY)).y, Ct = (e, t) => C(e.element($(t, Q.DIST_TRI_BARY)).zw), wt = (e, t) => Y(e.element($(t, Q.NORMAL_MAT)).x), Tt = (e, t) => S(e.element($(t, Q.NORMAL_MAT)).y), Et = (e, t) => h(e.element($(t, Q.NORMAL_MAT)).z).sub(h(1)), Dt = (e, t) => e.element($(t, Q.NORMAL_MAT)).w, Ot = (e, t) => e.element($(t, Q.RNG)).x, kt = (e, t, n) => e.element($(t, Q.RNG)).assign(E(n, 0, 0, 0)), At = (e, t) => {
|
|
652
|
-
let n = e.element($(t, Q.RNG));
|
|
653
|
-
return {
|
|
654
|
-
dVCM: C(n.y),
|
|
655
|
-
dVC: C(n.z)
|
|
656
|
-
};
|
|
657
|
-
}, jt = (e, t, n, r, i) => e.element($(t, Q.RNG)).assign(E(n, p(r), p(i), S(0))), Mt = (e) => (t) => $(e, Q.VERTEX + t), Nt = (e) => (t) => S(e).mul(4).add($e + t), Pt = (e, t, n) => {
|
|
658
|
-
e.element(t(0)).assign(E(p(n.position), n.tag)), e.element(t(1)).assign(E(p(n.throughput), J(n.V))), e.element(t(2)).assign(E(J(n.N), J(n.facetN), S(n.materialIndex).bitOr(S(n.extra).bitAnd(S(255)).shiftLeft(S(24))), p(n.uv.x))), e.element(t(3)).assign(E(p(n.uv.y), p(n.dVCM), p(n.dVC), S(0)));
|
|
659
|
-
}, Ft = (e, t) => e.element(t(0)).w, It = (e, t) => C(e.element(t(0)).xyz), Lt = (e, t) => e.element(t(3)).w, Rt = (e, t, n) => e.element(t(3)).w.assign(n), zt = (e, t) => {
|
|
660
|
-
let n = e.element(t(0)).toVar(), r = e.element(t(1)).toVar(), i = e.element(t(2)).toVar(), a = e.element(t(3)).toVar();
|
|
661
|
-
return {
|
|
662
|
-
position: C(n.xyz),
|
|
663
|
-
tag: n.w,
|
|
664
|
-
throughput: C(r.xyz),
|
|
665
|
-
V: Y(r.w),
|
|
666
|
-
N: Y(i.x),
|
|
667
|
-
facetN: Y(i.y),
|
|
668
|
-
materialIndex: i.z.bitAnd(S(16777215)),
|
|
669
|
-
uv: D(C(i.w), C(a.x)),
|
|
670
|
-
dVCM: C(a.y),
|
|
671
|
-
dVC: C(a.z),
|
|
672
|
-
extra: i.z.shiftRight(S(24))
|
|
673
|
-
};
|
|
674
|
-
}, Bt = (e, t, n) => {
|
|
675
|
-
let r = e.element(t(0)).w;
|
|
676
|
-
return b(r.shiftRight(S(8)).equal(n), r.bitAnd(S(255)), S(0));
|
|
677
|
-
}, Vt = (e, t, n, r) => {
|
|
678
|
-
let i = e.element(t(0)).xyz.toVar();
|
|
679
|
-
e.element(t(0)).assign(E(i, n.shiftLeft(S(8)).bitOr(S(r))));
|
|
680
|
-
}, Ht = (e, t, n, r, i, a) => e.element($(t, Q.VERTEX)).assign(E(S(n), S(h(r).add(h(1))), p(i), p(a))), Ut = (e, t) => {
|
|
681
|
-
let n = e.element($(t, Q.VERTEX)).toVar();
|
|
682
|
-
return {
|
|
683
|
-
triangle: h(n.x),
|
|
684
|
-
instanceLeaf: h(n.y).sub(h(1)),
|
|
685
|
-
cosLight: C(n.z),
|
|
686
|
-
scale: C(n.w)
|
|
687
|
-
};
|
|
688
|
-
}, Wt = (e, t, n, r, i, a, o, s, c, l = S(0)) => {
|
|
689
|
-
e.element($(t, Q.DIST_TRI_BARY)).assign(E(p(n), r, p(i), p(a))), e.element($(t, Q.NORMAL_MAT)).assign(E(J(o), s, c, l));
|
|
690
|
-
}, Gt = (e, t) => {
|
|
691
|
-
let n = e.element($(t, Z.MEDIUM_STACK)), r = p(n.x);
|
|
692
|
-
return {
|
|
693
|
-
stackDepth: r.bitAnd(255),
|
|
694
|
-
transTraversals: r.shiftRight(8).bitAnd(255),
|
|
695
|
-
wavelength: r.shiftRight(16).bitAnd(65535),
|
|
696
|
-
ior1: n.y,
|
|
697
|
-
ior2: n.z,
|
|
698
|
-
ior3: n.w
|
|
699
|
-
};
|
|
700
|
-
}, Kt = (e, t, n, r, i, a, o, s = S(0)) => e.element($(t, Z.MEDIUM_STACK)).assign(k(C(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), qt = (e, t) => e.element($(t, Z.MEDIUM_SIGMA_A)).xyz, Jt = (e, t, n) => {
|
|
701
|
-
let r = e.element($(t, Z.MEDIUM_SIGMA_A)).w.toVar();
|
|
702
|
-
e.element($(t, Z.MEDIUM_SIGMA_A)).assign(k(n, r));
|
|
703
|
-
}, Yt = (e) => {
|
|
704
|
-
let t = l(e, O(0), O(1)).mul(1023).add(.5);
|
|
705
|
-
return S(t.x).bitOr(S(t.y).shiftLeft(10)).bitOr(S(t.z).shiftLeft(20));
|
|
706
|
-
}, Xt = (e) => O(f(e.bitAnd(S(1023))), f(e.shiftRight(10).bitAnd(S(1023))), f(e.shiftRight(20).bitAnd(S(1023)))).div(1023), Zt = (e, t) => Xt(p(e.element($(t, Z.MEDIUM_SIGMA_A)).w)), Qt = (e, t, n) => {
|
|
707
|
-
let r = e.element($(t, Z.MEDIUM_SIGMA_A)).xyz.toVar();
|
|
708
|
-
e.element($(t, Z.MEDIUM_SIGMA_A)).assign(k(r, C(Yt(n))));
|
|
709
|
-
}, $t = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).bitAnd(255)), en = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), tn = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(16).bitAnd(S(63))), nn = (e, t) => {
|
|
710
|
-
let n = e.element($(t, Z.SSS_SIGMA_S));
|
|
711
|
-
return {
|
|
712
|
-
sigmaS: n.xyz,
|
|
713
|
-
g: n.w
|
|
714
|
-
};
|
|
715
|
-
}, rn = (e, t, n, r) => e.element($(t, Z.SSS_SIGMA_S)).assign(k(n, r)), an = [
|
|
716
|
-
610,
|
|
717
|
-
550,
|
|
718
|
-
465
|
|
719
|
-
].map((e) => -.023 + .292 / (e / 1e3));
|
|
720
|
-
//#endregion
|
|
721
|
-
export { rn as $, z as $t, at as A, Ke as At, lt as B, B as Bt, At as C, q as Ct, nt as D, Je as Dt, rt as E, Ye as Et, Lt as F, De as Ft, Jt as G, ue as Gt, Wt as H, pe as Ht, It as I, Ge as It, _t as J, le as Jt, Kt as K, V as Kt, zt as L, Ae as Lt, nn as M, ve as Mt, en as N, Me as Nt, ot as O, qe as Ot, tn as P, W as Pt, kt as Q, ae as Qt, Ft as R, Ve as Rt, gt as S, Ue as St, it as T, We as Tt, Ht as U, fe as Ut, ut as V, de as Vt, Vt as W, ce as Wt, yt as X, he as Xt, bt as Y, _e as Yt, jt as Z, me as Zt, St as _, Ne as _t, mt as a, N as an, G as at, qt as b, Ie as bt, Mt as c, Se as ct, Ct as d, Te as dt, se as en, Rt as et, xt as f, ye as ft, wt as g, ze as gt, Tt as h, Fe as ht, et as i, P as in, Oe as it, Ot as j, je as jt, st as k, Xe as kt, Zt as l, H as lt, Et as m, ke as mt, tt as n, j as nn, U as nt, ft as o, Ce as ot, Dt as p, xe as pt, vt as q, oe as qt, Nt as r, R as rn, Ee as rt, pt as s, we as st, an as t, ge as tn, Pt as tt, dt as u, be as ut, Ut as v, Le as vt, $t as w, He as wt, Gt as x, Pe as xt, Bt as y, Be as yt, Qt as z, Y as zt };
|