@flighthq/scene3d-wgpu 0.2.1-next.840.857425c

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 (263) hide show
  1. package/dist/anisotropyPbrWgpuMeshMaterialRenderer.d.ts +4 -0
  2. package/dist/anisotropyPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  3. package/dist/anisotropyPbrWgpuMeshMaterialRenderer.js +52 -0
  4. package/dist/anisotropyPbrWgpuMeshMaterialRenderer.js.map +1 -0
  5. package/dist/blinnPhongWgpuMeshMaterialRenderer.d.ts +4 -0
  6. package/dist/blinnPhongWgpuMeshMaterialRenderer.d.ts.map +1 -0
  7. package/dist/blinnPhongWgpuMeshMaterialRenderer.js +66 -0
  8. package/dist/blinnPhongWgpuMeshMaterialRenderer.js.map +1 -0
  9. package/dist/clearcoatPbrWgpuMeshMaterialRenderer.d.ts +4 -0
  10. package/dist/clearcoatPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  11. package/dist/clearcoatPbrWgpuMeshMaterialRenderer.js +52 -0
  12. package/dist/clearcoatPbrWgpuMeshMaterialRenderer.js.map +1 -0
  13. package/dist/customShaderWgpuMeshMaterialRenderer.d.ts +7 -0
  14. package/dist/customShaderWgpuMeshMaterialRenderer.d.ts.map +1 -0
  15. package/dist/customShaderWgpuMeshMaterialRenderer.js +225 -0
  16. package/dist/customShaderWgpuMeshMaterialRenderer.js.map +1 -0
  17. package/dist/depthWgpuMeshMaterialRenderer.d.ts +4 -0
  18. package/dist/depthWgpuMeshMaterialRenderer.d.ts.map +1 -0
  19. package/dist/depthWgpuMeshMaterialRenderer.js +42 -0
  20. package/dist/depthWgpuMeshMaterialRenderer.js.map +1 -0
  21. package/dist/drawWgpuScene3D.d.ts +4 -0
  22. package/dist/drawWgpuScene3D.d.ts.map +1 -0
  23. package/dist/drawWgpuScene3D.js +171 -0
  24. package/dist/drawWgpuScene3D.js.map +1 -0
  25. package/dist/emissiveWgpuMeshMaterialRenderer.d.ts +4 -0
  26. package/dist/emissiveWgpuMeshMaterialRenderer.d.ts.map +1 -0
  27. package/dist/emissiveWgpuMeshMaterialRenderer.js +51 -0
  28. package/dist/emissiveWgpuMeshMaterialRenderer.js.map +1 -0
  29. package/dist/enableWgpuScene3DCustomShaderGuards.d.ts +5 -0
  30. package/dist/enableWgpuScene3DCustomShaderGuards.d.ts.map +1 -0
  31. package/dist/enableWgpuScene3DCustomShaderGuards.js +56 -0
  32. package/dist/enableWgpuScene3DCustomShaderGuards.js.map +1 -0
  33. package/dist/enableWgpuScene3DForwardLightSelectionGuards.d.ts +4 -0
  34. package/dist/enableWgpuScene3DForwardLightSelectionGuards.d.ts.map +1 -0
  35. package/dist/enableWgpuScene3DForwardLightSelectionGuards.js +17 -0
  36. package/dist/enableWgpuScene3DForwardLightSelectionGuards.js.map +1 -0
  37. package/dist/explainWgpuScene3DForwardLightSelection.d.ts +3 -0
  38. package/dist/explainWgpuScene3DForwardLightSelection.d.ts.map +1 -0
  39. package/dist/explainWgpuScene3DForwardLightSelection.js +18 -0
  40. package/dist/explainWgpuScene3DForwardLightSelection.js.map +1 -0
  41. package/dist/index.d.ts +51 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +51 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/iridescencePbrWgpuMeshMaterialRenderer.d.ts +4 -0
  46. package/dist/iridescencePbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  47. package/dist/iridescencePbrWgpuMeshMaterialRenderer.js +60 -0
  48. package/dist/iridescencePbrWgpuMeshMaterialRenderer.js.map +1 -0
  49. package/dist/lambertWgpuMeshMaterialRenderer.d.ts +4 -0
  50. package/dist/lambertWgpuMeshMaterialRenderer.d.ts.map +1 -0
  51. package/dist/lambertWgpuMeshMaterialRenderer.js +61 -0
  52. package/dist/lambertWgpuMeshMaterialRenderer.js.map +1 -0
  53. package/dist/matcapWgpuMeshMaterialRenderer.d.ts +4 -0
  54. package/dist/matcapWgpuMeshMaterialRenderer.d.ts.map +1 -0
  55. package/dist/matcapWgpuMeshMaterialRenderer.js +54 -0
  56. package/dist/matcapWgpuMeshMaterialRenderer.js.map +1 -0
  57. package/dist/normalWgpuMeshMaterialRenderer.d.ts +4 -0
  58. package/dist/normalWgpuMeshMaterialRenderer.d.ts.map +1 -0
  59. package/dist/normalWgpuMeshMaterialRenderer.js +47 -0
  60. package/dist/normalWgpuMeshMaterialRenderer.js.map +1 -0
  61. package/dist/phongWgpuMeshMaterialRenderer.d.ts +4 -0
  62. package/dist/phongWgpuMeshMaterialRenderer.d.ts.map +1 -0
  63. package/dist/phongWgpuMeshMaterialRenderer.js +63 -0
  64. package/dist/phongWgpuMeshMaterialRenderer.js.map +1 -0
  65. package/dist/prepareWgpuScene3DForwardLights.d.ts +3 -0
  66. package/dist/prepareWgpuScene3DForwardLights.d.ts.map +1 -0
  67. package/dist/prepareWgpuScene3DForwardLights.js +110 -0
  68. package/dist/prepareWgpuScene3DForwardLights.js.map +1 -0
  69. package/dist/registerStandardPbrWgpuMaterial.d.ts +3 -0
  70. package/dist/registerStandardPbrWgpuMaterial.d.ts.map +1 -0
  71. package/dist/registerStandardPbrWgpuMaterial.js +11 -0
  72. package/dist/registerStandardPbrWgpuMaterial.js.map +1 -0
  73. package/dist/shadedWgpuMeshMaterialRenderer.d.ts +11 -0
  74. package/dist/shadedWgpuMeshMaterialRenderer.d.ts.map +1 -0
  75. package/dist/shadedWgpuMeshMaterialRenderer.js +47 -0
  76. package/dist/shadedWgpuMeshMaterialRenderer.js.map +1 -0
  77. package/dist/sheenPbrWgpuMeshMaterialRenderer.d.ts +4 -0
  78. package/dist/sheenPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  79. package/dist/sheenPbrWgpuMeshMaterialRenderer.js +58 -0
  80. package/dist/sheenPbrWgpuMeshMaterialRenderer.js.map +1 -0
  81. package/dist/specularGlossinessPbrWgpuMeshMaterialRenderer.d.ts +4 -0
  82. package/dist/specularGlossinessPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  83. package/dist/specularGlossinessPbrWgpuMeshMaterialRenderer.js +126 -0
  84. package/dist/specularGlossinessPbrWgpuMeshMaterialRenderer.js.map +1 -0
  85. package/dist/specularPbrWgpuMeshMaterialRenderer.d.ts +4 -0
  86. package/dist/specularPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  87. package/dist/specularPbrWgpuMeshMaterialRenderer.js +65 -0
  88. package/dist/specularPbrWgpuMeshMaterialRenderer.js.map +1 -0
  89. package/dist/standardPbrWgpuMeshMaterialRenderer.d.ts +9 -0
  90. package/dist/standardPbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  91. package/dist/standardPbrWgpuMeshMaterialRenderer.js +174 -0
  92. package/dist/standardPbrWgpuMeshMaterialRenderer.js.map +1 -0
  93. package/dist/subsurfacePbrWgpuMeshMaterialRenderer.d.ts +4 -0
  94. package/dist/subsurfacePbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  95. package/dist/subsurfacePbrWgpuMeshMaterialRenderer.js +68 -0
  96. package/dist/subsurfacePbrWgpuMeshMaterialRenderer.js.map +1 -0
  97. package/dist/toonWgpuMeshMaterialRenderer.d.ts +4 -0
  98. package/dist/toonWgpuMeshMaterialRenderer.d.ts.map +1 -0
  99. package/dist/toonWgpuMeshMaterialRenderer.js +71 -0
  100. package/dist/toonWgpuMeshMaterialRenderer.js.map +1 -0
  101. package/dist/transmissionVolumePbrWgpuMeshMaterialRenderer.d.ts +4 -0
  102. package/dist/transmissionVolumePbrWgpuMeshMaterialRenderer.d.ts.map +1 -0
  103. package/dist/transmissionVolumePbrWgpuMeshMaterialRenderer.js +74 -0
  104. package/dist/transmissionVolumePbrWgpuMeshMaterialRenderer.js.map +1 -0
  105. package/dist/unlitWgpuMeshMaterialRenderer.d.ts +4 -0
  106. package/dist/unlitWgpuMeshMaterialRenderer.d.ts.map +1 -0
  107. package/dist/unlitWgpuMeshMaterialRenderer.js +57 -0
  108. package/dist/unlitWgpuMeshMaterialRenderer.js.map +1 -0
  109. package/dist/vertexColorWgpuMeshMaterialRenderer.d.ts +4 -0
  110. package/dist/vertexColorWgpuMeshMaterialRenderer.d.ts.map +1 -0
  111. package/dist/vertexColorWgpuMeshMaterialRenderer.js +55 -0
  112. package/dist/vertexColorWgpuMeshMaterialRenderer.js.map +1 -0
  113. package/dist/wgpuClassicPrelude.d.ts +8 -0
  114. package/dist/wgpuClassicPrelude.d.ts.map +1 -0
  115. package/dist/wgpuClassicPrelude.js +319 -0
  116. package/dist/wgpuClassicPrelude.js.map +1 -0
  117. package/dist/wgpuCustomMaterialAbi.d.ts +3 -0
  118. package/dist/wgpuCustomMaterialAbi.d.ts.map +1 -0
  119. package/dist/wgpuCustomMaterialAbi.js +5 -0
  120. package/dist/wgpuCustomMaterialAbi.js.map +1 -0
  121. package/dist/wgpuDebugPrelude.d.ts +7 -0
  122. package/dist/wgpuDebugPrelude.d.ts.map +1 -0
  123. package/dist/wgpuDebugPrelude.js +133 -0
  124. package/dist/wgpuDebugPrelude.js.map +1 -0
  125. package/dist/wgpuEnvironmentCube.d.ts +4 -0
  126. package/dist/wgpuEnvironmentCube.d.ts.map +1 -0
  127. package/dist/wgpuEnvironmentCube.js +66 -0
  128. package/dist/wgpuEnvironmentCube.js.map +1 -0
  129. package/dist/wgpuEnvironmentIblBake.d.ts +4 -0
  130. package/dist/wgpuEnvironmentIblBake.d.ts.map +1 -0
  131. package/dist/wgpuEnvironmentIblBake.js +458 -0
  132. package/dist/wgpuEnvironmentIblBake.js.map +1 -0
  133. package/dist/wgpuEnvironmentSkybox.d.ts +3 -0
  134. package/dist/wgpuEnvironmentSkybox.d.ts.map +1 -0
  135. package/dist/wgpuEnvironmentSkybox.js +159 -0
  136. package/dist/wgpuEnvironmentSkybox.js.map +1 -0
  137. package/dist/wgpuMatcapPrelude.d.ts +7 -0
  138. package/dist/wgpuMatcapPrelude.d.ts.map +1 -0
  139. package/dist/wgpuMatcapPrelude.js +134 -0
  140. package/dist/wgpuMatcapPrelude.js.map +1 -0
  141. package/dist/wgpuMeshMaterialRegistry.d.ts +5 -0
  142. package/dist/wgpuMeshMaterialRegistry.d.ts.map +1 -0
  143. package/dist/wgpuMeshMaterialRegistry.js +29 -0
  144. package/dist/wgpuMeshMaterialRegistry.js.map +1 -0
  145. package/dist/wgpuMeshPipeline.d.ts +43 -0
  146. package/dist/wgpuMeshPipeline.d.ts.map +1 -0
  147. package/dist/wgpuMeshPipeline.js +1007 -0
  148. package/dist/wgpuMeshPipeline.js.map +1 -0
  149. package/dist/wgpuMeshUpload.d.ts +3 -0
  150. package/dist/wgpuMeshUpload.d.ts.map +1 -0
  151. package/dist/wgpuMeshUpload.js +58 -0
  152. package/dist/wgpuMeshUpload.js.map +1 -0
  153. package/dist/wgpuParticleEmitter3D.d.ts +4 -0
  154. package/dist/wgpuParticleEmitter3D.d.ts.map +1 -0
  155. package/dist/wgpuParticleEmitter3D.js +403 -0
  156. package/dist/wgpuParticleEmitter3D.js.map +1 -0
  157. package/dist/wgpuPbrPipelineCache.d.ts +4 -0
  158. package/dist/wgpuPbrPipelineCache.d.ts.map +1 -0
  159. package/dist/wgpuPbrPipelineCache.js +52 -0
  160. package/dist/wgpuPbrPipelineCache.js.map +1 -0
  161. package/dist/wgpuPbrPrelude.d.ts +7 -0
  162. package/dist/wgpuPbrPrelude.d.ts.map +1 -0
  163. package/dist/wgpuPbrPrelude.js +551 -0
  164. package/dist/wgpuPbrPrelude.js.map +1 -0
  165. package/dist/wgpuScene3DRuntime.d.ts +5 -0
  166. package/dist/wgpuScene3DRuntime.d.ts.map +1 -0
  167. package/dist/wgpuScene3DRuntime.js +81 -0
  168. package/dist/wgpuScene3DRuntime.js.map +1 -0
  169. package/dist/wgpuScene3DTestHelper.d.ts +14 -0
  170. package/dist/wgpuScene3DTestHelper.d.ts.map +1 -0
  171. package/dist/wgpuScene3DTestHelper.js +121 -0
  172. package/dist/wgpuScene3DTestHelper.js.map +1 -0
  173. package/dist/wgpuScene3DTime.d.ts +4 -0
  174. package/dist/wgpuScene3DTime.d.ts.map +1 -0
  175. package/dist/wgpuScene3DTime.js +11 -0
  176. package/dist/wgpuScene3DTime.js.map +1 -0
  177. package/dist/wgpuShadedModifierSnippet.d.ts +4 -0
  178. package/dist/wgpuShadedModifierSnippet.d.ts.map +1 -0
  179. package/dist/wgpuShadedModifierSnippet.js +18 -0
  180. package/dist/wgpuShadedModifierSnippet.js.map +1 -0
  181. package/dist/wgpuShadedPrelude.d.ts +16 -0
  182. package/dist/wgpuShadedPrelude.d.ts.map +1 -0
  183. package/dist/wgpuShadedPrelude.js +625 -0
  184. package/dist/wgpuShadedPrelude.js.map +1 -0
  185. package/dist/wgpuShadowMap.d.ts +4 -0
  186. package/dist/wgpuShadowMap.d.ts.map +1 -0
  187. package/dist/wgpuShadowMap.js +155 -0
  188. package/dist/wgpuShadowMap.js.map +1 -0
  189. package/dist/wgpuSkinPalette.d.ts +7 -0
  190. package/dist/wgpuSkinPalette.d.ts.map +1 -0
  191. package/dist/wgpuSkinPalette.js +173 -0
  192. package/dist/wgpuSkinPalette.js.map +1 -0
  193. package/dist/wgpuToonPrelude.d.ts +8 -0
  194. package/dist/wgpuToonPrelude.d.ts.map +1 -0
  195. package/dist/wgpuToonPrelude.js +192 -0
  196. package/dist/wgpuToonPrelude.js.map +1 -0
  197. package/dist/wgpuUnlitPrelude.d.ts +9 -0
  198. package/dist/wgpuUnlitPrelude.d.ts.map +1 -0
  199. package/dist/wgpuUnlitPrelude.js +142 -0
  200. package/dist/wgpuUnlitPrelude.js.map +1 -0
  201. package/dist/wgpuWireframePrelude.d.ts +6 -0
  202. package/dist/wgpuWireframePrelude.d.ts.map +1 -0
  203. package/dist/wgpuWireframePrelude.js +77 -0
  204. package/dist/wgpuWireframePrelude.js.map +1 -0
  205. package/dist/wgpuWireframeUpload.d.ts +3 -0
  206. package/dist/wgpuWireframeUpload.d.ts.map +1 -0
  207. package/dist/wgpuWireframeUpload.js +68 -0
  208. package/dist/wgpuWireframeUpload.js.map +1 -0
  209. package/dist/wireframeWgpuMeshMaterialRenderer.d.ts +4 -0
  210. package/dist/wireframeWgpuMeshMaterialRenderer.d.ts.map +1 -0
  211. package/dist/wireframeWgpuMeshMaterialRenderer.js +69 -0
  212. package/dist/wireframeWgpuMeshMaterialRenderer.js.map +1 -0
  213. package/package.json +57 -0
  214. package/src/anisotropyPbrWgpuMeshMaterialRenderer.test.ts +90 -0
  215. package/src/blinnPhongWgpuMeshMaterialRenderer.test.ts +82 -0
  216. package/src/clearcoatPbrWgpuMeshMaterialRenderer.test.ts +90 -0
  217. package/src/customShaderWgpuMeshMaterialRenderer.test.ts +207 -0
  218. package/src/depthWgpuMeshMaterialRenderer.test.ts +69 -0
  219. package/src/drawWgpuScene3D.test.ts +247 -0
  220. package/src/emissiveWgpuMeshMaterialRenderer.test.ts +64 -0
  221. package/src/enableWgpuScene3DCustomShaderGuards.test.ts +73 -0
  222. package/src/enableWgpuScene3DForwardLightSelectionGuards.test.ts +39 -0
  223. package/src/explainWgpuScene3DForwardLightSelection.test.ts +15 -0
  224. package/src/iridescencePbrWgpuMeshMaterialRenderer.test.ts +90 -0
  225. package/src/lambertWgpuMeshMaterialRenderer.test.ts +77 -0
  226. package/src/matcapWgpuMeshMaterialRenderer.test.ts +69 -0
  227. package/src/normalWgpuMeshMaterialRenderer.test.ts +69 -0
  228. package/src/phongWgpuMeshMaterialRenderer.test.ts +79 -0
  229. package/src/prepareWgpuScene3DForwardLights.test.ts +84 -0
  230. package/src/registerStandardPbrWgpuMaterial.test.ts +15 -0
  231. package/src/shadedWgpuMeshMaterialRenderer.test.ts +63 -0
  232. package/src/sheenPbrWgpuMeshMaterialRenderer.test.ts +87 -0
  233. package/src/specularGlossinessPbrWgpuMeshMaterialRenderer.test.ts +100 -0
  234. package/src/specularPbrWgpuMeshMaterialRenderer.test.ts +90 -0
  235. package/src/standardPbrWgpuMeshMaterialRenderer.test.ts +172 -0
  236. package/src/subsurfacePbrWgpuMeshMaterialRenderer.test.ts +90 -0
  237. package/src/toonWgpuMeshMaterialRenderer.test.ts +89 -0
  238. package/src/transmissionVolumePbrWgpuMeshMaterialRenderer.test.ts +97 -0
  239. package/src/unlitWgpuMeshMaterialRenderer.test.ts +94 -0
  240. package/src/vertexColorWgpuMeshMaterialRenderer.test.ts +62 -0
  241. package/src/wgpuClassicPrelude.test.ts +176 -0
  242. package/src/wgpuDebugPrelude.test.ts +79 -0
  243. package/src/wgpuEnvironmentCube.test.ts +86 -0
  244. package/src/wgpuEnvironmentIblBake.test.ts +79 -0
  245. package/src/wgpuEnvironmentSkybox.test.ts +56 -0
  246. package/src/wgpuMatcapPrelude.test.ts +70 -0
  247. package/src/wgpuMeshMaterialRegistry.test.ts +55 -0
  248. package/src/wgpuMeshPipeline.test.ts +844 -0
  249. package/src/wgpuMeshUpload.test.ts +177 -0
  250. package/src/wgpuParticleEmitter3D.test.ts +200 -0
  251. package/src/wgpuPbrPipelineCache.test.ts +67 -0
  252. package/src/wgpuPbrPrelude.test.ts +162 -0
  253. package/src/wgpuScene3DRuntime.test.ts +35 -0
  254. package/src/wgpuScene3DTime.test.ts +20 -0
  255. package/src/wgpuShadedModifierSnippet.test.ts +33 -0
  256. package/src/wgpuShadedPrelude.test.ts +394 -0
  257. package/src/wgpuShadowMap.test.ts +169 -0
  258. package/src/wgpuSkinPalette.test.ts +88 -0
  259. package/src/wgpuToonPrelude.test.ts +93 -0
  260. package/src/wgpuUnlitPrelude.test.ts +102 -0
  261. package/src/wgpuWireframePrelude.test.ts +54 -0
  262. package/src/wgpuWireframeUpload.test.ts +36 -0
  263. package/src/wireframeWgpuMeshMaterialRenderer.test.ts +69 -0
