@tinypoly/gpu-renderer 0.2.4 → 0.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/ARCHITECTURE.md +48 -10
- package/README.md +2 -0
- package/dist/accumulator.d.ts.map +1 -1
- package/dist/accumulator.js +1 -0
- package/dist/accumulator.js.map +1 -1
- package/dist/denoise.js +2 -2
- package/dist/denoise.js.map +1 -1
- package/dist/device.d.ts.map +1 -1
- package/dist/device.js +9 -0
- package/dist/device.js.map +1 -1
- package/dist/frameLayout.d.ts.map +1 -1
- package/dist/frameLayout.js +5 -0
- package/dist/frameLayout.js.map +1 -1
- package/dist/geometry.d.ts +48 -8
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +409 -134
- package/dist/geometry.js.map +1 -1
- package/dist/grass.d.ts.map +1 -1
- package/dist/grass.js +2 -1
- package/dist/grass.js.map +1 -1
- package/dist/imageResolve.js +2 -2
- package/dist/imageResolve.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/instancing.d.ts +100 -0
- package/dist/instancing.d.ts.map +1 -0
- package/dist/instancing.js +286 -0
- package/dist/instancing.js.map +1 -0
- package/dist/lensPass.d.ts +2 -0
- package/dist/lensPass.d.ts.map +1 -1
- package/dist/lensPass.js +7 -4
- package/dist/lensPass.js.map +1 -1
- package/dist/lights.d.ts.map +1 -1
- package/dist/lights.js +8 -5
- package/dist/lights.js.map +1 -1
- package/dist/memoryProbe.d.ts +76 -0
- package/dist/memoryProbe.d.ts.map +1 -0
- package/dist/memoryProbe.js +197 -0
- package/dist/memoryProbe.js.map +1 -0
- package/dist/oidnPass.d.ts +6 -0
- package/dist/oidnPass.d.ts.map +1 -1
- package/dist/oidnPass.js +18 -1
- package/dist/oidnPass.js.map +1 -1
- package/dist/pathTracePass.d.ts +15 -2
- package/dist/pathTracePass.d.ts.map +1 -1
- package/dist/pathTracePass.js +38 -16
- package/dist/pathTracePass.js.map +1 -1
- package/dist/renderer.d.ts +13 -0
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +248 -41
- package/dist/renderer.js.map +1 -1
- package/dist/sceneUpload.d.ts +26 -8
- package/dist/sceneUpload.d.ts.map +1 -1
- package/dist/sceneUpload.js +97 -27
- package/dist/sceneUpload.js.map +1 -1
- package/dist/shaderModule.d.ts.map +1 -1
- package/dist/shaderModule.js +2 -1
- package/dist/shaderModule.js.map +1 -1
- package/dist/skyBake.d.ts.map +1 -1
- package/dist/skyBake.js +5 -3
- package/dist/skyBake.js.map +1 -1
- package/dist/texturePack.d.ts +43 -3
- package/dist/texturePack.d.ts.map +1 -1
- package/dist/texturePack.js +209 -37
- package/dist/texturePack.js.map +1 -1
- package/dist/wgsl/bvh.wgsl.d.ts +5 -1
- package/dist/wgsl/bvh.wgsl.d.ts.map +1 -1
- package/dist/wgsl/bvh.wgsl.js +105 -15
- package/dist/wgsl/bvh.wgsl.js.map +1 -1
- package/dist/wgsl/common.wgsl.d.ts.map +1 -1
- package/dist/wgsl/common.wgsl.js +92 -11
- package/dist/wgsl/common.wgsl.js.map +1 -1
- package/dist/wgsl/lens.wgsl.d.ts +1 -1
- package/dist/wgsl/lens.wgsl.d.ts.map +1 -1
- package/dist/wgsl/lens.wgsl.js +14 -2
- package/dist/wgsl/lens.wgsl.js.map +1 -1
- package/dist/wgsl/surface.wgsl.d.ts +1 -1
- package/dist/wgsl/surface.wgsl.d.ts.map +1 -1
- package/dist/wgsl/surface.wgsl.js +24 -14
- package/dist/wgsl/surface.wgsl.js.map +1 -1
- package/dist/wgsl/texture.wgsl.d.ts +1 -1
- package/dist/wgsl/texture.wgsl.d.ts.map +1 -1
- package/dist/wgsl/texture.wgsl.js +11 -0
- package/dist/wgsl/texture.wgsl.js.map +1 -1
- package/package.json +1 -1
- package/src/accumulator.ts +1 -0
- package/src/denoise.ts +2 -2
- package/src/device.ts +12 -0
- package/src/frameLayout.ts +5 -0
- package/src/geometry.ts +527 -133
- package/src/grass.ts +2 -1
- package/src/imageResolve.ts +2 -2
- package/src/index.ts +1 -0
- package/src/instancing.ts +415 -0
- package/src/lensPass.ts +9 -4
- package/src/lights.ts +9 -5
- package/src/memoryProbe.ts +275 -0
- package/src/oidnPass.ts +21 -1
- package/src/pathTracePass.ts +42 -18
- package/src/renderer.ts +308 -47
- package/src/sceneUpload.ts +139 -36
- package/src/shaderModule.ts +2 -1
- package/src/skyBake.ts +5 -3
- package/src/texturePack.ts +274 -43
- package/src/wgsl/bvh.wgsl.ts +105 -15
- package/src/wgsl/common.wgsl.ts +92 -11
- package/src/wgsl/lens.wgsl.ts +14 -2
- package/src/wgsl/surface.wgsl.ts +24 -14
- package/src/wgsl/texture.wgsl.ts +11 -0
package/dist/skyBake.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { compileProgram } from "./shaderProgram.js";
|
|
2
2
|
import { createShaderModule } from "./shaderModule.js";
|
|
3
|
+
import { traversalConstants } from "./pathTracePass.js";
|
|
3
4
|
import { BVH_WGSL } from "./wgsl/bvh.wgsl.js";
|
|
4
5
|
import { COMMON_WGSL } from "./wgsl/common.wgsl.js";
|
|
5
6
|
import { RANDOM_WGSL } from "./wgsl/random.wgsl.js";
|
|
@@ -13,7 +14,7 @@ const WORKGROUP = 8;
|
|
|
13
14
|
* goes to the binding the path tracer accumulates into, which is the one read-write buffer the support code declares.
|
|
14
15
|
*/
|
|
15
16
|
export function skyBakeSource(program, width, height) {
|
|
16
|
-
return `${COMMON_WGSL}${RANDOM_WGSL}${BVH_WGSL}${SAMPLING_WGSL}${TEXTURE_WGSL}${SHADER_SUPPORT_WGSL}
|
|
17
|
+
return `${traversalConstants(false)}${COMMON_WGSL}${RANDOM_WGSL}${BVH_WGSL}${SAMPLING_WGSL}${TEXTURE_WGSL}${SHADER_SUPPORT_WGSL}
|
|
17
18
|
${program.wgsl}
|
|
18
19
|
|
|
19
20
|
@compute @workgroup_size(${WORKGROUP}, ${WORKGROUP})
|
|
@@ -62,11 +63,12 @@ export async function bakeSkyOnDevice(device, program, uniforms, width) {
|
|
|
62
63
|
layout: device.createPipelineLayout({ bindGroupLayouts: [layout] }),
|
|
63
64
|
compute: { module, entryPoint: "main" },
|
|
64
65
|
});
|
|
65
|
-
const output = device.createBuffer({ size: texels * 16, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC });
|
|
66
|
+
const output = device.createBuffer({ label: "sky bake", size: texels * 16, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC });
|
|
66
67
|
const data = device.createBuffer({
|
|
68
|
+
label: "sky bake",
|
|
67
69
|
size: Math.max(16, words.byteLength), usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
68
70
|
});
|
|
69
|
-
const staging = device.createBuffer({ size: texels * 16, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
|
|
71
|
+
const staging = device.createBuffer({ label: "sky bake", size: texels * 16, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST });
|
|
70
72
|
try {
|
|
71
73
|
device.queue.writeBuffer(data, 0, words);
|
|
72
74
|
const encoder = device.createCommandEncoder({ label: "sky bake" });
|
package/dist/skyBake.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skyBake.js","sourceRoot":"","sources":["../src/skyBake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAsB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAA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G,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;QACrF,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC;QAC/D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAExC,MAAM,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAExC,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAErE,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAE7F,OAAO,QAAQ,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/texturePack.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { ShaderPrograms } from "./shaderProgram.js";
|
|
1
2
|
import type { SerializedScene, SerializedTexture } from "./upstream.js";
|
|
2
3
|
/**
|
|
3
4
|
* Every texture of a scene in one storage buffer, led by a table saying where each one lives. Core WebGPU has no binding
|
|
4
5
|
* arrays and `texture_2d_array` wants one size and one format for every layer, which a Three.js scene does not provide,
|
|
5
6
|
* so the texels are read by hand. See the decision in ARCHITECTURE.md.
|
|
6
7
|
*
|
|
7
|
-
* Byte textures keep their eight bits per channel, four to a word, and are decoded from sRGB as they are read.
|
|
8
|
-
*
|
|
8
|
+
* Byte textures keep their eight bits per channel, four to a word, and are decoded from sRGB as they are read. A byte
|
|
9
|
+
* texture of which only one channel is ever read (a roughness or a bump map) keeps that channel alone, four texels to a
|
|
10
|
+
* word. Float textures keep all four, because their range is the reason they are float at all.
|
|
9
11
|
*/
|
|
10
12
|
export interface PackedTextures {
|
|
11
13
|
/**
|
|
@@ -46,6 +48,27 @@ declare const REPEAT = 1000;
|
|
|
46
48
|
declare const MIRRORED_REPEAT = 1002;
|
|
47
49
|
/** How many UV sets the geometry carries, and so the highest channel a texture may ask for. */
|
|
48
50
|
export declare const UV_CHANNELS = 2;
|
|
51
|
+
/**
|
|
52
|
+
* The channels the kernel reads from each material map slot, as the WGSL reads them: roughness from green, metalness
|
|
53
|
+
* from blue, and so on. A slot missing here counts as reading all four.
|
|
54
|
+
*/
|
|
55
|
+
export declare const SLOT_CHANNELS: Readonly<Record<string, string>>;
|
|
56
|
+
/** How each texture of a scene is stored: one channel, or all four and why. */
|
|
57
|
+
export interface TextureChannels {
|
|
58
|
+
/** The channel kept (0 for red to 3 for alpha) of each texture stored one byte a texel. */
|
|
59
|
+
single: Map<string, number>;
|
|
60
|
+
/** Why every other texture keeps all four. */
|
|
61
|
+
whole: Map<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Which byte textures of a scene are read through one channel only: every reference to the texture is a material map
|
|
65
|
+
* slot, and every such slot reads the same channel. A texture named anywhere else (a light's projected map, the sky, a
|
|
66
|
+
* planar capture) is read in ways this cannot see, and keeps all four. With the scene's translated programs, a
|
|
67
|
+
* shader's uniforms count only for the textures its program reads; without them, any texture they name keeps all four.
|
|
68
|
+
*/
|
|
69
|
+
export declare function textureChannels(scene: SerializedScene, programs?: Pick<ShaderPrograms, "fragment" | "after">): TextureChannels;
|
|
70
|
+
/** The byte textures of a scene read through one channel only, with that channel: see `textureChannels`. */
|
|
71
|
+
export declare function singleChannelTextures(scene: SerializedScene, programs?: Pick<ShaderPrograms, "fragment" | "after">): Map<string, number>;
|
|
49
72
|
/**
|
|
50
73
|
* Where everything will go, before anything is written: which index each texture gets and where the words after the
|
|
51
74
|
* texels begin. Materials and lights point into that tail by absolute offset, so they need it before the buffer exists.
|
|
@@ -53,14 +76,31 @@ export declare const UV_CHANNELS = 2;
|
|
|
53
76
|
export interface TexturePlan {
|
|
54
77
|
textures: SerializedTexture[];
|
|
55
78
|
indexOf: Map<string, number>;
|
|
79
|
+
/** The channel kept of each texture stored one byte a texel, by id. */
|
|
80
|
+
channelOf: ReadonlyMap<string, number>;
|
|
56
81
|
/** The lookup tables and the texture table together: where the texels begin. */
|
|
57
82
|
tableWords: number;
|
|
58
83
|
/** Where the words appended after the texels begin. */
|
|
59
84
|
extraOffset: number;
|
|
60
85
|
}
|
|
61
|
-
export declare function planTextures(scene: SerializedScene, extraTextures?: readonly SerializedTexture[]): TexturePlan;
|
|
86
|
+
export declare function planTextures(scene: SerializedScene, extraTextures?: readonly SerializedTexture[], channelOf?: ReadonlyMap<string, number>): TexturePlan;
|
|
62
87
|
export declare function packTextures(scene: SerializedScene, extras?: TextureExtras): PackedTextures;
|
|
63
88
|
/** The buffer a plan describes, with `extraWords` appended at its `extraOffset`. */
|
|
64
89
|
export declare function writeTextures(plan: TexturePlan, extraWords: Uint32Array): PackedTextures;
|
|
90
|
+
/**
|
|
91
|
+
* The same buffer `writeTextures` builds, written to the device a piece at a time: the tables, then each texture's
|
|
92
|
+
* texels straight from the snapshot, then the extra words. The page never holds the whole buffer, which for a scene of
|
|
93
|
+
* many large textures is hundreds of megabytes it would only hold to hand over.
|
|
94
|
+
*/
|
|
95
|
+
export interface TextureUpload {
|
|
96
|
+
byteLength: number;
|
|
97
|
+
count: number;
|
|
98
|
+
indexOf: Map<string, number>;
|
|
99
|
+
extraOffset: number;
|
|
100
|
+
/** Where each texture's texels start, in words, by its index in the table. */
|
|
101
|
+
offsets: number[];
|
|
102
|
+
write(device: GPUDevice, buffer: GPUBuffer): void;
|
|
103
|
+
}
|
|
104
|
+
export declare function textureUpload(plan: TexturePlan, extraWords: Uint32Array): TextureUpload;
|
|
65
105
|
export { MIRRORED_REPEAT, REPEAT };
|
|
66
106
|
//# sourceMappingURL=texturePack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texturePack.d.ts","sourceRoot":"","sources":["../src/texturePack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"texturePack.d.ts","sourceRoot":"","sources":["../src/texturePack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAsB,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oHAAoH;AACpH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,2EAA2E;AAC3E,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,+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;IACvD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,aAAa,GAAE,SAAS,iBAAiB,EAAO,EACnG,SAAS,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAgC,GAAG,WAAW,CAcpF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,GAAE,aAAkB,GAAG,cAAc,CAE/F;AAmED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,GAAG,cAAc,CAiCxF;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;CACnD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,GAAG,aAAa,CAsCvF;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/texturePack.js
CHANGED
|
@@ -52,6 +52,8 @@ const TEXTURE_NEAREST = 4;
|
|
|
52
52
|
const TEXTURE_FLIP_Y = 8;
|
|
53
53
|
/** An environment map whose mapping bends the view ray instead of mirroring it. */
|
|
54
54
|
const TEXTURE_REFRACTION = 16;
|
|
55
|
+
/** One byte a texel: the only channel the scene reads of it, which the shader hands back in every channel. */
|
|
56
|
+
const TEXTURE_SINGLE = 32;
|
|
55
57
|
/** Three's own wrap constants, which the shader compares against. */
|
|
56
58
|
const REPEAT = 1000;
|
|
57
59
|
const MIRRORED_REPEAT = 1002;
|
|
@@ -66,7 +68,118 @@ const isFloat = (texture) => texture.data instanceof Float32Array;
|
|
|
66
68
|
* texture was converted to linear when the scene was serialized, and had its colour space rewritten to say so.
|
|
67
69
|
*/
|
|
68
70
|
const isEncoded = (texture) => !isFloat(texture) && texture.colorSpace === "srgb";
|
|
69
|
-
|
|
71
|
+
/**
|
|
72
|
+
* The channels the kernel reads from each material map slot, as the WGSL reads them: roughness from green, metalness
|
|
73
|
+
* from blue, and so on. A slot missing here counts as reading all four.
|
|
74
|
+
*/
|
|
75
|
+
export const SLOT_CHANNELS = {
|
|
76
|
+
map: "rgba", emissiveMap: "rgb", roughnessMap: "g", metalnessMap: "b", normalMap: "rgb", clearcoatNormalMap: "rgb",
|
|
77
|
+
alphaMap: "g", transmissionMap: "r", thicknessMap: "g", clearcoatMap: "r", clearcoatRoughnessMap: "g",
|
|
78
|
+
sheenColorMap: "rgb", sheenRoughnessMap: "a", iridescenceMap: "r", iridescenceThicknessMap: "g", anisotropyMap: "rgb",
|
|
79
|
+
specularMap: "r", specularIntensityMap: "a", specularColorMap: "rgb", bumpMap: "r", displacementMap: "r",
|
|
80
|
+
lightMap: "rgb", gradientMap: "r", matcap: "rgb", envMap: "rgb",
|
|
81
|
+
};
|
|
82
|
+
/** Every string inside a value, with the first path it was found at, without walking into typed arrays. */
|
|
83
|
+
function collectStrings(value, path, into, seen = new Set()) {
|
|
84
|
+
if (typeof value === "string") {
|
|
85
|
+
if (!into.has(value))
|
|
86
|
+
into.set(value, path);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!value || typeof value !== "object" || seen.has(value) || ArrayBuffer.isView(value))
|
|
90
|
+
return;
|
|
91
|
+
seen.add(value);
|
|
92
|
+
for (const [key, entry] of Object.entries(value))
|
|
93
|
+
collectStrings(entry, `${path}.${key}`, into, seen);
|
|
94
|
+
}
|
|
95
|
+
/** Texture indices no table reaches, one per texture, which a program's packed uniforms give back where it reads one. */
|
|
96
|
+
const PROBE = 0x7f000000;
|
|
97
|
+
/**
|
|
98
|
+
* The textures a material's translated programs read: their uniforms are packed with a probe index for every texture,
|
|
99
|
+
* and the probes that come back are the textures the programs declare. A texture a hook's uniforms name but its
|
|
100
|
+
* program never declares (Three hands a patched material's every map to its shader) is not read by it.
|
|
101
|
+
*/
|
|
102
|
+
function programTextures(material, programs, textures) {
|
|
103
|
+
const probes = new Map(textures.map((texture, index) => [texture.id, PROBE + index]));
|
|
104
|
+
const uniforms = { ...material.shader?.uniforms, ...material.time !== undefined ? { time: material.time } : {} };
|
|
105
|
+
const read = new Set();
|
|
106
|
+
for (const program of [programs.fragment(material), programs.after(material)]) {
|
|
107
|
+
if (!program)
|
|
108
|
+
continue;
|
|
109
|
+
for (const word of program.packUniforms(uniforms, probes))
|
|
110
|
+
if (word >= PROBE && word < PROBE + textures.length)
|
|
111
|
+
read.add(textures[word - PROBE].id);
|
|
112
|
+
}
|
|
113
|
+
return read;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Which byte textures of a scene are read through one channel only: every reference to the texture is a material map
|
|
117
|
+
* slot, and every such slot reads the same channel. A texture named anywhere else (a light's projected map, the sky, a
|
|
118
|
+
* planar capture) is read in ways this cannot see, and keeps all four. With the scene's translated programs, a
|
|
119
|
+
* shader's uniforms count only for the textures its program reads; without them, any texture they name keeps all four.
|
|
120
|
+
*/
|
|
121
|
+
export function textureChannels(scene, programs) {
|
|
122
|
+
const read = new Map();
|
|
123
|
+
const elsewhere = new Map();
|
|
124
|
+
const materials = new Set(scene.meshes.flatMap(mesh => mesh.materials));
|
|
125
|
+
for (const material of materials) {
|
|
126
|
+
if (!material)
|
|
127
|
+
continue;
|
|
128
|
+
const { maps, ...everything } = material;
|
|
129
|
+
const name = `material "${material.name || material.type}"`;
|
|
130
|
+
// The shader's uniforms are read only through its translated programs, which say what they sample.
|
|
131
|
+
const { shader, ...rest } = everything;
|
|
132
|
+
if (programs && shader) {
|
|
133
|
+
for (const id of programTextures(material, programs, scene.textures ?? []))
|
|
134
|
+
if (!elsewhere.has(id))
|
|
135
|
+
elsewhere.set(id, `the shader of ${name}`);
|
|
136
|
+
}
|
|
137
|
+
else if (shader) {
|
|
138
|
+
collectStrings(shader, `${name}.shader`, elsewhere);
|
|
139
|
+
}
|
|
140
|
+
for (const [slot, id] of Object.entries(maps ?? {})) {
|
|
141
|
+
if (typeof id !== "string")
|
|
142
|
+
continue;
|
|
143
|
+
let channels = read.get(id);
|
|
144
|
+
if (!channels)
|
|
145
|
+
read.set(id, channels = new Set());
|
|
146
|
+
for (const channel of SLOT_CHANNELS[slot] ?? "rgba")
|
|
147
|
+
channels.add(channel);
|
|
148
|
+
}
|
|
149
|
+
collectStrings(rest, name, elsewhere);
|
|
150
|
+
}
|
|
151
|
+
// The rest of the scene: its lights, its sky and whatever else names a texture.
|
|
152
|
+
for (const [key, value] of Object.entries(scene))
|
|
153
|
+
if (key !== "meshes" && key !== "textures")
|
|
154
|
+
collectStrings(value, key, elsewhere);
|
|
155
|
+
const single = new Map();
|
|
156
|
+
const whole = new Map();
|
|
157
|
+
for (const texture of scene.textures ?? []) {
|
|
158
|
+
const channels = read.get(texture.id);
|
|
159
|
+
const named = elsewhere.get(texture.id);
|
|
160
|
+
if (isFloat(texture))
|
|
161
|
+
whole.set(texture.id, "float");
|
|
162
|
+
else if (!channels)
|
|
163
|
+
whole.set(texture.id, named ? `named by ${named}` : "not read by any map");
|
|
164
|
+
else if (channels.size !== 1)
|
|
165
|
+
whole.set(texture.id, `reads ${[...channels].join("")}`);
|
|
166
|
+
else if (named)
|
|
167
|
+
whole.set(texture.id, `named by ${named}`);
|
|
168
|
+
else
|
|
169
|
+
single.set(texture.id, "rgba".indexOf([...channels][0]));
|
|
170
|
+
}
|
|
171
|
+
return { single, whole };
|
|
172
|
+
}
|
|
173
|
+
/** The byte textures of a scene read through one channel only, with that channel: see `textureChannels`. */
|
|
174
|
+
export function singleChannelTextures(scene, programs) {
|
|
175
|
+
return textureChannels(scene, programs).single;
|
|
176
|
+
}
|
|
177
|
+
/** Words a texture's texels take in the buffer. */
|
|
178
|
+
function texelWords(texture, single) {
|
|
179
|
+
const texels = texelCount(texture);
|
|
180
|
+
return isFloat(texture) ? texels * 4 : single ? Math.ceil(texels / 4) : texels;
|
|
181
|
+
}
|
|
182
|
+
export function planTextures(scene, extraTextures = [], channelOf = singleChannelTextures(scene)) {
|
|
70
183
|
const seen = new Set();
|
|
71
184
|
// A texture id appears once, whoever refers to it; the first copy wins.
|
|
72
185
|
const textures = [...scene.textures ?? [], ...extraTextures]
|
|
@@ -74,25 +187,26 @@ export function planTextures(scene, extraTextures = []) {
|
|
|
74
187
|
.filter(texture => !seen.has(texture.id) && !!seen.add(texture.id));
|
|
75
188
|
const indexOf = new Map(textures.map((texture, index) => [texture.id, index]));
|
|
76
189
|
const tableWords = TEXTURE_TABLE + Math.max(1, textures.length) * TEXTURE_WORDS;
|
|
77
|
-
const
|
|
78
|
-
|
|
190
|
+
const kept = new Map([...channelOf].filter(([id]) => indexOf.has(id)));
|
|
191
|
+
const words = textures.reduce((sum, texture) => sum + texelWords(texture, kept.has(texture.id)), 0);
|
|
192
|
+
return { textures, indexOf, channelOf: kept, tableWords, extraOffset: tableWords + words };
|
|
79
193
|
}
|
|
80
194
|
export function packTextures(scene, extras = {}) {
|
|
81
195
|
return writeTextures(planTextures(scene, extras.textures), extras.words ?? new Uint32Array(0));
|
|
82
196
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
let texelAt = tableWords;
|
|
91
|
-
|
|
92
|
-
textures.forEach((texture, index) => {
|
|
197
|
+
/**
|
|
198
|
+
* The lookup tables and the texture table a plan describes, written at the head of `words`. Returns where each
|
|
199
|
+
* texture's texels start, in words.
|
|
200
|
+
*/
|
|
201
|
+
function writeTable(words, plan) {
|
|
202
|
+
const floats = new Float32Array(words.buffer, words.byteOffset, words.length);
|
|
203
|
+
const offsets = [];
|
|
204
|
+
let texelAt = plan.tableWords;
|
|
205
|
+
words.set(LOOKUP, 0);
|
|
206
|
+
plan.textures.forEach((texture, index) => {
|
|
93
207
|
const at = textureEntry(index);
|
|
94
|
-
const texels = texelCount(texture);
|
|
95
208
|
const float = isFloat(texture);
|
|
209
|
+
offsets.push(texelAt);
|
|
96
210
|
words[at] = texture.width;
|
|
97
211
|
words[at + 1] = texture.height;
|
|
98
212
|
words[at + 2] = texelAt;
|
|
@@ -100,7 +214,8 @@ export function writeTextures(plan, extraWords) {
|
|
|
100
214
|
| (isEncoded(texture) ? TEXTURE_SRGB : 0)
|
|
101
215
|
| (texture.nearest ? TEXTURE_NEAREST : 0)
|
|
102
216
|
| (texture.flipY ? TEXTURE_FLIP_Y : 0)
|
|
103
|
-
| (texture.refraction ? TEXTURE_REFRACTION : 0)
|
|
217
|
+
| (texture.refraction ? TEXTURE_REFRACTION : 0)
|
|
218
|
+
| (plan.channelOf.has(texture.id) ? TEXTURE_SINGLE : 0);
|
|
104
219
|
words[at + 4] = texture.wrapS;
|
|
105
220
|
words[at + 5] = texture.wrapT;
|
|
106
221
|
words[at + 6] = Math.min(Math.max(0, texture.channel | 0), UV_CHANNELS - 1);
|
|
@@ -109,31 +224,88 @@ export function writeTextures(plan, extraWords) {
|
|
|
109
224
|
const matrix = texture.matrix?.length === 9 ? texture.matrix : [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
110
225
|
floats.set([matrix[0], matrix[3], matrix[6], 0], at + 8);
|
|
111
226
|
floats.set([matrix[1], matrix[4], matrix[7], 0], at + 12);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
227
|
+
texelAt += texelWords(texture, plan.channelOf.has(texture.id));
|
|
228
|
+
});
|
|
229
|
+
return offsets;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* A texture's texels as the buffer holds them: viewed straight from the snapshot where the bytes already agree, the one
|
|
233
|
+
* channel kept copied out four texels to a word, or null for a byte texture a big endian page has to turn around.
|
|
234
|
+
*/
|
|
235
|
+
function texelView(texture, channel) {
|
|
236
|
+
const texels = texelCount(texture);
|
|
237
|
+
if (isFloat(texture))
|
|
238
|
+
return texture.data.subarray(0, texels * 4);
|
|
239
|
+
if (channel !== undefined) {
|
|
240
|
+
const source = texture.data;
|
|
241
|
+
// Bytes in the order the device reads a word's, lowest first, so this needs no turning around on any page.
|
|
242
|
+
const kept = new Uint8Array(Math.ceil(texels / 4) * 4);
|
|
243
|
+
for (let texel = 0; texel < texels; texel++)
|
|
244
|
+
kept[texel] = source[texel * 4 + channel];
|
|
245
|
+
return kept;
|
|
246
|
+
}
|
|
247
|
+
return LITTLE_ENDIAN ? texture.data.subarray(0, texels * 4) : null;
|
|
248
|
+
}
|
|
249
|
+
/** The buffer a plan describes, with `extraWords` appended at its `extraOffset`. */
|
|
250
|
+
export function writeTextures(plan, extraWords) {
|
|
251
|
+
const { textures, indexOf } = plan;
|
|
252
|
+
// WebGPU rejects an empty binding, and a scene with no textures at all is ordinary.
|
|
253
|
+
const data = new Uint32Array(Math.max(4, plan.extraOffset + extraWords.length));
|
|
254
|
+
const offsets = writeTable(data, plan);
|
|
255
|
+
textures.forEach((texture, index) => {
|
|
256
|
+
const texelAt = offsets[index];
|
|
257
|
+
const view = texelView(texture, plan.channelOf.get(texture.id));
|
|
258
|
+
if (view) {
|
|
259
|
+
// The channels keep their bits, and bytes already sit in the order the words want them: copied whole.
|
|
260
|
+
new Uint8Array(data.buffer, texelAt * 4, view.byteLength)
|
|
261
|
+
.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
|
|
262
|
+
return;
|
|
116
263
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (let texel = 0; texel < texels; texel++) {
|
|
125
|
-
const offset = texel * 4;
|
|
126
|
-
words[texelAt + texel] = source[offset]
|
|
127
|
-
| (source[offset + 1] << 8)
|
|
128
|
-
| (source[offset + 2] << 16)
|
|
129
|
-
| (source[offset + 3] << 24);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
texelAt += texels;
|
|
264
|
+
const source = texture.data;
|
|
265
|
+
for (let texel = 0; texel < texelCount(texture); texel++) {
|
|
266
|
+
const offset = texel * 4;
|
|
267
|
+
data[texelAt + texel] = source[offset]
|
|
268
|
+
| (source[offset + 1] << 8)
|
|
269
|
+
| (source[offset + 2] << 16)
|
|
270
|
+
| (source[offset + 3] << 24);
|
|
133
271
|
}
|
|
134
272
|
});
|
|
135
|
-
data.set(extraWords,
|
|
136
|
-
return { data, count: textures.length, indexOf, extraOffset:
|
|
273
|
+
data.set(extraWords, plan.extraOffset);
|
|
274
|
+
return { data, count: textures.length, indexOf, extraOffset: plan.extraOffset };
|
|
275
|
+
}
|
|
276
|
+
export function textureUpload(plan, extraWords) {
|
|
277
|
+
const byteLength = Math.max(4, plan.extraOffset + extraWords.length) * 4;
|
|
278
|
+
// A big endian page has to turn every byte texel around, which needs the whole buffer anyway.
|
|
279
|
+
if (!LITTLE_ENDIAN) {
|
|
280
|
+
const packed = writeTextures(plan, extraWords);
|
|
281
|
+
return {
|
|
282
|
+
byteLength,
|
|
283
|
+
count: packed.count,
|
|
284
|
+
indexOf: packed.indexOf,
|
|
285
|
+
extraOffset: packed.extraOffset,
|
|
286
|
+
offsets: plan.textures.map((_, index) => packed.data[textureEntry(index) + 2]),
|
|
287
|
+
write: (device, buffer) => device.queue.writeBuffer(buffer, 0, packed.data),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const header = new Uint32Array(plan.tableWords);
|
|
291
|
+
const offsets = writeTable(header, plan);
|
|
292
|
+
return {
|
|
293
|
+
byteLength,
|
|
294
|
+
count: plan.textures.length,
|
|
295
|
+
indexOf: plan.indexOf,
|
|
296
|
+
extraOffset: plan.extraOffset,
|
|
297
|
+
offsets,
|
|
298
|
+
write(device, buffer) {
|
|
299
|
+
device.queue.writeBuffer(buffer, 0, header);
|
|
300
|
+
plan.textures.forEach((texture, index) => {
|
|
301
|
+
const view = texelView(texture, plan.channelOf.get(texture.id));
|
|
302
|
+
if (view.byteLength)
|
|
303
|
+
device.queue.writeBuffer(buffer, offsets[index] * 4, view);
|
|
304
|
+
});
|
|
305
|
+
if (extraWords.length)
|
|
306
|
+
device.queue.writeBuffer(buffer, plan.extraOffset * 4, extraWords);
|
|
307
|
+
},
|
|
308
|
+
};
|
|
137
309
|
}
|
|
138
310
|
export { MIRRORED_REPEAT, REPEAT };
|
|
139
311
|
//# sourceMappingURL=texturePack.js.map
|
package/dist/texturePack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"texturePack.js","sourceRoot":"","sources":["../src/texturePack.ts"],"names":[],"mappings":"AA+BA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,GAAG,CAAC,GAAG,GAAG,CAAC;AAChD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,GAAG,GAAG,CAAC;AAE9C,wHAAwH;AACxH,SAAS,WAAW;IAClB,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,SAAS,GAAG,UAAU,CAAC;IAE3B,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC;QAClC,UAAU,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC;QACjC,SAAS,GAAG,CAAC,SAAS,GAAG,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAExC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,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;gBAAE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;QAC5F,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/wgsl/bvh.wgsl.d.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* The positions are uploaded in the hierarchy's leaf order, so a leaf is a run of triangles read straight off the
|
|
5
5
|
* buffer; the scene's own triangle number is looked up once, for the hit a trace returns. Every other reader goes the
|
|
6
6
|
* other way, from a triangle number to where its corners sit.
|
|
7
|
+
*
|
|
8
|
+
* With INSTANCES compiled in, a leaf with a count of -1 is an instance: the ray is taken into its object space and
|
|
9
|
+
* the traversal goes on in its prototype's hierarchy, with a marker on the stack that brings it back to world space.
|
|
10
|
+
* The distance along the ray is the same in both spaces, since the direction is transformed and not normalized.
|
|
7
11
|
*/
|
|
8
|
-
export declare const BVH_WGSL = "\n/** A corner of the triangle at this position of the hierarchy's leaf order. */\nfn leafVertex(at: u32, corner: u32) -> vec3<f32> {\n let base = at * 9u + corner * 3u;\n\n return vec3<f32>(positions[base], positions[base + 1u], positions[base + 2u]);\n}\n\n/** Where a triangle of the scene sits in the leaf order the positions are stored in. */\nfn leafOf(triangle: u32) -> u32 {\n return indices[frame.leafOffset + triangle];\n}\n\nfn triangleVertex(triangle: u32, corner: u32) -> vec3<f32> {\n return leafVertex(leafOf(triangle), corner);\n}\n\n/** Moller-Trumbore. Returns the distance in x and the barycentric coordinates in yz, or a negative distance. */\nfn intersectTriangle(at: u32, origin: vec3<f32>, direction: vec3<f32>) -> vec3<f32> {\n let miss = vec3<f32>(-1.0, 0.0, 0.0);\n let a = leafVertex(at, 0u);\n let edge1 = leafVertex(at, 1u) - a;\n let edge2 = leafVertex(at, 2u) - a;\n let p = cross(direction, edge2);\n let determinant = dot(edge1, p);\n\n if (abs(determinant) < 1e-12) {\n return miss;\n }\n\n let inverse = 1.0 / determinant;\n let offset = origin - a;\n let u = dot(offset, p) * inverse;\n\n if (u < 0.0 || u > 1.0) {\n return miss;\n }\n\n let q = cross(offset, edge1);\n let v = dot(direction, q) * inverse;\n\n if (v < 0.0 || u + v > 1.0) {\n return miss;\n }\n\n return vec3<f32>(dot(edge2, q) * inverse, u, v);\n}\n\n/** Where a ray enters a box, or 1e30 when it misses it or only meets it past maxDistance. */\nfn enterBox(low: vec3<f32>, high: vec3<f32>, origin: vec3<f32>, inverse: vec3<f32>, maxDistance: f32) -> f32 {\n let first = (low - origin) * inverse;\n let second = (high - origin) * inverse;\n let near = min(first, second);\n let far = max(first, second);\n let enter = max(max(near.x, near.y), max(near.z, 0.0));\n let exit = min(min(far.x, far.y), min(far.z, maxDistance));\n\n return select(1e30, enter, enter <= exit);\n}\n\n/** The triangles of a leaf, against the closest hit so far, which records where in the leaf order it found one. */\nfn intersectLeaf(link: i32, count: i32, origin: vec3<f32>, direction: vec3<f32>, hit: ptr<function, Hit>) {\n let start = u32(-1 - link);\n\n for (var i = 0u; i < u32(count); i = i + 1u) {\n let result = intersectTriangle(start + i, origin, direction);\n\n if (result.x > RAY_EPSILON && result.x < (*hit).distance) {\n (*hit).distance = result.x;\n (*hit).triangle = start + i;\n (*hit).u = result.y;\n (*hit).v = result.z;\n }\n }\n}\n\n/** Whether any triangle of a leaf lies along the ray before maxDistance: its position in the leaf order, or NO_HIT. */\nfn anyInLeaf(link: i32, count: i32, origin: vec3<f32>, direction: vec3<f32>, maxDistance: f32) -> u32 {\n let start = u32(-1 - link);\n\n for (var i = 0u; i < u32(count); i = i + 1u) {\n let result = intersectTriangle(start + i, origin, direction);\n\n if (result.x > RAY_EPSILON && result.x < maxDistance) {\n return start + i;\n }\n }\n\n return NO_HIT;\n}\n\n/** No node to go to: the traversal takes the next entry off the stack. */\nconst NO_NODE: u32 = 0xffffffffu;\n\n/**\n * A stack entry that is a leaf rather than a node: the node holding it and which of its two children it is. A leaf\n * has no node of its own, so this is how one waits its turn.\n */\nconst LEAF_ENTRY: u32 = 0x80000000u;\n\nfn leafEntry(parent: u32, right: bool) -> u32 {\n return LEAF_ENTRY | (parent << 1u) | select(0u, 1u, right);\n}\n\n/** A waiting leaf's link and count, read back from the node that holds it. */\nfn waitingLeaf(entry: u32) -> vec2<i32> {\n let parent = (entry & ~LEAF_ENTRY) >> 1u;\n\n if ((entry & 1u) != 0u) {\n return vec2<i32>(nodes[parent].rightLink, nodes[parent].rightCount);\n }\n\n return vec2<i32>(nodes[parent].leftLink, nodes[parent].leftCount);\n}\n\n/**\n * The closest hit along a ray. A node holds both of its children's boxes, so one read tests them both. The nearer is\n * visited first, so the closest hit shrinks the search early and whole subtrees behind it are skipped; the farther one\n * waits on the stack with where the ray entered it, and is dropped unopened if something closer turned up meanwhile.\n * A leaf is tested at the top of the next step, the one place the loop tests triangles, which keeps the kernel small.\n * This visits what the binary tree's traversal visited, in the same order, so it finds the same hit.\n */\nfn traceScene(origin: vec3<f32>, direction: vec3<f32>, maxDistance: f32) -> Hit {\n var hit: Hit;\n hit.distance = maxDistance;\n hit.triangle = NO_HIT;\n hit.u = 0.0;\n hit.v = 0.0;\n\n if (frame.triangleCount == 0u) {\n return hit;\n }\n\n // A huge finite reciprocal instead of an infinite one: an axis aligned slab would otherwise produce 0 * inf.\n let signs = select(vec3<f32>(-1.0), vec3<f32>(1.0), direction >= vec3<f32>(0.0));\n let inverse = signs / max(abs(direction), vec3<f32>(1e-20));\n\n var stack: array<u32, 32>;\n var enters: array<f32, 32>;\n var depth = 0u;\n var current = 0u;\n // A leaf to test before anything else: its link, and its triangle count, zero when there is none.\n var leaf = vec2<i32>(0, 0);\n\n loop {\n if (leaf.y > 0) {\n intersectLeaf(leaf.x, leaf.y, origin, direction, &hit);\n leaf.y = 0;\n }\n\n if (current == NO_NODE) {\n if (depth == 0u) {\n break;\n }\n\n depth = depth - 1u;\n\n // Something closer was found since this was pushed.\n if (enters[depth] > hit.distance) {\n continue;\n }\n\n let entry = stack[depth];\n\n if ((entry & LEAF_ENTRY) != 0u) {\n leaf = waitingLeaf(entry);\n continue;\n }\n\n current = entry;\n }\n\n let node = nodes[current];\n let leftEnter = enterBox(node.leftLow, node.leftHigh, origin, inverse, hit.distance);\n let rightEnter = enterBox(node.rightLow, node.rightHigh, origin, inverse, hit.distance);\n let leftFirst = leftEnter <= rightEnter;\n let nearLink = select(node.rightLink, node.leftLink, leftFirst);\n let farEnter = select(leftEnter, rightEnter, leftFirst);\n let farLink = select(node.leftLink, node.rightLink, leftFirst);\n let parent = current;\n\n current = NO_NODE;\n\n // The nearer child: a miss means both missed.\n if (min(leftEnter, rightEnter) < 1e30) {\n if (nearLink < 0) {\n leaf = vec2<i32>(nearLink, select(node.rightCount, node.leftCount, leftFirst));\n } else {\n current = u32(nearLink);\n }\n }\n\n // The builder caps its depth so the far children always fit; the guard keeps a malformed tree inside the stack.\n if (farEnter < 1e30 && depth < 32u) {\n stack[depth] = select(u32(farLink), leafEntry(parent, leftFirst), farLink < 0);\n enters[depth] = farEnter;\n depth = depth + 1u;\n }\n }\n\n if (hit.triangle != NO_HIT) {\n hit.triangle = orderedTriangle(hit.triangle);\n }\n\n return hit;\n}\n\n/**\n * Whether anything at all lies along a ray before maxDistance, stopping at the first triangle it finds rather than the\n * closest: what a shadow ray asks when every surface it could meet blocks it. Returns that triangle, or NO_HIT. The\n * right child goes first and the left one waits, the order the binary tree's traversal took.\n */\nfn traceAny(origin: vec3<f32>, direction: vec3<f32>, maxDistance: f32) -> u32 {\n if (frame.triangleCount == 0u) {\n return NO_HIT;\n }\n\n let signs = select(vec3<f32>(-1.0), vec3<f32>(1.0), direction >= vec3<f32>(0.0));\n let inverse = signs / max(abs(direction), vec3<f32>(1e-20));\n\n var stack: array<u32, 32>;\n var depth = 0u;\n var current = 0u;\n var leaf = vec2<i32>(0, 0);\n\n loop {\n if (leaf.y > 0) {\n let found = anyInLeaf(leaf.x, leaf.y, origin, direction, maxDistance);\n\n if (found != NO_HIT) {\n return orderedTriangle(found);\n }\n\n leaf.y = 0;\n }\n\n if (current == NO_NODE) {\n if (depth == 0u) {\n break;\n }\n\n depth = depth - 1u;\n\n let entry = stack[depth];\n\n if ((entry & LEAF_ENTRY) != 0u) {\n leaf = waitingLeaf(entry);\n continue;\n }\n\n current = entry;\n }\n\n let node = nodes[current];\n let rightHit = enterBox(node.rightLow, node.rightHigh, origin, inverse, maxDistance) < 1e30;\n let leftHit = enterBox(node.leftLow, node.leftHigh, origin, inverse, maxDistance) < 1e30;\n let parent = current;\n\n current = NO_NODE;\n\n // The right child is taken now and the left one waits; with only one of them hit, that one is taken now.\n let takeRight = rightHit;\n let takenLink = select(node.leftLink, node.rightLink, takeRight);\n\n if (rightHit || leftHit) {\n if (takenLink < 0) {\n leaf = vec2<i32>(takenLink, select(node.leftCount, node.rightCount, takeRight));\n } else {\n current = u32(takenLink);\n }\n }\n\n if (rightHit && leftHit && depth < 32u) {\n stack[depth] = select(u32(node.leftLink), leafEntry(parent, false), node.leftLink < 0);\n depth = depth + 1u;\n }\n }\n\n return NO_HIT;\n}\n";
|
|
12
|
+
export declare const BVH_WGSL = "\n/** A corner of the triangle at this position of the hierarchy's leaf order. */\nfn leafVertex(at: u32, corner: u32) -> vec3<f32> {\n let base = at * 9u + corner * 3u;\n\n return vec3<f32>(positions[base], positions[base + 1u], positions[base + 2u]);\n}\n\n/** Where a triangle of the scene sits in the leaf order the positions are stored in. */\nfn leafOf(triangle: u32) -> u32 {\n return indices[frame.leafOffset + triangle];\n}\n\n/** A corner of a triangle a hit named, in world space. */\nfn triangleVertex(triangle: u32, corner: u32) -> vec3<f32> {\n let instance = instanceOf(triangle);\n let p = leafVertex(leafOf(storedTriangle(triangle, instance)), corner);\n\n if (instance != NO_INSTANCE) {\n return instancePoint(instance, p);\n }\n\n return p;\n}\n\n/** The stack entry that leaves an instance: the traversal goes back to world space. */\nconst RETURN_ENTRY: u32 = 0xffffffffu;\n\n/** A huge finite reciprocal instead of an infinite one: an axis aligned slab would otherwise produce 0 * inf. */\nfn rayInverse(direction: vec3<f32>) -> vec3<f32> {\n let signs = select(vec3<f32>(-1.0), vec3<f32>(1.0), direction >= vec3<f32>(0.0));\n\n return signs / max(abs(direction), vec3<f32>(1e-20));\n}\n\n/** The number a hit goes by, from where it sits in the leaf order and the instance it was found in. */\nfn namedTriangle(at: u32, instance: u32) -> u32 {\n let stored = orderedTriangle(at);\n\n if (INSTANCES && instance != NO_INSTANCE) {\n return instanceWord(instance, 26u) + stored - instanceWord(instance, 25u);\n }\n\n return stored;\n}\n\n/** Moller-Trumbore. Returns the distance in x and the barycentric coordinates in yz, or a negative distance. */\nfn intersectTriangle(at: u32, origin: vec3<f32>, direction: vec3<f32>) -> vec3<f32> {\n let miss = vec3<f32>(-1.0, 0.0, 0.0);\n let a = leafVertex(at, 0u);\n let edge1 = leafVertex(at, 1u) - a;\n let edge2 = leafVertex(at, 2u) - a;\n let p = cross(direction, edge2);\n let determinant = dot(edge1, p);\n\n if (abs(determinant) < 1e-12) {\n return miss;\n }\n\n let inverse = 1.0 / determinant;\n let offset = origin - a;\n let u = dot(offset, p) * inverse;\n\n if (u < 0.0 || u > 1.0) {\n return miss;\n }\n\n let q = cross(offset, edge1);\n let v = dot(direction, q) * inverse;\n\n if (v < 0.0 || u + v > 1.0) {\n return miss;\n }\n\n return vec3<f32>(dot(edge2, q) * inverse, u, v);\n}\n\n/** Where a ray enters a box, or 1e30 when it misses it or only meets it past maxDistance. */\nfn enterBox(low: vec3<f32>, high: vec3<f32>, origin: vec3<f32>, inverse: vec3<f32>, maxDistance: f32) -> f32 {\n let first = (low - origin) * inverse;\n let second = (high - origin) * inverse;\n let near = min(first, second);\n let far = max(first, second);\n let enter = max(max(near.x, near.y), max(near.z, 0.0));\n let exit = min(min(far.x, far.y), min(far.z, maxDistance));\n\n return select(1e30, enter, enter <= exit);\n}\n\n/** The triangles of a leaf, against the closest hit so far, which records where in the leaf order it found one. */\nfn intersectLeaf(link: i32, count: i32, origin: vec3<f32>, direction: vec3<f32>, hit: ptr<function, Hit>) {\n let start = u32(-1 - link);\n\n for (var i = 0u; i < u32(count); i = i + 1u) {\n let result = intersectTriangle(start + i, origin, direction);\n\n if (result.x > RAY_EPSILON && result.x < (*hit).distance) {\n (*hit).distance = result.x;\n (*hit).triangle = start + i;\n (*hit).u = result.y;\n (*hit).v = result.z;\n }\n }\n}\n\n/** Whether any triangle of a leaf lies along the ray before maxDistance: its position in the leaf order, or NO_HIT. */\nfn anyInLeaf(link: i32, count: i32, origin: vec3<f32>, direction: vec3<f32>, maxDistance: f32) -> u32 {\n let start = u32(-1 - link);\n\n for (var i = 0u; i < u32(count); i = i + 1u) {\n let result = intersectTriangle(start + i, origin, direction);\n\n if (result.x > RAY_EPSILON && result.x < maxDistance) {\n return start + i;\n }\n }\n\n return NO_HIT;\n}\n\n/** No node to go to: the traversal takes the next entry off the stack. */\nconst NO_NODE: u32 = 0xffffffffu;\n\n/**\n * A stack entry that is a leaf rather than a node: the node holding it and which of its two children it is. A leaf\n * has no node of its own, so this is how one waits its turn.\n */\nconst LEAF_ENTRY: u32 = 0x80000000u;\n\nfn leafEntry(parent: u32, right: bool) -> u32 {\n return LEAF_ENTRY | (parent << 1u) | select(0u, 1u, right);\n}\n\n/** A waiting leaf's link and count, read back from the node that holds it. */\nfn waitingLeaf(entry: u32) -> vec2<i32> {\n let parent = (entry & ~LEAF_ENTRY) >> 1u;\n\n if ((entry & 1u) != 0u) {\n return vec2<i32>(nodes[parent].rightLink, nodes[parent].rightCount);\n }\n\n return vec2<i32>(nodes[parent].leftLink, nodes[parent].leftCount);\n}\n\n/**\n * The closest hit along a ray. A node holds both of its children's boxes, so one read tests them both. The nearer is\n * visited first, so the closest hit shrinks the search early and whole subtrees behind it are skipped; the farther one\n * waits on the stack with where the ray entered it, and is dropped unopened if something closer turned up meanwhile.\n * A leaf is tested at the top of the next step, the one place the loop tests triangles, which keeps the kernel small.\n * This visits what the binary tree's traversal visited, in the same order, so it finds the same hit.\n */\nfn traceScene(worldOrigin: vec3<f32>, worldDirection: vec3<f32>, maxDistance: f32) -> Hit {\n var hit: Hit;\n hit.distance = maxDistance;\n hit.triangle = NO_HIT;\n hit.u = 0.0;\n hit.v = 0.0;\n\n if (frame.triangleCount == 0u) {\n return hit;\n }\n\n var origin = worldOrigin;\n var direction = worldDirection;\n var inverse = rayInverse(direction);\n // The instance the traversal is inside, and the one the closest hit so far was found in.\n var instance = NO_INSTANCE;\n var hitInstance = NO_INSTANCE;\n\n var stack: array<u32, BVH_STACK>;\n var enters: array<f32, BVH_STACK>;\n var depth = 0u;\n var current = 0u;\n // A leaf to test before anything else: its link, and its triangle count, zero when there is none.\n var leaf = vec2<i32>(0, 0);\n\n loop {\n if (leaf.y > 0) {\n let before = hit.distance;\n\n intersectLeaf(leaf.x, leaf.y, origin, direction, &hit);\n\n if (INSTANCES && hit.distance < before) {\n hitInstance = instance;\n }\n\n leaf.y = 0;\n }\n\n if (INSTANCES && leaf.y < 0) {\n leaf.y = 0;\n\n if (depth < BVH_STACK) {\n instance = u32(-1 - leaf.x);\n stack[depth] = RETURN_ENTRY;\n enters[depth] = -1.0;\n depth = depth + 1u;\n origin = instanceToObject(instance, worldOrigin, 1.0);\n direction = instanceToObject(instance, worldDirection, 0.0);\n inverse = rayInverse(direction);\n current = instanceWord(instance, 24u);\n }\n }\n\n if (current == NO_NODE) {\n if (depth == 0u) {\n break;\n }\n\n depth = depth - 1u;\n\n // Something closer was found since this was pushed.\n if (enters[depth] > hit.distance) {\n continue;\n }\n\n let entry = stack[depth];\n\n if (INSTANCES && entry == RETURN_ENTRY) {\n instance = NO_INSTANCE;\n origin = worldOrigin;\n direction = worldDirection;\n inverse = rayInverse(direction);\n continue;\n }\n\n if ((entry & LEAF_ENTRY) != 0u) {\n leaf = waitingLeaf(entry);\n continue;\n }\n\n current = entry;\n }\n\n let node = nodes[current];\n let leftEnter = enterBox(node.leftLow, node.leftHigh, origin, inverse, hit.distance);\n let rightEnter = enterBox(node.rightLow, node.rightHigh, origin, inverse, hit.distance);\n let leftFirst = leftEnter <= rightEnter;\n let nearLink = select(node.rightLink, node.leftLink, leftFirst);\n let farEnter = select(leftEnter, rightEnter, leftFirst);\n let farLink = select(node.leftLink, node.rightLink, leftFirst);\n let parent = current;\n\n current = NO_NODE;\n\n // The nearer child: a miss means both missed.\n if (min(leftEnter, rightEnter) < 1e30) {\n if (nearLink < 0) {\n leaf = vec2<i32>(nearLink, select(node.rightCount, node.leftCount, leftFirst));\n } else {\n current = u32(nearLink);\n }\n }\n\n // The builder caps its depth so the far children always fit; the guard keeps a malformed tree inside the stack.\n if (farEnter < 1e30 && depth < BVH_STACK) {\n stack[depth] = select(u32(farLink), leafEntry(parent, leftFirst), farLink < 0);\n enters[depth] = farEnter;\n depth = depth + 1u;\n }\n }\n\n if (hit.triangle != NO_HIT) {\n hit.triangle = namedTriangle(hit.triangle, hitInstance);\n }\n\n return hit;\n}\n\n/**\n * Whether anything at all lies along a ray before maxDistance, stopping at the first triangle it finds rather than the\n * closest: what a shadow ray asks when every surface it could meet blocks it. Returns that triangle, or NO_HIT. The\n * right child goes first and the left one waits, the order the binary tree's traversal took.\n */\nfn traceAny(worldOrigin: vec3<f32>, worldDirection: vec3<f32>, maxDistance: f32) -> u32 {\n if (frame.triangleCount == 0u) {\n return NO_HIT;\n }\n\n var origin = worldOrigin;\n var direction = worldDirection;\n var inverse = rayInverse(direction);\n var instance = NO_INSTANCE;\n\n var stack: array<u32, BVH_STACK>;\n var depth = 0u;\n var current = 0u;\n var leaf = vec2<i32>(0, 0);\n\n loop {\n if (leaf.y > 0) {\n let found = anyInLeaf(leaf.x, leaf.y, origin, direction, maxDistance);\n\n if (found != NO_HIT) {\n return namedTriangle(found, instance);\n }\n\n leaf.y = 0;\n }\n\n if (INSTANCES && leaf.y < 0) {\n leaf.y = 0;\n\n if (depth < BVH_STACK) {\n instance = u32(-1 - leaf.x);\n stack[depth] = RETURN_ENTRY;\n depth = depth + 1u;\n origin = instanceToObject(instance, worldOrigin, 1.0);\n direction = instanceToObject(instance, worldDirection, 0.0);\n inverse = rayInverse(direction);\n current = instanceWord(instance, 24u);\n }\n }\n\n if (current == NO_NODE) {\n if (depth == 0u) {\n break;\n }\n\n depth = depth - 1u;\n\n let entry = stack[depth];\n\n if (INSTANCES && entry == RETURN_ENTRY) {\n instance = NO_INSTANCE;\n origin = worldOrigin;\n direction = worldDirection;\n inverse = rayInverse(direction);\n continue;\n }\n\n if ((entry & LEAF_ENTRY) != 0u) {\n leaf = waitingLeaf(entry);\n continue;\n }\n\n current = entry;\n }\n\n let node = nodes[current];\n let rightHit = enterBox(node.rightLow, node.rightHigh, origin, inverse, maxDistance) < 1e30;\n let leftHit = enterBox(node.leftLow, node.leftHigh, origin, inverse, maxDistance) < 1e30;\n let parent = current;\n\n current = NO_NODE;\n\n // The right child is taken now and the left one waits; with only one of them hit, that one is taken now.\n let takeRight = rightHit;\n let takenLink = select(node.leftLink, node.rightLink, takeRight);\n\n if (rightHit || leftHit) {\n if (takenLink < 0) {\n leaf = vec2<i32>(takenLink, select(node.leftCount, node.rightCount, takeRight));\n } else {\n current = u32(takenLink);\n }\n }\n\n if (rightHit && leftHit && depth < BVH_STACK) {\n stack[depth] = select(u32(node.leftLink), leafEntry(parent, false), node.leftLink < 0);\n depth = depth + 1u;\n }\n }\n\n return NO_HIT;\n}\n";
|
|
9
13
|
//# sourceMappingURL=bvh.wgsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvh.wgsl.d.ts","sourceRoot":"","sources":["../../src/wgsl/bvh.wgsl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"bvh.wgsl.d.ts","sourceRoot":"","sources":["../../src/wgsl/bvh.wgsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,65WA8WpB,CAAC"}
|