@luma.gl/engine 10.0.0-alpha.10 → 10.0.0-alpha.11

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.
Files changed (208) hide show
  1. package/dist/animation/node-animation-binding.cjs +10 -0
  2. package/dist/animation/node-animation-binding.d.ts +1 -1
  3. package/dist/animation/node-animation-binding.d.ts.map +1 -1
  4. package/dist/animation/node-animation-binding.js +10 -0
  5. package/dist/animation/node-animation-binding.js.map +1 -1
  6. package/dist/dist.dev.js +325 -80
  7. package/dist/dist.min.js +58 -58
  8. package/dist/gltf/gltf/animations/animations.d.ts +1 -1
  9. package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
  10. package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
  11. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
  12. package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
  13. package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
  14. package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
  15. package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
  16. package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
  17. package/dist/gltf/gltf/gltf-billboard.js +6 -1
  18. package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
  19. package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
  20. package/dist/gltf/gltf/gltf-extension-support.js +2 -2
  21. package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
  22. package/dist/gltf/index.cjs +2 -0
  23. package/dist/gltf/index.cjs.map +3 -3
  24. package/dist/gltf/index.d.ts +1 -1
  25. package/dist/gltf/index.d.ts.map +1 -1
  26. package/dist/gltf/index.js +1 -1
  27. package/dist/gltf/index.js.map +1 -1
  28. package/dist/gltf/parsers/parse-gltf-animations.cjs +8 -5
  29. package/dist/gltf/parsers/parse-gltf-animations.js +20 -5
  30. package/dist/gltf/parsers/parse-gltf-animations.js.map +1 -1
  31. package/dist/gltf/parsers/parse-gltf-lights.cjs +36 -72
  32. package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
  33. package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
  34. package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
  35. package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
  36. package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
  37. package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
  38. package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
  39. package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
  40. package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
  41. package/dist/gltf/parsers/parse-gltf.cjs +4 -1
  42. package/dist/gltf/parsers/parse-gltf.d.ts +4 -0
  43. package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
  44. package/dist/gltf/parsers/parse-gltf.js +3 -0
  45. package/dist/gltf/parsers/parse-gltf.js.map +1 -1
  46. package/dist/gltf/pbr/pbr-environment.cjs +21 -3
  47. package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
  48. package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
  49. package/dist/gltf/pbr/pbr-environment.js +19 -1
  50. package/dist/gltf/pbr/pbr-environment.js.map +1 -1
  51. package/dist/graph/models/index.cjs.map +1 -1
  52. package/dist/graph/models/path/path-attribute-model.cjs +1 -1
  53. package/dist/graph/models/path/path-attribute-model.js +1 -1
  54. package/dist/graph/models/path/path-attribute-model.js.map +1 -1
  55. package/dist/graph/models/path/path-storage-model.cjs +1 -1
  56. package/dist/graph/models/path/path-storage-model.js +1 -1
  57. package/dist/graph/models/path/path-storage-model.js.map +1 -1
  58. package/dist/graph/physics/index.cjs.map +1 -1
  59. package/dist/graph/tables/index.cjs.map +1 -1
  60. package/dist/index.cjs +13 -0
  61. package/dist/index.cjs.map +3 -3
  62. package/dist/index.d.ts +4 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +3 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/lighting/ambient-occlusion-pass.cjs +126 -0
  67. package/dist/lighting/ambient-occlusion-pass.d.ts +31 -0
  68. package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
  69. package/dist/lighting/ambient-occlusion-pass.js +108 -0
  70. package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
  71. package/dist/lighting/clustered-light-grid.cjs +378 -0
  72. package/dist/lighting/clustered-light-grid.d.ts +94 -0
  73. package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
  74. package/dist/lighting/clustered-light-grid.js +370 -0
  75. package/dist/lighting/clustered-light-grid.js.map +1 -0
  76. package/dist/lighting/contact-shadow-composite.cjs +80 -0
  77. package/dist/lighting/contact-shadow-composite.d.ts +6 -0
  78. package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
  79. package/dist/lighting/contact-shadow-composite.js +59 -0
  80. package/dist/lighting/contact-shadow-composite.js.map +1 -0
  81. package/dist/lighting/contact-shadow-pass.cjs +102 -0
  82. package/dist/lighting/contact-shadow-pass.d.ts +23 -0
  83. package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
  84. package/dist/lighting/contact-shadow-pass.js +85 -0
  85. package/dist/lighting/contact-shadow-pass.js.map +1 -0
  86. package/dist/lighting/index.cjs +98 -0
  87. package/dist/lighting/index.cjs.map +6 -0
  88. package/dist/lighting/index.d.ts +23 -0
  89. package/dist/lighting/index.d.ts.map +1 -0
  90. package/dist/lighting/index.js +16 -0
  91. package/dist/lighting/index.js.map +1 -0
  92. package/dist/lighting/pbr-environment.cjs +45 -0
  93. package/dist/lighting/pbr-environment.d.ts +25 -0
  94. package/dist/lighting/pbr-environment.d.ts.map +1 -0
  95. package/dist/lighting/pbr-environment.js +30 -0
  96. package/dist/lighting/pbr-environment.js.map +1 -0
  97. package/dist/lighting/pbr-material.cjs +75 -0
  98. package/dist/lighting/pbr-material.d.ts +33 -0
  99. package/dist/lighting/pbr-material.d.ts.map +1 -0
  100. package/dist/lighting/pbr-material.js +52 -0
  101. package/dist/lighting/pbr-material.js.map +1 -0
  102. package/dist/lighting/pbr-model.cjs +509 -0
  103. package/dist/lighting/pbr-model.d.ts +41 -0
  104. package/dist/lighting/pbr-model.d.ts.map +1 -0
  105. package/dist/lighting/pbr-model.js +475 -0
  106. package/dist/lighting/pbr-model.js.map +1 -0
  107. package/dist/lighting/pbr-surface-pass.cjs +116 -0
  108. package/dist/lighting/pbr-surface-pass.d.ts +35 -0
  109. package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
  110. package/dist/lighting/pbr-surface-pass.js +98 -0
  111. package/dist/lighting/pbr-surface-pass.js.map +1 -0
  112. package/dist/lighting/prefiltered-environment.cjs +275 -0
  113. package/dist/lighting/prefiltered-environment.d.ts +56 -0
  114. package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
  115. package/dist/lighting/prefiltered-environment.js +264 -0
  116. package/dist/lighting/prefiltered-environment.js.map +1 -0
  117. package/dist/lighting/shadow-map-renderer.cjs +627 -0
  118. package/dist/lighting/shadow-map-renderer.d.ts +92 -0
  119. package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
  120. package/dist/lighting/shadow-map-renderer.js +617 -0
  121. package/dist/lighting/shadow-map-renderer.js.map +1 -0
  122. package/dist/lighting/shadow-quality.cjs +58 -0
  123. package/dist/lighting/shadow-quality.d.ts +13 -0
  124. package/dist/lighting/shadow-quality.d.ts.map +1 -0
  125. package/dist/lighting/shadow-quality.js +37 -0
  126. package/dist/lighting/shadow-quality.js.map +1 -0
  127. package/dist/material/material.cjs +3 -0
  128. package/dist/material/material.d.ts +2 -0
  129. package/dist/material/material.d.ts.map +1 -1
  130. package/dist/material/material.js +3 -0
  131. package/dist/material/material.js.map +1 -1
  132. package/dist/model/gpu-vector-model.cjs +11 -1
  133. package/dist/model/gpu-vector-model.d.ts +4 -2
  134. package/dist/model/gpu-vector-model.d.ts.map +1 -1
  135. package/dist/model/gpu-vector-model.js +12 -1
  136. package/dist/model/gpu-vector-model.js.map +1 -1
  137. package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
  138. package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
  139. package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
  140. package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
  141. package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
  142. package/dist/scenegraph/scene-metadata.cjs +43 -0
  143. package/dist/scenegraph/scene-metadata.d.ts +9 -0
  144. package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
  145. package/dist/scenegraph/scene-metadata.js +21 -0
  146. package/dist/scenegraph/scene-metadata.js.map +1 -0
  147. package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
  148. package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
  149. package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
  150. package/dist/scenegraph/scenegraph-interaction.js +79 -0
  151. package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
  152. package/dist/scenegraph/scenegraph-node.cjs +10 -0
  153. package/dist/scenegraph/scenegraph-node.d.ts +10 -0
  154. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  155. package/dist/scenegraph/scenegraph-node.js +10 -0
  156. package/dist/scenegraph/scenegraph-node.js.map +1 -1
  157. package/dist/text/experimental.cjs.map +1 -1
  158. package/dist/text/fonts/atlas/text-utils.cjs +1 -1
  159. package/dist/text/fonts/atlas/text-utils.js +1 -1
  160. package/dist/text/fonts/atlas/text-utils.js.map +1 -1
  161. package/dist/text/fonts/index.cjs.map +1 -1
  162. package/dist/text/index.cjs.map +1 -1
  163. package/dist/text/text-2d/models/text-attribute-model.cjs +1 -1
  164. package/dist/text/text-2d/models/text-attribute-model.js +1 -1
  165. package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
  166. package/dist/text/text-2d/models/text-dictionary-model.cjs +1 -1
  167. package/dist/text/text-2d/models/text-dictionary-model.js +1 -1
  168. package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
  169. package/dist/text/text-2d/models/text-storage-model.cjs +1 -1
  170. package/dist/text/text-2d/models/text-storage-model.js +1 -1
  171. package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
  172. package/package.json +13 -8
  173. package/src/animation/node-animation-binding.ts +18 -1
  174. package/src/gltf/gltf/animations/animations.ts +8 -1
  175. package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
  176. package/src/gltf/gltf/gltf-billboard.ts +6 -1
  177. package/src/gltf/gltf/gltf-extension-support.ts +2 -2
  178. package/src/gltf/index.ts +1 -0
  179. package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
  180. package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
  181. package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
  182. package/src/gltf/parsers/parse-gltf.ts +5 -0
  183. package/src/gltf/pbr/pbr-environment.ts +27 -1
  184. package/src/graph/models/path/path-attribute-model.ts +1 -1
  185. package/src/graph/models/path/path-storage-model.ts +1 -1
  186. package/src/index.ts +16 -0
  187. package/src/lighting/ambient-occlusion-pass.ts +130 -0
  188. package/src/lighting/clustered-light-grid.ts +481 -0
  189. package/src/lighting/contact-shadow-composite.ts +67 -0
  190. package/src/lighting/contact-shadow-pass.ts +107 -0
  191. package/src/lighting/index.ts +88 -0
  192. package/src/lighting/pbr-environment.ts +55 -0
  193. package/src/lighting/pbr-material.ts +85 -0
  194. package/src/lighting/pbr-model.ts +531 -0
  195. package/src/lighting/pbr-surface-pass.ts +122 -0
  196. package/src/lighting/prefiltered-environment.ts +354 -0
  197. package/src/lighting/shadow-map-renderer.ts +909 -0
  198. package/src/lighting/shadow-quality.ts +50 -0
  199. package/src/material/material.ts +3 -0
  200. package/src/model/gpu-vector-model.ts +18 -3
  201. package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
  202. package/src/scenegraph/scene-metadata.ts +23 -0
  203. package/src/scenegraph/scenegraph-interaction.ts +131 -0
  204. package/src/scenegraph/scenegraph-node.ts +12 -0
  205. package/src/text/fonts/atlas/text-utils.ts +1 -1
  206. package/src/text/text-2d/models/text-attribute-model.ts +1 -1
  207. package/src/text/text-2d/models/text-dictionary-model.ts +1 -1
  208. package/src/text/text-2d/models/text-storage-model.ts +1 -1