@@ -0,0 +1,52 @@
1
+ import { createWgpuMeshPipeline, ensureWgpuPbrSampleLayout, ensureWgpuScene3DPipeline } from './wgpuMeshPipeline';
2
+ import { buildWgpuPbrDefineKey, getWgpuPbrModuleSourceForKey } from './wgpuPbrPrelude';
3
+ import { getWgpuSkinningAdapter } from './wgpuScene3DRuntime';
4
+ // Compiles the PBR uber-shader module for a define key and builds the render pipeline for the given
5
+ // color-attachment format. Pure GPU work — no caching — used by ensureWgpuPbrPipeline. The group(2)
6
+ // material layout is a uniform (the MaterialBlock) + one filtering sampler per standard map + six
7
+ // textures (base-color, normal, metallic-roughness, occlusion, emissive, alpha), which are all
8
+ // sampled from real uploads when present; an absent map binds a shared placeholder view, so the
9
+ // layout is fixed whether or not a given variant samples a particular map.
10
+ // Depth-stencil, vertex layout, and back-face culling (unless doubleSided) come from the shared
11
+ // createWgpuMeshPipeline. Mirrors scene-gl's compileGlPbrProgram.
12
+ export function compileWgpuPbrPipeline(state, key, format, blended = false, skinned = false) {
13
+ const device = state.device;
14
+ const module = device.createShaderModule({
15
+ code: getWgpuPbrModuleSourceForKey(key, skinned, getWgpuSkinningAdapter(state)),
16
+ });
17
+ const materialBindGroupLayout = device.createBindGroupLayout({
18
+ entries: [
19
+ { binding: 0, visibility: GPUShaderStage.FRAGMENT, buffer: { type: 'uniform' } },
20
+ { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
21
+ { binding: 2, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
22
+ { binding: 3, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
23
+ { binding: 4, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
24
+ { binding: 5, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
25
+ { binding: 6, visibility: GPUShaderStage.FRAGMENT, sampler: { type: 'filtering' } },
26
+ { binding: 7, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
27
+ { binding: 8, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
28
+ { binding: 9, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
29
+ { binding: 10, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
30
+ { binding: 11, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
31
+ { binding: 12, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: 'float' } },
32
+ ],
33
+ });
34
+ // The PBR family is lit and may PCF-sample shadows plus image-based lighting. Both live in one group
35
+ // 3 layout so the pipeline fits WebGPU's required maxBindGroups minimum of 4.
36
+ return createWgpuMeshPipeline(state, {
37
+ blended,
38
+ doubleSided: key.doubleSided,
39
+ format,
40
+ materialBindGroupLayout,
41
+ module,
42
+ pbrSampleBindGroupLayout: ensureWgpuPbrSampleLayout(state),
43
+ skinned,
44
+ });
45
+ }
46
+ // Resolves the PBR pipeline for a define key + color-attachment format, compiling and caching it on
47
+ // first use through the shared scene pipeline cache under the `pbr:` family namespace, so each variant
48
+ // is compiled at most once per state and reused every frame. Mirrors scene-gl's ensureGlPbrProgram.
49
+ export function ensureWgpuPbrPipeline(state, key, format) {
50
+ return ensureWgpuScene3DPipeline(state, `pbr:${format}|${buildWgpuPbrDefineKey(key)}`, (blended, skinned) => compileWgpuPbrPipeline(state, key, format, blended, skinned));
51
+ }
52
+ //# sourceMappingURL=wgpuPbrPipelineCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuPbrPipelineCache.js","sourceRoot":"","sources":["../src/wgpuPbrPipelineCache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,oGAAoG;AACpG,oGAAoG;AACpG,kGAAkG;AAClG,+FAA+F;AAC/F,gGAAgG;AAChG,2EAA2E;AAC3E,gGAAgG;AAChG,kEAAkE;AAClE,MAAM,UAAU,sBAAsB,CACpC,KAAsB,EACtB,GAA+B,EAC/B,MAAwB,EACxB,OAAO,GAAG,KAAK,EACf,OAAO,GAAG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J,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { WgpuPbrDefineKey } from '@flighthq/types';
2
+ import type { WgpuSkinningAdapter } from '@flighthq/types';
3
+ export declare function buildWgpuPbrDefineKey(key: Readonly<WgpuPbrDefineKey>): string;
4
+ export declare function buildWgpuPbrDefineSource(key: Readonly<WgpuPbrDefineKey>): string;
5
+ export declare function getWgpuPbrModuleBody(): string;
6
+ export declare function getWgpuPbrModuleSourceForKey(key: Readonly<WgpuPbrDefineKey>, skinned?: boolean, skinning?: Readonly<WgpuSkinningAdapter> | null): string;
7
+ //# sourceMappingURL=wgpuPbrPrelude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuPbrPrelude.d.ts","sourceRoot":"","sources":["../src/wgpuPbrPrelude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAsC3D,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAkB7E;AAKD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAkBhF;AAKD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAID,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC/B,OAAO,UAAQ,EACf,QAAQ,GAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,IAAW,GACpD,MAAM,CAKR"}
@@ -0,0 +1,551 @@
1
+ // The shared Wgpu PBR prelude: the WGSL vertex + fragment uber-shader for the StandardPbr forward-lit
2
+ // path AND every PBR-extension variant — the WGSL mirror of scene-gl's glPbrPrelude. One module source
3
+ // is specialized per material at compile time by prepending a const-flag block (see WgpuPbrDefineKey /
4
+ // buildWgpuPbrDefineSource): WGSL has no preprocessor, so each feature flag is emitted as
5
+ // `const FLAG : bool = …;` and the shader branches on it (the dead branch is folded away by the
6
+ // pipeline compiler). The maps-present / double-sided / alpha-mask variants AND the extension lobes
7
+ // (clearcoat, sheen, anisotropy, iridescence, specular, subsurface, transmission) are all const-flag
8
+ // branches of one module, never separate files. An extension renderer sets exactly one extension flag
9
+ // on top of the standard map flags drawn from `material.standard`, so the base StandardPbr path is
10
+ // byte-for-byte unchanged when no extension flag is set.
11
+ //
12
+ // The lighting model is Cook-Torrance: GGX normal distribution, Smith height-correlated visibility,
13
+ // and a Fresnel-Schlick approximation, evaluated over the interpolated world-space normal/tangent/uv
14
+ // for one directional + one ambient light, up to MAX_FORWARD_LIGHTS (4) each of point, spot, and
15
+ // hemisphere lights, read from the Frame uniform. The fragment scene2d outputs LINEAR HDR radiance (no
16
+ // tonemap / gamma here — the effect pipeline's resolve/tonemap pass owns that), matching the
17
+ // rgba16float scene target.
18
+ //
19
+ // The Frame uniform mirrors Scene3DLightBlock.data: a directional term { direction.xyz, _pad,
20
+ // radiance.rgb, _pad } then an ambient term { radiance.rgb, _pad }, followed by packed point/spot/
21
+ // hemisphere arrays and a punctualCounts vec4f — radiance is already linear and premultiplied by
22
+ // intensity at pack time, so the shader never decodes sRgb. directionalCount / ambientCount (0 or 1)
23
+ // gate each term's contribution; the punctual loops are bounded by their respective count.
24
+ //
25
+ // Bind groups (must match standardPbrWgpuMeshMaterialRenderer):
26
+ // group(0) Frame : viewProjection, cameraPosition, directional + ambient light — uniform.
27
+ // group(1) Draw : world + normalMatrix — uniform (dynamic offset per draw).
28
+ // group(2) Material : the 48-float MaterialBlock (base + extension factors) uniform + sampler + 5
29
+ // optional maps. Extension factors ride in the one MaterialBlock; the lobe that
30
+ // reads them runs only when its const flag is set.
31
+ // group(3) Samples : the directional shadow resources plus image-based-lighting resources. They share
32
+ // one group so PBR fits WebGPU's required maxBindGroups minimum of 4.
33
+ // A short, stable, order-independent string identity for a define key, used as the pipeline-cache map
34
+ // key (combined with the color-attachment format). Two keys with the same flags produce the same
35
+ // string and so share a compiled pipeline. Standard map/alpha/double-sided flags first, then one slot
36
+ // per extension lobe past the `:` (mirroring scene-gl's `mbnroe:CSAIPUT` layout — all five standard
37
+ // maps now sampled on wgpu: base color, normal, metallic-roughness, occlusion, emissive).
38
+ export function buildWgpuPbrDefineKey(key) {
39
+ return (`${key.alphaMaskEnabled ? 'm' : '-'}` +
40
+ `${key.doubleSided ? 'd' : '-'}` +
41
+ `${key.hasBaseColorMap ? 'b' : '-'}` +
42
+ `${key.hasNormalMap ? 'n' : '-'}` +
43
+ `${key.hasMetallicRoughnessMap ? 'r' : '-'}` +
44
+ `${key.hasOcclusionMap ? 'o' : '-'}` +
45
+ `${key.hasEmissiveMap ? 'e' : '-'}` +
46
+ `${key.hasAlphaMap ? 'a' : '-'}` +
47
+ `:${key.clearcoatEnabled ? 'C' : '-'}` +
48
+ `${key.sheenEnabled ? 'S' : '-'}` +
49
+ `${key.anisotropyEnabled ? 'A' : '-'}` +
50
+ `${key.iridescenceEnabled ? 'I' : '-'}` +
51
+ `${key.specularEnabled ? 'P' : '-'}` +
52
+ `${key.subsurfaceEnabled ? 'U' : '-'}` +
53
+ `${key.transmissionEnabled ? 'T' : '-'}`);
54
+ }
55
+ // Builds the leading `const FLAG : bool = …;` block for a define key, prepended to the module body
56
+ // before compile. Pure string assembly; the same key always yields the same source, which is what
57
+ // makes the pipeline cache by define key sound.
58
+ export function buildWgpuPbrDefineSource(key) {
59
+ return (`const ALPHA_MASK : bool = ${key.alphaMaskEnabled ? 'true' : 'false'};\n` +
60
+ `const DOUBLE_SIDED : bool = ${key.doubleSided ? 'true' : 'false'};\n` +
61
+ `const HAS_BASE_COLOR_MAP : bool = ${key.hasBaseColorMap ? 'true' : 'false'};\n` +
62
+ `const HAS_NORMAL_MAP : bool = ${key.hasNormalMap ? 'true' : 'false'};\n` +
63
+ `const HAS_METALLIC_ROUGHNESS_MAP : bool = ${key.hasMetallicRoughnessMap ? 'true' : 'false'};\n` +
64
+ `const HAS_OCCLUSION_MAP : bool = ${key.hasOcclusionMap ? 'true' : 'false'};\n` +
65
+ `const HAS_EMISSIVE_MAP : bool = ${key.hasEmissiveMap ? 'true' : 'false'};\n` +
66
+ `const HAS_ALPHA_MAP : bool = ${key.hasAlphaMap ? 'true' : 'false'};\n` +
67
+ `const CLEARCOAT : bool = ${key.clearcoatEnabled ? 'true' : 'false'};\n` +
68
+ `const SHEEN : bool = ${key.sheenEnabled ? 'true' : 'false'};\n` +
69
+ `const ANISOTROPY : bool = ${key.anisotropyEnabled ? 'true' : 'false'};\n` +
70
+ `const IRIDESCENCE : bool = ${key.iridescenceEnabled ? 'true' : 'false'};\n` +
71
+ `const SPECULAR_EXT : bool = ${key.specularEnabled ? 'true' : 'false'};\n` +
72
+ `const SUBSURFACE : bool = ${key.subsurfaceEnabled ? 'true' : 'false'};\n` +
73
+ `const TRANSMISSION : bool = ${key.transmissionEnabled ? 'true' : 'false'};\n`);
74
+ }
75
+ // The static WGSL module body (everything after the const-flag block): bind-group structs, the
76
+ // Cook-Torrance BRDF + the extension-lobe helpers, and the vs_main/fs_main entry points. Toggled by
77
+ // the const flags emitted ahead of it; the compiler folds the dead branch away.
78
+ export function getWgpuPbrModuleBody() {
79
+ return PBR_WGSL_BODY;
80
+ }
81
+ // The full WGSL module source for a define key (flag block + body), ready to hand to
82
+ // device.createShaderModule. Convenience over buildWgpuPbrDefineSource + getWgpuPbrModuleBody.
83
+ export function getWgpuPbrModuleSourceForKey(key, skinned = false, skinning = null) {
84
+ return (buildWgpuPbrDefineSource(key) +
85
+ (skinned && skinning !== null ? skinning.extendMeshPrelude(PBR_WGSL_BODY) : PBR_WGSL_BODY));
86
+ }
87
+ const PBR_WGSL_BODY = /* wgsl */ `
88
+ const PI : f32 = 3.14159265359;
89
+ const MAX_FORWARD_LIGHTS : u32 = 4u;
90
+
91
+ struct Frame {
92
+ viewProjection : mat4x4f,
93
+ cameraPosition : vec4f,
94
+ lightDirection : vec4f, // xyz = directional light travel direction; w = directionalCount
95
+ directionalRadiance : vec4f, // rgb = linear premultiplied radiance
96
+ ambientRadiance : vec4f, // rgb = linear premultiplied radiance; w = ambientCount
97
+ view : mat4x4f, // camera view matrix (unused by PBR, but keeps struct in lockstep)
98
+ // Punctual light arrays — layout mirrors Scene3DLightBlock.data (packScene3DLightBlock).
99
+ // point[i] = pointLights[i*2+0]={pos.xyz,range}, [i*2+1]={radiance.rgb,invSqrRange}
100
+ // spot[i] = spotLights[i*4+0..1] as point, [i*4+2]={dir.xyz,_}, [i*4+3]={cosInner,cosOuter,_,_}
101
+ // hemisphere[i] = hemisphereLights[i*3+0]={sky.rgb,_}, [i*3+1]={ground.rgb,_}, [i*3+2]={up.xyz,_}
102
+ pointLights : array<vec4f, 8>, // MAX_FORWARD_LIGHTS * 2
103
+ spotLights : array<vec4f, 16>, // MAX_FORWARD_LIGHTS * 4
104
+ hemisphereLights : array<vec4f, 12>, // MAX_FORWARD_LIGHTS * 3
105
+ punctualCounts : vec4f, // x = pointCount, y = spotCount, z = hemisphereCount
106
+ };
107
+
108
+ struct Draw {
109
+ world : mat4x4f,
110
+ normalMatrix : mat3x3f,
111
+ uvTransform : mat3x3f, // KHR_texture_transform of the base-color map (identity when unused)
112
+ params : vec4f, // x = resolved object alpha
113
+ };
114
+
115
+ // The 48-float MaterialBlock: the base StandardPbr block (vec4 0..3) plus one vec4 slot per extension
116
+ // lobe (matching the CPU packers in standardPbrWgpuMeshMaterialRenderer + the extension renderers).
117
+ // base0 : baseColor.rgba (linear)
118
+ // base1 : emissive.rgb * strength; w unused
119
+ // base2 : metallic, roughness, normalScale, occlusionStrength
120
+ // base3 : alphaCutoff, _, _, _
121
+ // clearcoat : clearcoat, clearcoatRoughness, _, _
122
+ // sheen : sheenColor.rgb, sheenRoughness
123
+ // anisotropy : anisotropyStrength, anisotropyRotation, _, _
124
+ // iridescence : iridescence, iridescenceIor, iridescenceThickness (nm), _
125
+ // specular : specular, specularColor.rgb
126
+ // subsurface : subsurface, subsurfaceColor.rgb
127
+ // thickness : thickness, _, _, _
128
+ // transmission: transmission, attenuationColor.rgb
129
+ struct MaterialBlock {
130
+ baseColor : vec4f,
131
+ emissive : vec4f,
132
+ factors : vec4f,
133
+ flags : vec4f,
134
+ clearcoat : vec4f,
135
+ sheen : vec4f,
136
+ anisotropy : vec4f,
137
+ iridescence : vec4f,
138
+ specular : vec4f,
139
+ subsurface : vec4f,
140
+ thickness : vec4f,
141
+ transmission : vec4f,
142
+ };
143
+
144
+ @group(0) @binding(0) var<uniform> frame : Frame;
145
+ @group(1) @binding(0) var<uniform> draw : Draw;
146
+ // The directional shadow inputs (group 3), the WGSL mirror of scene-gl's u_shadowMap / u_shadowMatrix /
147
+ // u_shadowEnabled. matrix is the light view-projection (world to shadow clip); params.x is the enabled
148
+ // flag (0 or 1). The depth map is a texture_depth_2d PCF-compared with a comparison sampler.
149
+ struct Shadow {
150
+ matrix : mat4x4f,
151
+ params : vec4f, // x = enabled (0 or 1)
152
+ };
153
+
154
+ @group(2) @binding(0) var<uniform> material : MaterialBlock;
155
+ @group(2) @binding(1) var baseColorSampler : sampler;
156
+ @group(2) @binding(2) var metallicRoughnessSampler : sampler;
157
+ @group(2) @binding(3) var normalSampler : sampler;
158
+ @group(2) @binding(4) var occlusionSampler : sampler;
159
+ @group(2) @binding(5) var emissiveSampler : sampler;
160
+ @group(2) @binding(6) var alphaSampler : sampler;
161
+ @group(2) @binding(7) var baseColorTexture : texture_2d<f32>;
162
+ @group(2) @binding(8) var metallicRoughnessTexture : texture_2d<f32>;
163
+ @group(2) @binding(9) var normalTexture : texture_2d<f32>;
164
+ @group(2) @binding(10) var occlusionTexture : texture_2d<f32>;
165
+ @group(2) @binding(11) var emissiveTexture : texture_2d<f32>;
166
+ @group(2) @binding(12) var alphaTexture : texture_2d<f32>;
167
+
168
+ @group(3) @binding(0) var<uniform> shadow : Shadow;
169
+ @group(3) @binding(1) var shadowMap : texture_depth_2d;
170
+ @group(3) @binding(2) var shadowSampler : sampler_comparison;
171
+
172
+ // The image-based-lighting inputs share group 3 with shadow so PBR fits WebGPU's maxBindGroups minimum.
173
+ // params.x is the enabled flag (0 or 1), params.y the environment intensity, params.z the highest
174
+ // prefiltered mip index (roughness 1.0). The split-sum set: a diffuse irradiance cube, a roughness-mipped
175
+ // prefiltered specular cube, and the 2D BRDF LUT, sampled through one filtering sampler.
176
+ struct Ibl {
177
+ params : vec4f, // x = enabled, y = intensity, z = maxMip
178
+ };
179
+
180
+ @group(3) @binding(3) var<uniform> ibl : Ibl;
181
+ @group(3) @binding(4) var iblIrradiance : texture_cube<f32>;
182
+ @group(3) @binding(5) var iblPrefiltered : texture_cube<f32>;
183
+ @group(3) @binding(6) var iblBrdf : texture_2d<f32>;
184
+ @group(3) @binding(7) var iblSampler : sampler;
185
+
186
+ struct VertexOutput {
187
+ @builtin(position) clipPosition : vec4f,
188
+ @location(0) worldPosition : vec3f,
189
+ @location(1) worldNormal : vec3f,
190
+ @location(2) worldTangent : vec4f,
191
+ @location(3) uv : vec2f,
192
+ @location(4) @interpolate(flat) objectAlpha : f32,
193
+ };
194
+
195
+ @vertex fn vs_main(
196
+ @location(0) position : vec3f,
197
+ @location(1) normal : vec3f,
198
+ @location(2) tangent : vec4f,
199
+ @location(3) uv : vec2f,
200
+ ) -> VertexOutput {
201
+ var out : VertexOutput;
202
+ var localPosition = vec4f(position, 1.0);
203
+ var localNormal = normal;
204
+ var localTangent = tangent.xyz;
205
+ let world = draw.world * localPosition;
206
+ out.worldPosition = world.xyz;
207
+ out.clipPosition = frame.viewProjection * world;
208
+ out.worldNormal = draw.normalMatrix * localNormal;
209
+ out.worldTangent = vec4f(draw.normalMatrix * localTangent, tangent.w);
210
+ // draw.uvTransform is identity for an untiled material, so this reproduces the raw uv; see the shared
211
+ // vs_main in wgpuMeshPipeline for why the KHR transform is applied unconditionally rather than gated.
212
+ out.uv = (draw.uvTransform * vec3f(uv, 1.0)).xy;
213
+ out.objectAlpha = draw.params.x;
214
+ return out;
215
+ }
216
+
217
+ // sRgb albedo texels are gamma-encoded; decode to linear before lighting.
218
+ fn srgbToLinear(c : vec3f) -> vec3f {
219
+ let lo = c / 12.92;
220
+ let hi = pow((c + vec3f(0.055)) / 1.055, vec3f(2.4));
221
+ return select(lo, hi, c > vec3f(0.04045));
222
+ }
223
+
224
+ fn distributionGgx(nDotH : f32, roughness : f32) -> f32 {
225
+ let a = roughness * roughness;
226
+ let a2 = a * a;
227
+ let d = nDotH * nDotH * (a2 - 1.0) + 1.0;
228
+ return a2 / max(PI * d * d, 1e-7);
229
+ }
230
+
231
+ fn visibilitySmith(nDotV : f32, nDotL : f32, roughness : f32) -> f32 {
232
+ let a = roughness * roughness;
233
+ let k = a * 0.5;
234
+ let gv = nDotV / (nDotV * (1.0 - k) + k);
235
+ let gl = nDotL / (nDotL * (1.0 - k) + k);
236
+ return gv * gl;
237
+ }
238
+
239
+ fn fresnelSchlick(cosTheta : f32, f0 : vec3f) -> vec3f {
240
+ return f0 + (vec3f(1.0) - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
241
+ }
242
+
243
+ // Roughness-aware Fresnel for the IBL specular term (Sébastien Lagarde): rougher surfaces reflect less at
244
+ // grazing angles than the smooth Schlick approximation. The WGSL mirror of scene-gl's fresnelSchlickRoughness.
245
+ fn fresnelSchlickRoughness(cosTheta : f32, f0 : vec3f, roughness : f32) -> vec3f {
246
+ let fMax = max(vec3f(1.0 - roughness), f0);
247
+ return f0 + (fMax - f0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
248
+ }
249
+
250
+ // Image-based ambient via the split-sum approximation: diffuse irradiance over the albedo plus prefiltered
251
+ // specular weighted by the BRDF LUT, scaled by the environment intensity and AO. Replaces the flat ambient
252
+ // term when an environment is baked (bakeWgpuEnvironmentIbl). The cube/LUT samples are already linear
253
+ // (baked from sRGB-decoded sources), so no decode here. The WGSL mirror of scene-gl's sampleIblAmbient.
254
+ // textureSampleLevel is used throughout (the irradiance/LUT at level 0, the prefiltered cube at the
255
+ // roughness-scaled mip) so the sample never needs screen-space derivatives — safe under any control flow.
256
+ fn sampleIblAmbient(N : vec3f, V : vec3f, rough : f32, f0 : vec3f, diffuseColor : vec3f, occ : f32) -> vec3f {
257
+ let nv = max(dot(N, V), 1e-4);
258
+ let F = fresnelSchlickRoughness(nv, f0, rough);
259
+ let diffuse = textureSampleLevel(iblIrradiance, iblSampler, N, 0.0).rgb * diffuseColor;
260
+ let R = reflect(-V, N);
261
+ let prefiltered = textureSampleLevel(iblPrefiltered, iblSampler, R, rough * ibl.params.z).rgb;
262
+ let brdf = textureSampleLevel(iblBrdf, iblSampler, vec2f(nv, rough), 0.0).rg;
263
+ let specular = prefiltered * (F * brdf.x + brdf.y);
264
+ return ((vec3f(1.0) - F) * diffuse + specular) * occ * ibl.params.y;
265
+ }
266
+
267
+ // Anisotropic GGX distribution (Burley): an elliptical lobe along the tangent (at) vs bitangent (ab)
268
+ // roughness axes. tDotH/bDotH are the half-vector projections onto the rotated tangent frame.
269
+ fn distributionGgxAnisotropic(nDotH : f32, tDotH : f32, bDotH : f32, at : f32, ab : f32) -> f32 {
270
+ let d = tDotH * tDotH / (at * at) + bDotH * bDotH / (ab * ab) + nDotH * nDotH;
271
+ return 1.0 / max(PI * at * ab * d * d, 1e-7);
272
+ }
273
+
274
+ // Charlie ("inverted GGX") sheen distribution from Estevez & Kulla — a soft retroreflective lobe for
275
+ // cloth. Approximated visibility keeps the lobe energy-plausible without a lookup table.
276
+ fn distributionCharlie(nDotH : f32, roughness : f32) -> f32 {
277
+ let r = clamp(roughness, 0.07, 1.0);
278
+ let invR = 1.0 / r;
279
+ let cos2h = nDotH * nDotH;
280
+ let sin2h = max(1.0 - cos2h, 1e-4);
281
+ return (2.0 + invR) * pow(sin2h, invR * 0.5) / (2.0 * PI);
282
+ }
283
+
284
+ fn visibilitySheen(nDotV : f32, nDotL : f32) -> f32 {
285
+ return 1.0 / max(4.0 * (nDotL + nDotV - nDotL * nDotV), 1e-4);
286
+ }
287
+
288
+ // Thin-film interference: shift F0 toward a view-/thickness-dependent hue. A compact sinusoidal
289
+ // approximation of the optical-path-difference phase per RGB band (sample-viewer style), enough to
290
+ // produce a plausible soap-bubble rainbow without the full Airy summation.
291
+ fn iridescentFresnel(cosTheta : f32, f0 : vec3f, thicknessNm : f32, filmIor : f32) -> vec3f {
292
+ let opd = 2.0 * filmIor * thicknessNm * cosTheta;
293
+ let bands = vec3f(580.0, 540.0, 460.0); // approximate R/G/B wavelengths (nm)
294
+ let phase = 2.0 * PI * opd / bands;
295
+ let shift = vec3f(0.5) + vec3f(0.5) * cos(phase);
296
+ let base = fresnelSchlick(cosTheta, f0);
297
+ return mix(base, shift, clamp(thicknessNm / 1000.0, 0.0, 1.0));
298
+ }
299
+
300
+ // Directional shadow factor at a world position: 1.0 fully lit, 0.0 fully shadowed, with 3x3 PCF —
301
+ // the WGSL mirror of scene-gl's sampleDirectionalShadow. Two WebGPU-specific deltas from the GL form:
302
+ // the sample UV flips Y (WebGPU textures are top-left origin, GL bottom-left), and the depth reference
303
+ // remaps the GL-convention clip Z (-1..1) into WebGPU's 0..1 depth range — matching the identical remap
304
+ // the shadow depth pass applies when it writes the map. The comparison sampler ('less-equal') yields
305
+ // GL's "current <= closest" per tap; fragments outside the shadow frustum read as lit.
306
+ fn sampleDirectionalShadow(worldPos : vec3f) -> f32 {
307
+ if (shadow.params.x < 0.5) {
308
+ return 1.0;
309
+ }
310
+ let clip = shadow.matrix * vec4f(worldPos, 1.0);
311
+ let ndc = clip.xyz / clip.w;
312
+ let uv = vec2f(ndc.x * 0.5 + 0.5, 1.0 - (ndc.y * 0.5 + 0.5));
313
+ let depthRef = ndc.z * 0.5 + 0.5 - 0.0025;
314
+ if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 || depthRef > 1.0) {
315
+ return 1.0;
316
+ }
317
+ let texel = 1.0 / vec2f(textureDimensions(shadowMap, 0));
318
+ var sum = 0.0;
319
+ for (var x = -1; x <= 1; x = x + 1) {
320
+ for (var y = -1; y <= 1; y = y + 1) {
321
+ let offset = vec2f(f32(x), f32(y)) * texel;
322
+ sum = sum + textureSampleCompareLevel(shadowMap, shadowSampler, uv + offset, depthRef);
323
+ }
324
+ }
325
+ return sum / 9.0;
326
+ }
327
+
328
+ // Smooth inverse-square range window (glTF/UE4): 1 near the light, eased to 0 at the range.
329
+ // invSqrRange is 1/range^2 (0 = infinite range, no cutoff); dist2 is the squared surface->light
330
+ // distance. The WGSL mirror of scene-gl's rangeWindow.
331
+ fn rangeWindow(dist2 : f32, invSqrRange : f32) -> f32 {
332
+ let factor = dist2 * invSqrRange;
333
+ let windowed = clamp(1.0 - factor * factor, 0.0, 1.0);
334
+ return windowed * windowed;
335
+ }
336
+
337
+ // The full Cook-Torrance shading (plus every enabled extension lobe) for ONE light. Directional,
338
+ // point, and spot lights all route through this one BRDF so punctual lights never fork the shading
339
+ // model — the caller passes the surface->light direction L and that light's (attenuated, cone-scaled)
340
+ // radiance. The anisotropic tangent frame is rebuilt here per light from the surface tangent frame so
341
+ // the function stays self-contained; f0/diffuseColor/roughness/metallic are the finalized surface
342
+ // values from main. Returns the light's linear radiance contribution (shadowing applied by the caller).
343
+ // The WGSL mirror of scene-gl's shadePbrPunctual.
344
+ fn shadePbrPunctual(N : vec3f, V : vec3f, tangentDir : vec3f, bitangentDir : vec3f, L : vec3f,
345
+ lightColor : vec3f, f0 : vec3f, diffuseColor : vec3f, roughness : f32,
346
+ metallic : f32, anisoT : vec3f, anisoB : vec3f, at : f32, ab : f32) -> vec3f {
347
+ let nDotV = max(dot(N, V), 1e-4);
348
+ let halfVec = normalize(V + L);
349
+ let nDotL = max(dot(N, L), 0.0);
350
+ let nDotH = max(dot(N, halfVec), 0.0);
351
+ let vDotH = max(dot(V, halfVec), 0.0);
352
+
353
+ var d = distributionGgx(nDotH, roughness);
354
+ if (ANISOTROPY) {
355
+ let tDotH = dot(anisoT, halfVec);
356
+ let bDotH = dot(anisoB, halfVec);
357
+ d = distributionGgxAnisotropic(nDotH, tDotH, bDotH, at, ab);
358
+ }
359
+ let vis = visibilitySmith(nDotV, nDotL, roughness);
360
+ let fresnel = fresnelSchlick(vDotH, f0);
361
+
362
+ let specular = d * vis * fresnel;
363
+ let kd = (vec3f(1.0) - fresnel) * (1.0 - metallic);
364
+ let brdf = kd * diffuseColor / PI + specular;
365
+ var direct = brdf * lightColor * nDotL;
366
+
367
+ if (SUBSURFACE) {
368
+ let wrap = clamp((dot(N, L) + 0.5) / 2.25, 0.0, 1.0);
369
+ let translucency = material.subsurface.x / (1.0 + material.thickness.x);
370
+ direct = direct + translucency * wrap * material.subsurface.yzw * diffuseColor * lightColor;
371
+ }
372
+
373
+ if (SHEEN) {
374
+ let sheenD = distributionCharlie(nDotH, material.sheen.w);
375
+ let sheenV = visibilitySheen(nDotV, nDotL);
376
+ direct = direct + material.sheen.rgb * sheenD * sheenV * lightColor * nDotL;
377
+ }
378
+
379
+ if (CLEARCOAT) {
380
+ let ccRough = clamp(material.clearcoat.y, 0.04, 1.0);
381
+ let ccD = distributionGgx(nDotH, ccRough);
382
+ let ccVis = visibilitySmith(nDotV, nDotL, ccRough);
383
+ let ccF = fresnelSchlick(vDotH, vec3f(0.04)) * material.clearcoat.x;
384
+ let ccSpec = ccD * ccVis * ccF * lightColor * nDotL;
385
+ direct = direct * (vec3f(1.0) - ccF) + ccSpec;
386
+ }
387
+
388
+ return direct;
389
+ }
390
+
391
+ @fragment fn fs_main(in : VertexOutput, @builtin(front_facing) isFront : bool) -> @location(0) vec4f {
392
+ var baseColor = material.baseColor;
393
+ if (HAS_BASE_COLOR_MAP) {
394
+ let sampled = textureSample(baseColorTexture, baseColorSampler, in.uv);
395
+ baseColor = vec4f(baseColor.rgb * srgbToLinear(sampled.rgb), baseColor.a * sampled.a);
396
+ }
397
+
398
+ // Dedicated coverage (opacity) map: its green channel is linear data, multiplied into alpha before
399
+ // the alpha-mask cutoff so 'mask' cutout and 'blend' transparency both see the combined coverage.
400
+ if (HAS_ALPHA_MAP) {
401
+ baseColor.a = baseColor.a * textureSample(alphaTexture, alphaSampler, in.uv).g;
402
+ }
403
+
404
+ if (ALPHA_MASK && baseColor.a < material.flags.x) {
405
+ discard;
406
+ }
407
+
408
+ var geometricNormal = normalize(in.worldNormal);
409
+ // Double-sided materials flip the normal for back faces so both sides shade correctly.
410
+ if (DOUBLE_SIDED && !isFront) {
411
+ geometricNormal = -geometricNormal;
412
+ }
413
+
414
+ let tangent = normalize(in.worldTangent.xyz - geometricNormal * dot(in.worldTangent.xyz, geometricNormal));
415
+ let bitangent = cross(geometricNormal, tangent) * in.worldTangent.w;
416
+
417
+ var normal = geometricNormal;
418
+ if (HAS_NORMAL_MAP) {
419
+ var tangentNormal = textureSample(normalTexture, normalSampler, in.uv).xyz * 2.0 - vec3f(1.0);
420
+ tangentNormal = vec3f(tangentNormal.xy * material.factors.z, tangentNormal.z);
421
+ let tbn = mat3x3f(tangent, bitangent, geometricNormal);
422
+ normal = normalize(tbn * tangentNormal);
423
+ }
424
+
425
+ let viewDir = normalize(frame.cameraPosition.xyz - in.worldPosition);
426
+ let nDotV = max(dot(normal, viewDir), 1e-4);
427
+
428
+ var roughness = clamp(material.factors.y, 0.04, 1.0);
429
+ var metallic = clamp(material.factors.x, 0.0, 1.0);
430
+ if (HAS_METALLIC_ROUGHNESS_MAP) {
431
+ // glTF packing: roughness in G, metallic in B (R is occlusion if combined, ignored here).
432
+ let mr = textureSample(metallicRoughnessTexture, metallicRoughnessSampler, in.uv);
433
+ roughness = clamp(roughness * mr.g, 0.04, 1.0);
434
+ metallic = clamp(metallic * mr.b, 0.0, 1.0);
435
+ }
436
+
437
+ // Occlusion defaults to full ambient; the map (R channel) attenuates it, lerped by occlusionStrength
438
+ // (factors.w). Without a map the ambient term is unattenuated, matching the GL path.
439
+ var occlusion = 1.0;
440
+ if (HAS_OCCLUSION_MAP) {
441
+ let ao = textureSample(occlusionTexture, occlusionSampler, in.uv).r;
442
+ occlusion = mix(1.0, ao, clamp(material.factors.w, 0.0, 1.0));
443
+ }
444
+
445
+ let albedo = baseColor.rgb;
446
+ var f0 = mix(vec3f(0.04), albedo, metallic);
447
+
448
+ if (SPECULAR_EXT) {
449
+ // KHR_materials_specular: scale and tint the dielectric F0 (metals keep their albedo F0).
450
+ let dielectricF0 = min(0.04 * material.specular.yzw, vec3f(1.0)) * material.specular.x;
451
+ f0 = mix(dielectricF0, albedo, metallic);
452
+ }
453
+
454
+ if (IRIDESCENCE) {
455
+ let irid = iridescentFresnel(nDotV, f0, material.iridescence.z, material.iridescence.y);
456
+ f0 = mix(f0, irid, material.iridescence.x);
457
+ }
458
+
459
+ let diffuseColor = albedo * (1.0 - metallic);
460
+
461
+ // Anisotropy: rotate the tangent frame, then split roughness into along-/across-tangent axes
462
+ // (Burley). Higher strength stretches the highlight along the tangent direction.
463
+ let anisoStrength = clamp(material.anisotropy.x, 0.0, 1.0);
464
+ let cosR = cos(material.anisotropy.y);
465
+ let sinR = sin(material.anisotropy.y);
466
+ let anisoT = normalize(cosR * tangent + sinR * bitangent);
467
+ let anisoB = normalize(cross(normal, anisoT));
468
+ let at = max(roughness * roughness * (1.0 + anisoStrength), 1e-3);
469
+ let ab = max(roughness * roughness * (1.0 - anisoStrength), 1e-3);
470
+
471
+ var radiance = vec3f(0.0);
472
+
473
+ // Directional light: -direction is the surface-to-light vector (light travels along direction).
474
+ // Routed through shadePbrPunctual so the BRDF is identical for all light types.
475
+ if (frame.lightDirection.w > 0.5) {
476
+ let lightDir = normalize(-frame.lightDirection.xyz);
477
+ let direct = shadePbrPunctual(normal, viewDir, tangent, bitangent, lightDir,
478
+ frame.directionalRadiance.rgb, f0, diffuseColor, roughness,
479
+ metallic, anisoT, anisoB, at, ab);
480
+ // Attenuate only the directional term by the PCF shadow factor (mirrors scene-gl's PBR path).
481
+ radiance = radiance + direct * sampleDirectionalShadow(in.worldPosition);
482
+ }
483
+
484
+ // Point lights: surface->light direction with a smooth inverse-square range falloff, same BRDF.
485
+ let pointCount = u32(frame.punctualCounts.x);
486
+ for (var i = 0u; i < MAX_FORWARD_LIGHTS; i++) {
487
+ if (i >= pointCount) { break; }
488
+ let toLight = frame.pointLights[i * 2u + 0u].xyz - in.worldPosition;
489
+ let dist2 = dot(toLight, toLight);
490
+ let lightDir = toLight * inverseSqrt(max(dist2, 1e-8));
491
+ let atten = rangeWindow(dist2, frame.pointLights[i * 2u + 1u].w) / max(dist2, 1e-4);
492
+ radiance = radiance + shadePbrPunctual(normal, viewDir, tangent, bitangent, lightDir,
493
+ frame.pointLights[i * 2u + 1u].xyz * atten, f0,
494
+ diffuseColor, roughness, metallic,
495
+ anisoT, anisoB, at, ab);
496
+ }
497
+
498
+ // Spot lights: point attenuation times a smooth cone falloff between the inner/outer cosines.
499
+ let spotCount = u32(frame.punctualCounts.y);
500
+ for (var j = 0u; j < MAX_FORWARD_LIGHTS; j++) {
501
+ if (j >= spotCount) { break; }
502
+ let toLight = frame.spotLights[j * 4u + 0u].xyz - in.worldPosition;
503
+ let dist2 = dot(toLight, toLight);
504
+ let lightDir = toLight * inverseSqrt(max(dist2, 1e-8));
505
+ let atten = rangeWindow(dist2, frame.spotLights[j * 4u + 1u].w) / max(dist2, 1e-4);
506
+ let cone = smoothstep(frame.spotLights[j * 4u + 3u].y, frame.spotLights[j * 4u + 3u].x,
507
+ dot(normalize(frame.spotLights[j * 4u + 2u].xyz), -lightDir));
508
+ radiance = radiance + shadePbrPunctual(normal, viewDir, tangent, bitangent, lightDir,
509
+ frame.spotLights[j * 4u + 1u].xyz * atten * cone, f0,
510
+ diffuseColor, roughness, metallic,
511
+ anisoT, anisoB, at, ab);
512
+ }
513
+
514
+ // Ambient term: image-based lighting (diffuse irradiance + prefiltered specular) when an environment is
515
+ // baked, else the flat ambient irradiance over the diffuse albedo. Both are AO-attenuated. Mirrors
516
+ // scene-gl's ambient branch (u_iblEnabled ? sampleIblAmbient : flat ambient).
517
+ if (ibl.params.x > 0.5) {
518
+ radiance = radiance + sampleIblAmbient(normal, viewDir, roughness, f0, diffuseColor, occlusion);
519
+ } else if (frame.ambientRadiance.w > 0.5) {
520
+ radiance = radiance + diffuseColor * frame.ambientRadiance.rgb * occlusion;
521
+ }
522
+
523
+ // Hemisphere fill: sky/ground gradient blended by the normal's vertical component, AO-attenuated.
524
+ let hemisphereCount = u32(frame.punctualCounts.z);
525
+ for (var k = 0u; k < MAX_FORWARD_LIGHTS; k++) {
526
+ if (k >= hemisphereCount) { break; }
527
+ let hf = 0.5 + 0.5 * dot(normal, frame.hemisphereLights[k * 3u + 2u].xyz);
528
+ radiance = radiance + mix(frame.hemisphereLights[k * 3u + 1u].xyz,
529
+ frame.hemisphereLights[k * 3u + 0u].xyz, hf)
530
+ * diffuseColor * occlusion;
531
+ }
532
+
533
+ var emissive = material.emissive.rgb;
534
+ if (HAS_EMISSIVE_MAP) {
535
+ emissive = emissive * srgbToLinear(textureSample(emissiveTexture, emissiveSampler, in.uv).rgb);
536
+ }
537
+ radiance = radiance + emissive;
538
+
539
+ var alpha = baseColor.a;
540
+ if (TRANSMISSION) {
541
+ // Phase-5 approximation: a true refractive path needs the opaque-scene-color capture pass to
542
+ // sample what lies behind the surface. Until then, model transmission as added translucency —
543
+ // attenuate coverage by the transmission factor and tint the surface by the attenuation color.
544
+ radiance = radiance * mix(vec3f(1.0), material.transmission.yzw, material.transmission.x);
545
+ alpha = alpha * (1.0 - material.transmission.x);
546
+ }
547
+
548
+ return vec4f(radiance, alpha * in.objectAlpha);
549
+ }
550
+ `;
551
+ //# sourceMappingURL=wgpuPbrPrelude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuPbrPrelude.js","sourceRoot":"","sources":["../src/wgpuPbrPrelude.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,uGAAuG;AACvG,uGAAuG;AACvG,0FAA0F;AAC1F,gGAAgG;AAChG,oGAAoG;AACpG,qGAAqG;AACrG,sGAAsG;AACtG,mGAAmG;AACnG,yDAAyD;AACzD,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+chC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { WgpuScene3DRuntime, WgpuRenderState } from '@flighthq/types';
2
+ import type { WgpuSkinningAdapter } from '@flighthq/types';
3
+ export declare function getWgpuScene3DRuntime(state: WgpuRenderState): WgpuScene3DRuntime;
4
+ export declare function getWgpuSkinningAdapter(state: WgpuRenderState): WgpuSkinningAdapter | null;
5
+ //# sourceMappingURL=wgpuScene3DRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wgpuScene3DRuntime.d.ts","sourceRoot":"","sources":["../src/wgpuScene3DRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAA0B,MAAM,iBAAiB,CAAC;AAEnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAK3D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,kBAAkB,CAuEhF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,mBAAmB,GAAG,IAAI,CAEzF"}