@@ -0,0 +1,370 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { assert, Buffer } from '@luma.gl/core';
5
+ import { Computation } from "../compute/computation.js";
6
+ /** Byte layout of each point-light record. The grid ignores the consumer payload. */
7
+ export const CLUSTERED_POINT_LIGHT_LAYOUT = Object.freeze({
8
+ byteStride: 32,
9
+ positionByteOffset: 0,
10
+ radiusByteOffset: 12,
11
+ payloadByteOffset: 16
12
+ });
13
+ export const MAX_CLUSTERED_POINT_LIGHTS = 512;
14
+ export const DEFAULT_CLUSTER_DIMENSIONS = [16, 9, 24];
15
+ export const DEFAULT_MAX_LIGHTS_PER_CLUSTER = 64;
16
+ const CLUSTER_WORKGROUP_SIZE = 64;
17
+ const CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH = 80;
18
+ /**
19
+ * Builds fixed-capacity screen/depth light lists entirely on WebGPU.
20
+ *
21
+ * One compute invocation projects each view-space point-light sphere into the overlapping
22
+ * x/y/z cluster range and atomically marks its light bit. A second compute dispatch compacts
23
+ * each bit mask in stable light-index order. Indices beyond maxLightsPerCluster are
24
+ * intentionally dropped so the fullscreen lighting pass has a predictable loop bound without
25
+ * nondeterministic overflow shimmer.
26
+ */
27
+ export class ClusteredLightGrid {
28
+ device;
29
+ id;
30
+ clusterDimensions;
31
+ maxLightsPerCluster;
32
+ maxLightCount;
33
+ clusterCount;
34
+ clusterLightCounts;
35
+ clusterLightIndices;
36
+ clusterLightBitMask;
37
+ uniformBuffer;
38
+ clearComputation;
39
+ binningComputation;
40
+ compactComputation;
41
+ activePointLightCount = 0;
42
+ depthRange = null;
43
+ destroyed = false;
44
+ constructor(device, props = {}) {
45
+ if (device.type !== 'webgpu') {
46
+ throw new Error('ClusteredLightGrid requires WebGPU.');
47
+ }
48
+ this.device = device;
49
+ this.id = props.id || 'clustered-light-grid';
50
+ this.clusterDimensions = props.clusterDimensions ?? DEFAULT_CLUSTER_DIMENSIONS;
51
+ this.maxLightsPerCluster = props.maxLightsPerCluster ?? DEFAULT_MAX_LIGHTS_PER_CLUSTER;
52
+ this.maxLightCount = props.maxLightCount ?? MAX_CLUSTERED_POINT_LIGHTS;
53
+ validateClusteredLightGridProps(this.clusterDimensions, this.maxLightsPerCluster, this.maxLightCount);
54
+ this.clusterCount =
55
+ this.clusterDimensions[0] * this.clusterDimensions[1] * this.clusterDimensions[2];
56
+ this.clusterLightCounts = device.createBuffer({
57
+ id: `${this.id}-counts`,
58
+ byteLength: this.clusterCount * Uint32Array.BYTES_PER_ELEMENT,
59
+ usage: Buffer.STORAGE | Buffer.COPY_SRC
60
+ });
61
+ this.clusterLightIndices = device.createBuffer({
62
+ id: `${this.id}-indices`,
63
+ byteLength: this.clusterCount * this.maxLightsPerCluster * Uint32Array.BYTES_PER_ELEMENT,
64
+ usage: Buffer.STORAGE | Buffer.COPY_SRC
65
+ });
66
+ const lightWordCount = getLightWordCount(this.maxLightCount);
67
+ this.clusterLightBitMask = device.createBuffer({
68
+ id: `${this.id}-light-mask`,
69
+ byteLength: this.clusterCount * lightWordCount * Uint32Array.BYTES_PER_ELEMENT,
70
+ usage: Buffer.STORAGE
71
+ });
72
+ this.uniformBuffer = device.createBuffer({
73
+ id: `${this.id}-uniforms`,
74
+ byteLength: CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH,
75
+ usage: Buffer.UNIFORM | Buffer.COPY_DST
76
+ });
77
+ this.clearComputation = new Computation(device, {
78
+ id: `${this.id}-clear`,
79
+ source: getClearClusterLightBitMaskSource(this.clusterCount, lightWordCount),
80
+ shaderLayout: {
81
+ bindings: [{ name: 'clusterLightBitMask', type: 'storage', group: 0, location: 0 }]
82
+ }
83
+ });
84
+ this.clearComputation.setBindings({ clusterLightBitMask: this.clusterLightBitMask });
85
+ this.binningComputation = new Computation(device, {
86
+ id: `${this.id}-bin`,
87
+ source: getClusterBinningSource(this.clusterDimensions, this.maxLightCount),
88
+ shaderLayout: {
89
+ bindings: [
90
+ { name: 'pointLights', type: 'read-only-storage', group: 0, location: 0 },
91
+ { name: 'clusterLightBitMask', type: 'storage', group: 0, location: 1 },
92
+ { name: 'clusteredLightGrid', type: 'uniform', group: 0, location: 2 }
93
+ ]
94
+ }
95
+ });
96
+ this.compactComputation = new Computation(device, {
97
+ id: `${this.id}-compact`,
98
+ source: getCompactClusterLightListsSource(this.clusterCount, lightWordCount, this.maxLightsPerCluster, this.maxLightCount),
99
+ shaderLayout: {
100
+ bindings: [
101
+ { name: 'clusterLightBitMask', type: 'storage', group: 0, location: 0 },
102
+ { name: 'clusterLightCounts', type: 'storage', group: 0, location: 1 },
103
+ { name: 'clusterLightIndices', type: 'storage', group: 0, location: 2 }
104
+ ]
105
+ }
106
+ });
107
+ }
108
+ /** Rebuilds cluster counts and light-index lists on the supplied command encoder. */
109
+ encode(commandEncoder, options) {
110
+ // Resources and encoder must be live and belong to this grid's device.
111
+ assert(!this.destroyed && !options.pointLights.destroyed && !commandEncoder.destroyed);
112
+ assert(options.pointLights.device === this.device && commandEncoder.device === this.device);
113
+ validateClusteredLightGridEncodeOptions(options, this.maxLightCount);
114
+ // The active prefix must fit in a storage buffer of complete point-light records.
115
+ assert(Boolean(options.pointLights.usage & Buffer.STORAGE));
116
+ assert(options.pointLights.byteLength >=
117
+ Math.max(1, options.pointLightCount) * CLUSTERED_POINT_LIGHT_LAYOUT.byteStride);
118
+ this.depthRange = [options.nearPlane, options.farPlane];
119
+ this.activePointLightCount = options.pointLightCount;
120
+ this.uniformBuffer.write(makeClusteredLightGridUniformData(options));
121
+ this.binningComputation.setBindings({
122
+ pointLights: options.pointLights,
123
+ clusterLightBitMask: this.clusterLightBitMask,
124
+ clusteredLightGrid: this.uniformBuffer
125
+ });
126
+ this.compactComputation.setBindings({
127
+ clusterLightBitMask: this.clusterLightBitMask,
128
+ clusterLightCounts: this.clusterLightCounts,
129
+ clusterLightIndices: this.clusterLightIndices
130
+ });
131
+ this.clearComputation.predraw(commandEncoder);
132
+ this.binningComputation.predraw(commandEncoder);
133
+ this.compactComputation.predraw(commandEncoder);
134
+ const computePass = commandEncoder.beginComputePass({ id: `${this.id}-build` });
135
+ this.clearComputation.dispatch(computePass, Math.ceil((this.clusterCount * getLightWordCount(this.maxLightCount)) / CLUSTER_WORKGROUP_SIZE));
136
+ this.binningComputation.dispatch(computePass, Math.max(1, Math.ceil(options.pointLightCount / CLUSTER_WORKGROUP_SIZE)));
137
+ this.compactComputation.dispatch(computePass, Math.ceil(this.clusterCount / CLUSTER_WORKGROUP_SIZE));
138
+ computePass.end();
139
+ }
140
+ /** Returns the storage bindings available to lighting consumers. */
141
+ getBindings() {
142
+ assert(!this.destroyed);
143
+ return {
144
+ clusterLightCounts: this.clusterLightCounts,
145
+ clusterLightIndices: this.clusterLightIndices
146
+ };
147
+ }
148
+ /** Compatibility accessor for shader-pass consumers. */
149
+ getShaderPassBindings() {
150
+ return this.getBindings();
151
+ }
152
+ /** Returns a snapshot matching the latest encode. Encode before requesting uniforms. */
153
+ getUniforms() {
154
+ // A grid must be encoded before its camera/depth metadata can be consumed.
155
+ assert(!this.destroyed && this.depthRange);
156
+ return this.getShaderPassUniforms(this.depthRange[0], this.depthRange[1]);
157
+ }
158
+ /** Returns the scalar uniforms available to lighting consumers. */
159
+ getShaderPassUniforms(nearPlane, farPlane) {
160
+ assert(!this.destroyed);
161
+ validateDepthRange(nearPlane, farPlane);
162
+ return {
163
+ clusterCountX: this.clusterDimensions[0],
164
+ clusterCountY: this.clusterDimensions[1],
165
+ clusterCountZ: this.clusterDimensions[2],
166
+ maxLightsPerCluster: this.maxLightsPerCluster,
167
+ pointLightCount: this.activePointLightCount,
168
+ clusterNearPlane: nearPlane,
169
+ clusterFarPlane: farPlane
170
+ };
171
+ }
172
+ destroy() {
173
+ if (this.destroyed)
174
+ return;
175
+ this.destroyed = true;
176
+ this.clearComputation.destroy();
177
+ this.binningComputation.destroy();
178
+ this.compactComputation.destroy();
179
+ this.uniformBuffer.destroy();
180
+ this.clusterLightBitMask.destroy();
181
+ this.clusterLightCounts.destroy();
182
+ this.clusterLightIndices.destroy();
183
+ }
184
+ }
185
+ function getClearClusterLightBitMaskSource(clusterCount, lightWordCount) {
186
+ return `\
187
+ const CLUSTER_LIGHT_MASK_WORD_COUNT: u32 = ${clusterCount * lightWordCount}u;
188
+ @group(0) @binding(0) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
189
+ @compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
190
+ @builtin(global_invocation_id) globalId: vec3<u32>
191
+ ) {
192
+ if (globalId.x < CLUSTER_LIGHT_MASK_WORD_COUNT) {
193
+ atomicStore(&clusterLightBitMask[globalId.x], 0u);
194
+ }
195
+ }`;
196
+ }
197
+ function getClusterBinningSource(clusterDimensions, maxLightCount) {
198
+ return `\
199
+ const CLUSTER_COUNT_X: u32 = ${clusterDimensions[0]}u;
200
+ const CLUSTER_COUNT_Y: u32 = ${clusterDimensions[1]}u;
201
+ const CLUSTER_COUNT_Z: u32 = ${clusterDimensions[2]}u;
202
+ const MAX_LIGHT_COUNT: u32 = ${maxLightCount}u;
203
+ const LIGHT_WORD_COUNT: u32 = ${getLightWordCount(maxLightCount)}u;
204
+
205
+ struct ClusteredLightGridUniforms {
206
+ projectionMatrix: mat4x4f,
207
+ depthRange: vec2f,
208
+ lightCount: u32,
209
+ padding: u32,
210
+ };
211
+
212
+ struct ClusteredLightGridPointLight {
213
+ positionRange: vec4f,
214
+ payload: vec4f,
215
+ };
216
+
217
+ @group(0) @binding(0) var<storage, read> pointLights: array<ClusteredLightGridPointLight>;
218
+ @group(0) @binding(1) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
219
+ @group(0) @binding(2) var<uniform> clusteredLightGrid: ClusteredLightGridUniforms;
220
+
221
+ fn clusteredLightGrid_getCoordinate(value: f32, size: u32) -> u32 {
222
+ return min(u32(clamp(value, 0.0, 0.999999) * f32(size)), size - 1u);
223
+ }
224
+
225
+ fn clusteredLightGrid_getDepthSlice(distance: f32) -> u32 {
226
+ let normalizedDepth = clamp(
227
+ log(distance / clusteredLightGrid.depthRange.x) /
228
+ log(clusteredLightGrid.depthRange.y / clusteredLightGrid.depthRange.x),
229
+ 0.0,
230
+ 0.999999
231
+ );
232
+ return min(u32(normalizedDepth * f32(CLUSTER_COUNT_Z)), CLUSTER_COUNT_Z - 1u);
233
+ }
234
+
235
+ @compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
236
+ @builtin(global_invocation_id) globalId: vec3<u32>
237
+ ) {
238
+ let lightIndex = globalId.x;
239
+ let lightCount = min(clusteredLightGrid.lightCount, min(MAX_LIGHT_COUNT, arrayLength(&pointLights)));
240
+ if (lightIndex >= lightCount) {
241
+ return;
242
+ }
243
+
244
+ let light = pointLights[lightIndex];
245
+ let viewDepth = -light.positionRange.z;
246
+ let minimumDepth = max(clusteredLightGrid.depthRange.x, viewDepth - light.positionRange.w);
247
+ let maximumDepth = min(clusteredLightGrid.depthRange.y, viewDepth + light.positionRange.w);
248
+ if (maximumDepth < clusteredLightGrid.depthRange.x ||
249
+ minimumDepth > clusteredLightGrid.depthRange.y ||
250
+ maximumDepth < minimumDepth) {
251
+ return;
252
+ }
253
+
254
+ let isOrthographicProjection = abs(clusteredLightGrid.projectionMatrix[3][3]) > 0.5;
255
+ var minimumUv = vec2f(0.0);
256
+ var maximumUv = vec2f(0.999999);
257
+ // A sphere crossing the camera plane conservatively covers the viewport.
258
+ if (isOrthographicProjection || viewDepth > light.positionRange.w) {
259
+ let projectionScale = vec2f(clusteredLightGrid.projectionMatrix[0][0], clusteredLightGrid.projectionMatrix[1][1]);
260
+ let lower = projectionScale * (light.positionRange.xy - vec2f(light.positionRange.w));
261
+ let upper = projectionScale * (light.positionRange.xy + vec2f(light.positionRange.w));
262
+ var minimumNdc = min(lower, upper) + clusteredLightGrid.projectionMatrix[3].xy;
263
+ var maximumNdc = max(lower, upper) + clusteredLightGrid.projectionMatrix[3].xy;
264
+ if (!isOrthographicProjection) {
265
+ // Project the enclosing box at both depth extremes, including off-axis centers.
266
+ let nearestDepth = max(minimumDepth, clusteredLightGrid.depthRange.x);
267
+ let farthestDepth = max(maximumDepth, nearestDepth);
268
+ minimumNdc = min(min(lower / nearestDepth, upper / nearestDepth), min(lower / farthestDepth, upper / farthestDepth)) - clusteredLightGrid.projectionMatrix[2].xy;
269
+ maximumNdc = max(max(lower / nearestDepth, upper / nearestDepth), max(lower / farthestDepth, upper / farthestDepth)) - clusteredLightGrid.projectionMatrix[2].xy;
270
+ }
271
+ let unclampedMinimumUv = vec2f(minimumNdc.x * 0.5 + 0.5, 0.5 - maximumNdc.y * 0.5);
272
+ let unclampedMaximumUv = vec2f(maximumNdc.x * 0.5 + 0.5, 0.5 - minimumNdc.y * 0.5);
273
+ if (unclampedMaximumUv.x < 0.0 || unclampedMinimumUv.x > 1.0 ||
274
+ unclampedMaximumUv.y < 0.0 || unclampedMinimumUv.y > 1.0) {
275
+ return;
276
+ }
277
+
278
+ minimumUv = clamp(unclampedMinimumUv, vec2f(0.0), vec2f(0.999999));
279
+ maximumUv = clamp(unclampedMaximumUv, vec2f(0.0), vec2f(0.999999));
280
+ }
281
+ let minimumX = clusteredLightGrid_getCoordinate(minimumUv.x, CLUSTER_COUNT_X);
282
+ let maximumX = clusteredLightGrid_getCoordinate(maximumUv.x, CLUSTER_COUNT_X);
283
+ let minimumY = clusteredLightGrid_getCoordinate(minimumUv.y, CLUSTER_COUNT_Y);
284
+ let maximumY = clusteredLightGrid_getCoordinate(maximumUv.y, CLUSTER_COUNT_Y);
285
+ let minimumZ = clusteredLightGrid_getDepthSlice(minimumDepth);
286
+ let maximumZ = clusteredLightGrid_getDepthSlice(maximumDepth);
287
+ let lightWordIndex = lightIndex / 32u;
288
+ let lightBit = 1u << (lightIndex % 32u);
289
+
290
+ for (var depthSlice = minimumZ; depthSlice <= maximumZ; depthSlice++) {
291
+ for (var tileY = minimumY; tileY <= maximumY; tileY++) {
292
+ for (var tileX = minimumX; tileX <= maximumX; tileX++) {
293
+ let clusterIndex = (depthSlice * CLUSTER_COUNT_Y + tileY) * CLUSTER_COUNT_X + tileX;
294
+ atomicOr(&clusterLightBitMask[clusterIndex * LIGHT_WORD_COUNT + lightWordIndex], lightBit);
295
+ }
296
+ }
297
+ }
298
+ }`;
299
+ }
300
+ function getCompactClusterLightListsSource(clusterCount, lightWordCount, maxLightsPerCluster, maxLightCount) {
301
+ return `\
302
+ const CLUSTER_COUNT: u32 = ${clusterCount}u;
303
+ const LIGHT_WORD_COUNT: u32 = ${lightWordCount}u;
304
+ const MAX_LIGHTS_PER_CLUSTER: u32 = ${maxLightsPerCluster}u;
305
+ const MAX_LIGHT_COUNT: u32 = ${maxLightCount}u;
306
+
307
+ @group(0) @binding(0) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
308
+ @group(0) @binding(1) var<storage, read_write> clusterLightCounts: array<u32>;
309
+ @group(0) @binding(2) var<storage, read_write> clusterLightIndices: array<u32>;
310
+
311
+ @compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
312
+ @builtin(global_invocation_id) globalId: vec3<u32>
313
+ ) {
314
+ let clusterIndex = globalId.x;
315
+ if (clusterIndex >= CLUSTER_COUNT) {
316
+ return;
317
+ }
318
+
319
+ let maskOffset = clusterIndex * LIGHT_WORD_COUNT;
320
+ let indexOffset = clusterIndex * MAX_LIGHTS_PER_CLUSTER;
321
+ var lightCount = 0u;
322
+ for (var lightIndex = 0u; lightIndex < MAX_LIGHT_COUNT; lightIndex++) {
323
+ let lightWord = atomicLoad(&clusterLightBitMask[maskOffset + lightIndex / 32u]);
324
+ let lightBit = 1u << (lightIndex % 32u);
325
+ if ((lightWord & lightBit) != 0u) {
326
+ if (lightCount < MAX_LIGHTS_PER_CLUSTER) {
327
+ clusterLightIndices[indexOffset + lightCount] = lightIndex;
328
+ }
329
+ lightCount += 1u;
330
+ }
331
+ }
332
+ clusterLightCounts[clusterIndex] = lightCount;
333
+ }`;
334
+ }
335
+ function getLightWordCount(maxLightCount) {
336
+ return Math.ceil(maxLightCount / 32);
337
+ }
338
+ function makeClusteredLightGridUniformData(options) {
339
+ const data = new ArrayBuffer(CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH);
340
+ const floatValues = new Float32Array(data);
341
+ floatValues.set(options.projectionMatrix, 0);
342
+ floatValues[16] = options.nearPlane;
343
+ floatValues[17] = options.farPlane;
344
+ new Uint32Array(data)[18] = options.pointLightCount;
345
+ return data;
346
+ }
347
+ function validateClusteredLightGridProps(clusterDimensions, maxLightsPerCluster, maxLightCount) {
348
+ if (clusterDimensions.some(dimension => !Number.isSafeInteger(dimension) || dimension < 1) ||
349
+ !Number.isSafeInteger(maxLightsPerCluster) ||
350
+ maxLightsPerCluster < 1 ||
351
+ !Number.isSafeInteger(maxLightCount) ||
352
+ maxLightCount < 1) {
353
+ throw new Error('Cluster dimensions and capacities must be positive safe integers.');
354
+ }
355
+ }
356
+ function validateClusteredLightGridEncodeOptions(options, maxLightCount) {
357
+ if (!Number.isSafeInteger(options.pointLightCount) || options.pointLightCount < 0) {
358
+ throw new Error('Point light count must be a non-negative safe integer.');
359
+ }
360
+ if (options.pointLightCount > maxLightCount) {
361
+ throw new Error('Point light count exceeds ClusteredLightGrid capacity.');
362
+ }
363
+ validateDepthRange(options.nearPlane, options.farPlane);
364
+ }
365
+ function validateDepthRange(nearPlane, farPlane) {
366
+ if (!(nearPlane > 0) || !(farPlane > nearPlane)) {
367
+ throw new Error('Cluster depth range requires 0 < nearPlane < farPlane.');
368
+ }
369
+ }
370
+ //# sourceMappingURL=clustered-light-grid.js.map
@@ -0,0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AC;QACD,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;AACH,CAAC;AAED,SAAS,uCAAuC,CAC9C,OAAwC,EACxC,aAAqB;IAErB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;QAClF,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,OAAO,CAAC,eAAe,GAAG,aAAa,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAiB,EAAE,QAAgB;IAC7D,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
@@ -0,0 +1,80 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var contact_shadow_composite_exports = {};
19
+ __export(contact_shadow_composite_exports, {
20
+ createContactShadowCompositeShaderPass: () => createContactShadowCompositeShaderPass
21
+ });
22
+ module.exports = __toCommonJS(contact_shadow_composite_exports);
23
+ var import_shaders = require("@luma.gl/shaders");
24
+ var import_shadow_quality = require("./shadow-quality.cjs");
25
+ function createContactShadowCompositeShaderPass(options = {}) {
26
+ const quality = options.quality || "balanced";
27
+ const settings = import_shadow_quality.SHADOW_QUALITY_SETTINGS[quality];
28
+ if (!settings) {
29
+ throw new Error(`Unknown shadow quality: ${String(quality)}.`);
30
+ }
31
+ return {
32
+ name: "contactShadowCompositeShaderPass",
33
+ renderTargets: {
34
+ contactShadowRaw: {
35
+ scale: [settings.contactScale, settings.contactScale],
36
+ format: "rgba8unorm"
37
+ },
38
+ contactShadowScratch: {
39
+ scale: [settings.contactScale, settings.contactScale],
40
+ format: "rgba8unorm"
41
+ },
42
+ contactShadowFiltered: {
43
+ scale: [settings.contactScale, settings.contactScale],
44
+ format: "rgba8unorm"
45
+ }
46
+ },
47
+ steps: [
48
+ {
49
+ shaderPass: import_shaders.contactShadowTrace,
50
+ inputs: { sourceTexture: "previous" },
51
+ output: "contactShadowRaw",
52
+ uniforms: { stepCount: settings.contactStepCount }
53
+ },
54
+ {
55
+ shaderPass: import_shaders.contactShadowBilateralBlur,
56
+ inputs: { sourceTexture: "contactShadowRaw" },
57
+ output: "contactShadowScratch",
58
+ uniforms: { direction: [1, 0] }
59
+ },
60
+ {
61
+ shaderPass: import_shaders.contactShadowBilateralBlur,
62
+ inputs: { sourceTexture: "contactShadowScratch" },
63
+ output: "contactShadowFiltered",
64
+ uniforms: { direction: [0, 1] }
65
+ },
66
+ {
67
+ shaderPass: import_shaders.contactShadowComposite,
68
+ inputs: {
69
+ sourceTexture: "previous",
70
+ contactShadowTexture: "contactShadowFiltered"
71
+ },
72
+ output: "previous"
73
+ }
74
+ ]
75
+ };
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ createContactShadowCompositeShaderPass
80
+ });
@@ -0,0 +1,6 @@
1
+ import type { CompositeShaderPass } from '@luma.gl/shaders';
2
+ /** Builds the quality-scaled trace, bilateral cleanup, and direct-light composite pipeline. */
3
+ export declare function createContactShadowCompositeShaderPass(options?: {
4
+ quality?: 'low' | 'balanced' | 'cinematic';
5
+ }): CompositeShaderPass<'contactShadowRaw' | 'contactShadowScratch' | 'contactShadowFiltered'>;
6
+ //# sourceMappingURL=contact-shadow-composite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-shadow-composite.d.ts","sourceRoot":"","sources":["../../src/lighting/contact-shadow-composite.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAQ1D,+FAA+F;AAC/F,wBAAgB,sCAAsC,CACpD,OAAO,GAAE;IAAC,OAAO,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,WAAW,CAAA;CAAM,GACzD,mBAAmB,CAAC,kBAAkB,GAAG,sBAAsB,GAAG,uBAAuB,CAAC,CAmD5F"}
@@ -0,0 +1,59 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { contactShadowTrace, contactShadowBilateralBlur, contactShadowComposite } from '@luma.gl/shaders';
5
+ import { SHADOW_QUALITY_SETTINGS } from "./shadow-quality.js";
6
+ /** Builds the quality-scaled trace, bilateral cleanup, and direct-light composite pipeline. */
7
+ export function createContactShadowCompositeShaderPass(options = {}) {
8
+ const quality = options.quality || 'balanced';
9
+ const settings = SHADOW_QUALITY_SETTINGS[quality];
10
+ if (!settings) {
11
+ throw new Error(`Unknown shadow quality: ${String(quality)}.`);
12
+ }
13
+ return {
14
+ name: 'contactShadowCompositeShaderPass',
15
+ renderTargets: {
16
+ contactShadowRaw: {
17
+ scale: [settings.contactScale, settings.contactScale],
18
+ format: 'rgba8unorm'
19
+ },
20
+ contactShadowScratch: {
21
+ scale: [settings.contactScale, settings.contactScale],
22
+ format: 'rgba8unorm'
23
+ },
24
+ contactShadowFiltered: {
25
+ scale: [settings.contactScale, settings.contactScale],
26
+ format: 'rgba8unorm'
27
+ }
28
+ },
29
+ steps: [
30
+ {
31
+ shaderPass: contactShadowTrace,
32
+ inputs: { sourceTexture: 'previous' },
33
+ output: 'contactShadowRaw',
34
+ uniforms: { stepCount: settings.contactStepCount }
35
+ },
36
+ {
37
+ shaderPass: contactShadowBilateralBlur,
38
+ inputs: { sourceTexture: 'contactShadowRaw' },
39
+ output: 'contactShadowScratch',
40
+ uniforms: { direction: [1, 0] }
41
+ },
42
+ {
43
+ shaderPass: contactShadowBilateralBlur,
44
+ inputs: { sourceTexture: 'contactShadowScratch' },
45
+ output: 'contactShadowFiltered',
46
+ uniforms: { direction: [0, 1] }
47
+ },
48
+ {
49
+ shaderPass: contactShadowComposite,
50
+ inputs: {
51
+ sourceTexture: 'previous',
52
+ contactShadowTexture: 'contactShadowFiltered'
53
+ },
54
+ output: 'previous'
55
+ }
56
+ ]
57
+ };
58
+ }
59
+ //# sourceMappingURL=contact-shadow-composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-shadow-composite.js","sourceRoot":"","sources":["../../src/lighting/contact-shadow-composite.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,uBAAuB,EAAC,4BAAyB;AAEzD,+FAA+F;AAC/F,MAAM,UAAU,sCAAsC,CACpD,UAAwD,EAAE;IAE1D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC;IAC9C,MAAM,QAAQ,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,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,MAAM,EAAE,UAAU;aACnB;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,102 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var contact_shadow_pass_exports = {};
19
+ __export(contact_shadow_pass_exports, {
20
+ ContactShadowPass: () => ContactShadowPass
21
+ });
22
+ module.exports = __toCommonJS(contact_shadow_pass_exports);
23
+ var import_core = require("@luma.gl/core");
24
+ var import_shaders = require("@luma.gl/shaders");
25
+ var import_core2 = require("@math.gl/core");
26
+ var import_shader_pass_renderer = require("../passes/shader-pass-renderer.cjs");
27
+ var import_shadow_quality = require("./shadow-quality.cjs");
28
+ class ContactShadowPass {
29
+ device;
30
+ renderer;
31
+ destroyed = false;
32
+ constructor(device, props = {}) {
33
+ this.device = device;
34
+ const settings = import_shadow_quality.SHADOW_QUALITY_SETTINGS[props.quality ?? "balanced"];
35
+ const shaderPass = {
36
+ name: "contactShadowVisibility",
37
+ renderTargets: {
38
+ contactShadowRaw: {
39
+ scale: [settings.contactScale, settings.contactScale],
40
+ format: "rgba8unorm"
41
+ },
42
+ contactShadowScratch: {
43
+ scale: [settings.contactScale, settings.contactScale],
44
+ format: "rgba8unorm"
45
+ }
46
+ },
47
+ steps: [
48
+ {
49
+ shaderPass: import_shaders.contactShadowTrace,
50
+ inputs: { sourceTexture: "original" },
51
+ output: "contactShadowRaw",
52
+ uniforms: { stepCount: settings.contactStepCount }
53
+ },
54
+ {
55
+ shaderPass: import_shaders.contactShadowBilateralBlur,
56
+ inputs: { sourceTexture: "contactShadowRaw" },
57
+ output: "contactShadowScratch",
58
+ uniforms: { direction: [1, 0] }
59
+ },
60
+ {
61
+ shaderPass: import_shaders.contactShadowBilateralBlur,
62
+ inputs: { sourceTexture: "contactShadowScratch" },
63
+ output: "previous",
64
+ uniforms: { direction: [0, 1] }
65
+ }
66
+ ]
67
+ };
68
+ this.renderer = new import_shader_pass_renderer.ShaderPassRenderer(device, {
69
+ shaderPasses: [shaderPass],
70
+ colorFormat: "rgba8unorm"
71
+ });
72
+ }
73
+ /** Uses the backend-native projection and view-space normals/direction of the same camera. */
74
+ render(options) {
75
+ (0, import_core.assert)(!this.destroyed && options.depthTexture.device === this.device && options.normalTexture.device === this.device);
76
+ (0, import_core.assert)(options.depthTexture.width === options.normalTexture.width && options.depthTexture.height === options.normalTexture.height);
77
+ this.renderer.resize([options.normalTexture.width, options.normalTexture.height]);
78
+ const { depthTexture, normalTexture, ...traceProps } = options;
79
+ const texture = this.renderer.renderToTexture({
80
+ sourceTexture: normalTexture,
81
+ bindings: { depthTexture, normalTexture },
82
+ uniforms: {
83
+ contactShadowTrace: {
84
+ ...traceProps,
85
+ inverseProjectionMatrix: new import_core2.Matrix4(options.projectionMatrix).invert()
86
+ }
87
+ }
88
+ });
89
+ (0, import_core.assert)(texture);
90
+ return texture;
91
+ }
92
+ destroy() {
93
+ if (this.destroyed)
94
+ return;
95
+ this.destroyed = true;
96
+ this.renderer.destroy();
97
+ }
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ ContactShadowPass
102
+ });
@@ -0,0 +1,23 @@
1
+ import { type Device, type Texture } from '@luma.gl/core';
2
+ import { type ContactTraceUniforms } from '@luma.gl/shaders';
3
+ import { Matrix4, type NumberArray3, type NumberArray16 } from '@math.gl/core';
4
+ export type ContactShadowPassProps = {
5
+ quality?: 'low' | 'balanced' | 'cinematic';
6
+ };
7
+ export type ContactShadowRenderOptions = Partial<Omit<ContactTraceUniforms, 'projectionMatrix' | 'inverseProjectionMatrix' | 'lightDirectionView'>> & {
8
+ projectionMatrix: Readonly<Matrix4 | NumberArray16>;
9
+ lightDirectionView: Readonly<NumberArray3>;
10
+ depthTexture: Texture;
11
+ normalTexture: Texture;
12
+ };
13
+ /** Prepares a screen-space visibility texture for one directional light. No history or submission. */
14
+ export declare class ContactShadowPass {
15
+ readonly device: Device;
16
+ private readonly renderer;
17
+ private destroyed;
18
+ constructor(device: Device, props?: ContactShadowPassProps);
19
+ /** Uses the backend-native projection and view-space normals/direction of the same camera. */
20
+ render(options: ContactShadowRenderOptions): Texture;
21
+ destroy(): void;
22
+ }
23
+ //# sourceMappingURL=contact-shadow-pass.d.ts.map