@luma.gl/shadertools 9.3.0-alpha.6 → 9.3.0-alpha.8

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 (152) hide show
  1. package/dist/dist.dev.js +2550 -330
  2. package/dist/dist.min.js +1803 -283
  3. package/dist/index.cjs +2495 -358
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +9 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -1
  10. package/dist/lib/preprocessor/preprocessor.js +4 -3
  11. package/dist/lib/preprocessor/preprocessor.js.map +1 -1
  12. package/dist/lib/shader-assembler.d.ts +10 -0
  13. package/dist/lib/shader-assembler.d.ts.map +1 -1
  14. package/dist/lib/shader-assembler.js +12 -2
  15. package/dist/lib/shader-assembler.js.map +1 -1
  16. package/dist/lib/shader-assembly/assemble-shaders.d.ts +23 -2
  17. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  18. package/dist/lib/shader-assembly/assemble-shaders.js +211 -11
  19. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
  20. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts +37 -0
  21. package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts.map +1 -0
  22. package/dist/lib/shader-assembly/wgsl-binding-debug.js +140 -0
  23. package/dist/lib/shader-assembly/wgsl-binding-debug.js.map +1 -0
  24. package/dist/lib/shader-generator/glsl/generate-glsl.js +3 -0
  25. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -1
  26. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -1
  27. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +3 -0
  28. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -1
  29. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts +22 -0
  30. package/dist/lib/shader-module/shader-module-uniform-layout.d.ts.map +1 -0
  31. package/dist/lib/shader-module/shader-module-uniform-layout.js +112 -0
  32. package/dist/lib/shader-module/shader-module-uniform-layout.js.map +1 -0
  33. package/dist/lib/shader-module/shader-module.d.ts +11 -5
  34. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  35. package/dist/lib/shader-module/shader-module.js.map +1 -1
  36. package/dist/lib/utils/uniform-types.d.ts +11 -7
  37. package/dist/lib/utils/uniform-types.d.ts.map +1 -1
  38. package/dist/modules/engine/picking/picking.d.ts +3 -0
  39. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  40. package/dist/modules/engine/picking/picking.js +3 -0
  41. package/dist/modules/engine/picking/picking.js.map +1 -1
  42. package/dist/modules/engine/skin/skin.d.ts +7 -6
  43. package/dist/modules/engine/skin/skin.d.ts.map +1 -1
  44. package/dist/modules/engine/skin/skin.js +3 -5
  45. package/dist/modules/engine/skin/skin.js.map +1 -1
  46. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  47. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  48. package/dist/modules/lighting/gouraud-material/gouraud-material.js +3 -0
  49. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  50. package/dist/modules/lighting/ibl/ibl.d.ts +26 -0
  51. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  52. package/dist/modules/lighting/ibl/ibl.js +33 -0
  53. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  54. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  55. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  56. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  57. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  58. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  59. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  60. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  61. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  62. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  63. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  64. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  65. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  66. package/dist/modules/lighting/lights/lighting-glsl.d.ts +1 -1
  67. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -1
  68. package/dist/modules/lighting/lights/lighting-glsl.js +43 -55
  69. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -1
  70. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +1 -1
  71. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -1
  72. package/dist/modules/lighting/lights/lighting-wgsl.js +43 -65
  73. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -1
  74. package/dist/modules/lighting/lights/lighting.d.ts +104 -86
  75. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  76. package/dist/modules/lighting/lights/lighting.js +96 -83
  77. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  78. package/dist/modules/lighting/no-material/dirlight.d.ts +7 -2
  79. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  80. package/dist/modules/lighting/no-material/dirlight.js +3 -1
  81. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  82. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
  83. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
  84. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +524 -28
  85. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
  86. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +2 -2
  87. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
  88. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +706 -50
  89. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
  90. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +110 -61
  91. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  92. package/dist/modules/lighting/pbr-material/pbr-material.js +85 -9
  93. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  94. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  95. package/dist/modules/lighting/pbr-material/pbr-projection.js +2 -1
  96. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  97. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -0
  98. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  99. package/dist/modules/lighting/phong-material/phong-material.js +4 -0
  100. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  101. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  102. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  103. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +15 -4
  104. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  105. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -1
  106. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  107. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +36 -5
  108. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  109. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  110. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  111. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +41 -10
  112. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -1
  113. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -0
  114. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  115. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +212 -0
  116. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  117. package/dist/modules/math/fp64/fp64.d.ts +1 -0
  118. package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
  119. package/dist/modules/math/fp64/fp64.js +8 -2
  120. package/dist/modules/math/fp64/fp64.js.map +1 -1
  121. package/package.json +3 -3
  122. package/src/index.ts +19 -2
  123. package/src/lib/preprocessor/preprocessor.ts +6 -3
  124. package/src/lib/shader-assembler.ts +17 -2
  125. package/src/lib/shader-assembly/assemble-shaders.ts +377 -12
  126. package/src/lib/shader-assembly/wgsl-binding-debug.ts +216 -0
  127. package/src/lib/shader-generator/glsl/generate-glsl.ts +7 -1
  128. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -0
  129. package/src/lib/shader-module/shader-module-uniform-layout.ts +194 -0
  130. package/src/lib/shader-module/shader-module.ts +16 -6
  131. package/src/lib/utils/uniform-types.ts +24 -9
  132. package/src/modules/engine/picking/picking.ts +3 -0
  133. package/src/modules/engine/skin/skin.ts +3 -5
  134. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  135. package/src/modules/lighting/ibl/ibl.ts +44 -0
  136. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  137. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  138. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  139. package/src/modules/lighting/lights/lighting-glsl.ts +43 -55
  140. package/src/modules/lighting/lights/lighting-wgsl.ts +43 -65
  141. package/src/modules/lighting/lights/lighting.ts +186 -123
  142. package/src/modules/lighting/no-material/dirlight.ts +3 -1
  143. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +524 -28
  144. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +706 -50
  145. package/src/modules/lighting/pbr-material/pbr-material.ts +111 -18
  146. package/src/modules/lighting/pbr-material/pbr-projection.ts +2 -1
  147. package/src/modules/lighting/phong-material/phong-material.ts +5 -0
  148. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +15 -4
  149. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +36 -5
  150. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +41 -10
  151. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +212 -0
  152. package/src/modules/math/fp64/fp64.ts +9 -3
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { lighting } from "../lights/lighting.js";
5
+ import { ibl } from "../ibl/ibl.js";
5
6
  import { vs, fs } from "./pbr-material-glsl.js";
6
7
  import { source } from "./pbr-material-wgsl.js";
7
8
  import { pbrProjection } from "./pbr-projection.js";
@@ -12,8 +13,75 @@ import { pbrProjection } from "./pbr-projection.js";
12
13
  export const pbrMaterial = {
13
14
  props: {},
14
15
  uniforms: {},
16
+ defaultUniforms: {
17
+ unlit: false,
18
+ baseColorMapEnabled: false,
19
+ baseColorFactor: [1, 1, 1, 1],
20
+ normalMapEnabled: false,
21
+ normalScale: 1,
22
+ emissiveMapEnabled: false,
23
+ emissiveFactor: [0, 0, 0],
24
+ metallicRoughnessValues: [1, 1],
25
+ metallicRoughnessMapEnabled: false,
26
+ occlusionMapEnabled: false,
27
+ occlusionStrength: 1,
28
+ alphaCutoffEnabled: false,
29
+ alphaCutoff: 0.5,
30
+ IBLenabled: false,
31
+ scaleIBLAmbient: [1, 1],
32
+ scaleDiffBaseMR: [0, 0, 0, 0],
33
+ scaleFGDSpec: [0, 0, 0, 0],
34
+ specularColorFactor: [1, 1, 1],
35
+ specularIntensityFactor: 1,
36
+ specularColorMapEnabled: false,
37
+ specularIntensityMapEnabled: false,
38
+ ior: 1.5,
39
+ transmissionFactor: 0,
40
+ transmissionMapEnabled: false,
41
+ thicknessFactor: 0,
42
+ attenuationDistance: 1e9,
43
+ attenuationColor: [1, 1, 1],
44
+ clearcoatFactor: 0,
45
+ clearcoatRoughnessFactor: 0,
46
+ clearcoatMapEnabled: false,
47
+ clearcoatRoughnessMapEnabled: false,
48
+ sheenColorFactor: [0, 0, 0],
49
+ sheenRoughnessFactor: 0,
50
+ sheenColorMapEnabled: false,
51
+ sheenRoughnessMapEnabled: false,
52
+ iridescenceFactor: 0,
53
+ iridescenceIor: 1.3,
54
+ iridescenceThicknessRange: [100, 400],
55
+ iridescenceMapEnabled: false,
56
+ anisotropyStrength: 0,
57
+ anisotropyRotation: 0,
58
+ anisotropyDirection: [1, 0],
59
+ anisotropyMapEnabled: false,
60
+ emissiveStrength: 1
61
+ },
15
62
  name: 'pbrMaterial',
16
- dependencies: [lighting, pbrProjection],
63
+ firstBindingSlot: 0,
64
+ bindingLayout: [
65
+ { name: 'pbrMaterial', group: 3 },
66
+ { name: 'pbr_baseColorSampler', group: 3 },
67
+ { name: 'pbr_normalSampler', group: 3 },
68
+ { name: 'pbr_emissiveSampler', group: 3 },
69
+ { name: 'pbr_metallicRoughnessSampler', group: 3 },
70
+ { name: 'pbr_occlusionSampler', group: 3 },
71
+ { name: 'pbr_specularColorSampler', group: 3 },
72
+ { name: 'pbr_specularIntensitySampler', group: 3 },
73
+ { name: 'pbr_transmissionSampler', group: 3 },
74
+ { name: 'pbr_thicknessSampler', group: 3 },
75
+ { name: 'pbr_clearcoatSampler', group: 3 },
76
+ { name: 'pbr_clearcoatRoughnessSampler', group: 3 },
77
+ { name: 'pbr_clearcoatNormalSampler', group: 3 },
78
+ { name: 'pbr_sheenColorSampler', group: 3 },
79
+ { name: 'pbr_sheenRoughnessSampler', group: 3 },
80
+ { name: 'pbr_iridescenceSampler', group: 3 },
81
+ { name: 'pbr_iridescenceThicknessSampler', group: 3 },
82
+ { name: 'pbr_anisotropySampler', group: 3 }
83
+ ],
84
+ dependencies: [lighting, ibl, pbrProjection],
17
85
  source,
18
86
  vs,
19
87
  fs,
@@ -27,10 +95,16 @@ export const pbrMaterial = {
27
95
  HAS_SPECULARCOLORMAP: false,
28
96
  HAS_SPECULARINTENSITYMAP: false,
29
97
  HAS_TRANSMISSIONMAP: false,
98
+ HAS_THICKNESSMAP: false,
30
99
  HAS_CLEARCOATMAP: false,
100
+ HAS_CLEARCOATROUGHNESSMAP: false,
101
+ HAS_CLEARCOATNORMALMAP: false,
31
102
  HAS_SHEENCOLORMAP: false,
103
+ HAS_SHEENROUGHNESSMAP: false,
32
104
  HAS_IRIDESCENCEMAP: false,
105
+ HAS_IRIDESCENCETHICKNESSMAP: false,
33
106
  HAS_ANISOTROPYMAP: false,
107
+ USE_MATERIAL_EXTENSIONS: false,
34
108
  ALPHA_CUTOFF: false,
35
109
  USE_IBL: false,
36
110
  PBR_DEBUG: false
@@ -52,13 +126,6 @@ export const pbrMaterial = {
52
126
  occlusionStrength: 'f32', // #ifdef HAS_OCCLUSIONMAP
53
127
  alphaCutoffEnabled: 'i32',
54
128
  alphaCutoff: 'f32', // #ifdef ALPHA_CUTOFF
55
- // IBL
56
- IBLenabled: 'i32',
57
- scaleIBLAmbient: 'vec2<f32>', // #ifdef USE_IBL
58
- // debugging flags used for shader output of intermediate PBR variables
59
- // #ifdef PBR_DEBUG
60
- scaleDiffBaseMR: 'vec4<f32>',
61
- scaleFGDSpec: 'vec4<f32>',
62
129
  specularColorFactor: 'vec3<f32>',
63
130
  specularIntensityFactor: 'f32',
64
131
  specularColorMapEnabled: 'i32',
@@ -72,9 +139,11 @@ export const pbrMaterial = {
72
139
  clearcoatFactor: 'f32',
73
140
  clearcoatRoughnessFactor: 'f32',
74
141
  clearcoatMapEnabled: 'i32',
142
+ clearcoatRoughnessMapEnabled: 'i32',
75
143
  sheenColorFactor: 'vec3<f32>',
76
144
  sheenRoughnessFactor: 'f32',
77
145
  sheenColorMapEnabled: 'i32',
146
+ sheenRoughnessMapEnabled: 'i32',
78
147
  iridescenceFactor: 'f32',
79
148
  iridescenceIor: 'f32',
80
149
  iridescenceThicknessRange: 'vec2<f32>',
@@ -83,7 +152,14 @@ export const pbrMaterial = {
83
152
  anisotropyRotation: 'f32',
84
153
  anisotropyDirection: 'vec2<f32>',
85
154
  anisotropyMapEnabled: 'i32',
86
- emissiveStrength: 'f32'
155
+ emissiveStrength: 'f32',
156
+ // IBL
157
+ IBLenabled: 'i32',
158
+ scaleIBLAmbient: 'vec2<f32>', // #ifdef USE_IBL
159
+ // debugging flags used for shader output of intermediate PBR variables
160
+ // #ifdef PBR_DEBUG
161
+ scaleDiffBaseMR: 'vec4<f32>',
162
+ scaleFGDSpec: 'vec4<f32>'
87
163
  }
88
164
  };
89
165
  //# sourceMappingURL=pbr-material.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pbr-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAepC,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAE5C,OAAO,EAAC,EAAE,EAAE,EAAE,EAAC,+BAA4B;AAC3C,OAAO,EAAC,MAAM,EAAC,+BAA4B;AAC3C,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAiG/C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,EAAsB;IAC7B,QAAQ,EAAE,EAAyB;IAEnC,IAAI,EAAE,aAAa;IACnB,YAAY,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;IACvC,MAAM;IACN,EAAE;IACF,EAAE;IAEF,OAAO,EAAE;QACP,iBAAiB,EAAE,IAAI;QACvB,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,gBAAgB,EAAE,KAAK;QACvB,qBAAqB,EAAE,KAAK;QAC5B,oBAAoB,EAAE,KAAK;QAC3B,wBAAwB,EAAE,KAAK;QAC/B,mBAAmB,EAAE,KAAK;QAC1B,gBAAgB,EAAE,KAAK;Q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,WAAW;QAE7B,eAAe,EAAE,KAAK;QACtB,wBAAwB,EAAE,KAAK;QAC/B,mBAAmB,EAAE,KAAK;QAC1B,4BAA4B,EAAE,KAAK;QAEnC,gBAAgB,EAAE,WAAW;QAC7B,oBAAoB,EAAE,KAAK;QAC3B,oBAAoB,EAAE,KAAK;QAC3B,wBAAwB,EAAE,KAAK;QAE/B,iBAAiB,EAAE,KAAK;QACxB,cAAc,EAAE,KAAK;QACrB,yBAAyB,EAAE,WAAW;QACtC,qBAAqB,EAAE,KAAK;QAE5B,kBAAkB,EAAE,KAAK;QACzB,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,WAAW;QAChC,oBAAoB,EAAE,KAAK;QAE3B,gBAAgB,EAAE,KAAK;QAEvB,MAAM;QACN,UAAU,EAAE,KAAK;QACjB,eAAe,EAAE,WAAW,EAAE,iBAAiB;QAE/C,uEAAuE;QACvE,mBAAmB;QACnB,eAAe,EAAE,WAAW;QAC5B,YAAY,EAAE,WAAW;KAC1B;CAC0F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pbr-projection.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-projection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAsBtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yBAAyB,EAAE,aAAa,CAAC;IACzC,WAAW,EAAE,aAAa,CAAC;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CAa1D,CAAC"}
1
+ {"version":3,"file":"pbr-projection.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-projection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAsBtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yBAAyB,EAAE,aAAa,CAAC;IACzC,WAAW,EAAE,aAAa,CAAC;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CAc1D,CAAC"}
@@ -17,10 +17,11 @@ struct pbrProjectionUniforms {
17
17
  camera: vec3<f32>
18
18
  };
19
19
 
20
- @binding(0) @group(0) var<uniform> pbrProjection: pbrProjectionUniforms;
20
+ @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
21
21
  `;
22
22
  export const pbrProjection = {
23
23
  name: 'pbrProjection',
24
+ bindingLayout: [{ name: 'pbrProjection', group: 0 }],
24
25
  source: wgslUniformBlock,
25
26
  vs: uniformBlock,
26
27
  fs: uniformBlock,
@@ -1 +1 @@
1
- {"version":3,"file":"pbr-projection.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-projection.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAMpC,MAAM,YAAY,GAAG,UAAU,CAAC;;;;;;;CAO/B,CAAC;AAEF,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;CASnC,CAAC;AASF,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,MAAM,EAAE,gBAAgB;IACxB,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,YAAY;IAChB,2BAA2B;IAC3B,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK;IAC3B,YAAY,EAAE;QACZ,yBAAyB,EAAE,aAAa;QACxC,WAAW,EAAE,aAAa;QAC1B,YAAY,EAAE,aAAa;QAC3B,MAAM,EAAE,WAAW;KACpB;CACF,CAAC"}
1
+ {"version":3,"file":"pbr-projection.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-projection.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAMpC,MAAM,YAAY,GAAG,UAAU,CAAC;;;;;;;CAO/B,CAAC;AAEF,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;CASnC,CAAC;AASF,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAClD,MAAM,EAAE,gBAAgB;IACxB,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,YAAY;IAChB,2BAA2B;IAC3B,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK;IAC3B,YAAY,EAAE;QACZ,yBAAyB,EAAE,aAAa;QACxC,WAAW,EAAE,aAAa;QAC1B,YAAY,EAAE,aAAa;QAC3B,MAAM,EAAE,WAAW;KACpB;CACF,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { NumberArray3 } from '@math.gl/types';
2
2
  import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
3
3
  export type PhongMaterialProps = {
4
+ unlit?: boolean;
4
5
  ambient?: number;
5
6
  diffuse?: number;
6
7
  /** Specularity exponent */
@@ -1 +1 @@
1
- {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAKtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CA6B1D,CAAC"}
1
+ {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAKtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CAiC1D,CAAC"}
@@ -7,6 +7,8 @@ import { PHONG_VS, PHONG_FS } from "./phong-shaders-glsl.js";
7
7
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
8
8
  export const phongMaterial = {
9
9
  name: 'phongMaterial',
10
+ firstBindingSlot: 0,
11
+ bindingLayout: [{ name: 'phongMaterial', group: 3 }],
10
12
  dependencies: [lighting],
11
13
  // Note these are switched between phong and gouraud
12
14
  source: PHONG_WGSL,
@@ -16,12 +18,14 @@ export const phongMaterial = {
16
18
  LIGHTING_FRAGMENT: true
17
19
  },
18
20
  uniformTypes: {
21
+ unlit: 'i32',
19
22
  ambient: 'f32',
20
23
  diffuse: 'f32',
21
24
  shininess: 'f32',
22
25
  specularColor: 'vec3<f32>'
23
26
  },
24
27
  defaultUniforms: {
28
+ unlit: false,
25
29
  ambient: 0.35,
26
30
  diffuse: 0.6,
27
31
  shininess: 32,
@@ -1 +1 @@
1
- {"version":3,"file":"phong-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,UAAU,EAAC,gCAA6B;AAChD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gCAA6B;AAUxD,wIAAwI;AACxI,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,oDAAoD;IACpD,MAAM,EAAE,UAAU;IAClB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE;QACP,iBAAiB,EAAE,IAAI;KACxB;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;KAC3B;IACD,eAAe,EAAE;QACf,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;KAClC;IACD,WAAW,CAAC,KAA0B;QACpC,MAAM,QAAQ,GAAG,EAAC,GAAG,KAAK,EAAC,CAAC;QAC5B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC3B,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAiB,CAAC;QACpF,CAAC;QACD,OAAO,EAAC,GAAG,aAAa,CAAC,eAAe,EAAE,GAAG,QAAQ,EAAC,CAAC;IACzD,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"phong-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAI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float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
2
- export declare const PHONG_FS = "#define MAX_LIGHTS 3\n\nuniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (int i = lighting.pointLightCount; i < totalLights; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
1
+ export declare const PHONG_VS = "uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
2
+ export declare const PHONG_FS = "uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
3
3
  //# sourceMappingURL=phong-shaders-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,mKAOpB,CAAC;AAEF,eAAO,MAAM,QAAQ,wkEAgDpB,CAAC"}
1
+ {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,0LAQpB,CAAC;AAEF,eAAO,MAAM,QAAQ,2gFA0DpB,CAAC"}
@@ -3,6 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  export const PHONG_VS = /* glsl */ `\
5
5
  uniform phongMaterialUniforms {
6
+ uniform bool unlit;
6
7
  uniform float ambient;
7
8
  uniform float diffuse;
8
9
  uniform float shininess;
@@ -10,9 +11,8 @@ uniform phongMaterialUniforms {
10
11
  } material;
11
12
  `;
12
13
  export const PHONG_FS = /* glsl */ `\
13
- #define MAX_LIGHTS 3
14
-
15
14
  uniform phongMaterialUniforms {
15
+ uniform bool unlit;
16
16
  uniform float ambient;
17
17
  uniform float diffuse;
18
18
  uniform float shininess;
@@ -34,6 +34,10 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
34
34
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
35
35
  vec3 lightColor = surfaceColor;
36
36
 
37
+ if (material.unlit) {
38
+ return surfaceColor;
39
+ }
40
+
37
41
  if (lighting.enabled == 0) {
38
42
  return lightColor;
39
43
  }
@@ -49,8 +53,15 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
49
53
  lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
50
54
  }
51
55
 
52
- int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
53
- for (int i = lighting.pointLightCount; i < totalLights; i++) {
56
+ for (int i = 0; i < lighting.spotLightCount; i++) {
57
+ SpotLight spotLight = lighting_getSpotLight(i);
58
+ vec3 light_position_worldspace = spotLight.position;
59
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
60
+ float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
61
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);
62
+ }
63
+
64
+ for (int i = 0; i < lighting.directionalLightCount; i++) {
54
65
  DirectionalLight directionalLight = lighting_getDirectionalLight(i);
55
66
  lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
56
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;CAOlC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDlC,CAAC"}
1
+ {"version":3,"file":"phong-shaders-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;;CAQlC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DlC,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const PHONG_WGSL = "struct phongMaterialUniforms {\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@binding(2) @group(0) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n let totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (var i: i32 = lighting.pointLightCount; i < totalLights; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n let totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (var i: i32 = lighting.pointLightCount; i < totalLights; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n";
1
+ export declare const PHONG_WGSL = "struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n";
2
2
  //# sourceMappingURL=phong-shaders-wgsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,4tHA0FtB,CAAC"}
1
+ {"version":3,"file":"phong-shaders-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,2uJAyHtB,CAAC"}
@@ -3,13 +3,14 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  export const PHONG_WGSL = /* wgsl */ `\
5
5
  struct phongMaterialUniforms {
6
+ unlit: u32,
6
7
  ambient: f32,
7
8
  diffuse: f32,
8
9
  shininess: f32,
9
10
  specularColor: vec3<f32>,
10
11
  };
11
12
 
12
- @binding(2) @group(0) var<uniform> phongMaterial : phongMaterialUniforms;
13
+ @group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;
13
14
 
14
15
  fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
15
16
  let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
@@ -26,6 +27,10 @@ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, v
26
27
  fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
27
28
  var lightColor: vec3<f32> = surfaceColor;
28
29
 
30
+ if (phongMaterial.unlit != 0u) {
31
+ return surfaceColor;
32
+ }
33
+
29
34
  if (lighting.enabled == 0) {
30
35
  return lightColor;
31
36
  }
@@ -50,8 +55,21 @@ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, p
50
55
  );
51
56
  }
52
57
 
53
- let totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
54
- for (var i: i32 = lighting.pointLightCount; i < totalLights; i++) {
58
+ for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
59
+ let spotLight: SpotLight = lighting_getSpotLight(i);
60
+ let light_position_worldspace: vec3<f32> = spotLight.position;
61
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
62
+ let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
63
+ lightColor += lighting_getLightColor(
64
+ surfaceColor,
65
+ light_direction,
66
+ view_direction,
67
+ normal_worldspace,
68
+ spotLight.color / light_attenuation
69
+ );
70
+ }
71
+
72
+ for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
55
73
  let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
56
74
  lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
57
75
  }
@@ -83,8 +101,21 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
83
101
  );
84
102
  }
85
103
 
86
- let totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
87
- for (var i: i32 = lighting.pointLightCount; i < totalLights; i++) {
104
+ for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
105
+ let spotLight: SpotLight = lighting_getSpotLight(i);
106
+ let light_position_worldspace: vec3<f32> = spotLight.position;
107
+ let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
108
+ let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
109
+ lightColor += lighting_getLightColor(
110
+ surfaceColor,
111
+ light_direction,
112
+ view_direction,
113
+ normal_worldspace,
114
+ spotLight.color / light_attenuation
115
+ );
116
+ }
117
+
118
+ for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
88
119
  let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
89
120
  lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
90
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FpC,CAAC"}
1
+ {"version":3,"file":"phong-shaders-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHpC,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const fp64arithmeticShader = "\nuniform fp64arithmeticUniforms {\n uniform float ONE;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n const float SPLIT = 4097.0;\n float t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float a_hi = t * fp64.ONE - (t - a);\n float a_lo = a * fp64.ONE - a_hi;\n#else\n float a_hi = t - (t - a);\n float a_lo = a - a_hi;\n#endif\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\n a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n";
1
+ export declare const fp64arithmeticShader = "\nuniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n";
2
2
  //# sourceMappingURL=fp64-arithmetic-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fp64-arithmetic-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,shJAyKhC,CAAC"}
1
+ {"version":3,"file":"fp64-arithmetic-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,kiMAwMhC,CAAC"}
@@ -5,6 +5,7 @@ export const fp64arithmeticShader = /* glsl */ `\
5
5
 
6
6
  uniform fp64arithmeticUniforms {
7
7
  uniform float ONE;
8
+ uniform float SPLIT;
8
9
  } fp64;
9
10
 
10
11
  /*
@@ -14,6 +15,12 @@ The purpose of this workaround is to prevent shader compilers from
14
15
  optimizing away necessary arithmetic operations by swapping their sequences
15
16
  or transform the equation to some 'equivalent' form.
16
17
 
18
+ These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
19
+ folds constants or reassociates the arithmetic, the high/low split can stop
20
+ tracking the rounding error correctly. That failure mode tends to look fine in
21
+ simple coordinate setup, but then breaks down inside iterative arithmetic such
22
+ as fp64 Mandelbrot loops.
23
+
17
24
  The method is to multiply an artifical variable, ONE, which will be known to
18
25
  the compiler to be 1 only at runtime. The whole expression is then represented
19
26
  as a polynomial with respective to ONE. In the coefficients of all terms, only one a
@@ -22,17 +29,23 @@ and one b should appear
22
29
  err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
23
30
  */
24
31
 
25
- // Divide float number to high and low floats to extend fraction bits
26
- vec2 split(float a) {
27
- const float SPLIT = 4097.0;
28
- float t = a * SPLIT;
32
+ float prevent_fp64_optimization(float value) {
29
33
  #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
30
- float a_hi = t * fp64.ONE - (t - a);
31
- float a_lo = a * fp64.ONE - a_hi;
34
+ return value + fp64.ONE * 0.0;
32
35
  #else
33
- float a_hi = t - (t - a);
34
- float a_lo = a - a_hi;
36
+ return value;
35
37
  #endif
38
+ }
39
+
40
+ // Divide float number to high and low floats to extend fraction bits
41
+ vec2 split(float a) {
42
+ // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
43
+ // split into a constant expression and reassociate the recovery steps.
44
+ float split = prevent_fp64_optimization(fp64.SPLIT);
45
+ float t = prevent_fp64_optimization(a * split);
46
+ float temp = t - a;
47
+ float a_hi = t - temp;
48
+ float a_lo = a - a_hi;
36
49
  return vec2(a_hi, a_lo);
37
50
  }
38
51
 
@@ -96,8 +109,26 @@ vec2 twoProd(float a, float b) {
96
109
  float prod = a * b;
97
110
  vec2 a_fp64 = split(a);
98
111
  vec2 b_fp64 = split(b);
99
- float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
100
- a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
112
+ // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
113
+ // on the split terms and cross terms staying in the original evaluation
114
+ // order. If the compiler folds or reassociates them, the low part tends to
115
+ // collapse to zero or NaN on some drivers.
116
+ float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
117
+ float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
118
+ float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
119
+ float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
120
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
121
+ float err1 = (highProduct - prod) * fp64.ONE;
122
+ float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
123
+ float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
124
+ float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
125
+ #else
126
+ float err1 = highProduct - prod;
127
+ float err2 = crossProduct1;
128
+ float err3 = crossProduct2;
129
+ float err4 = lowProduct;
130
+ #endif
131
+ float err = ((err1 + err2) + err3) + err4;
101
132
  return vec2(prod, err);
102
133
  }
103
134
 
@@ -1 +1 @@
1
- {"version":3,"file":"fp64-arithmetic-glsl.js","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyK9C,CAAC"}
1
+ {"version":3,"file":"fp64-arithmetic-glsl.js","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwM9C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const fp64arithmeticWGSL = "struct Fp64ArithmeticUniforms {\n ONE: f32,\n SPLIT: f32,\n};\n\n@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;\n\nfn fp64_nan(seed: f32) -> f32 {\n let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);\n return bitcast<f32>(nanBits);\n}\n\nfn fp64_runtime_zero() -> f32 {\n return fp64arithmetic.ONE * 0.0;\n}\n\nfn prevent_fp64_optimization(value: f32) -> f32 {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n return value + fp64_runtime_zero();\n#else\n return value;\n#endif\n}\n\nfn split(a: f32) -> vec2f {\n let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());\n let t = prevent_fp64_optimization(a * splitValue);\n let temp = prevent_fp64_optimization(t - a);\n let aHi = prevent_fp64_optimization(t - temp);\n let aLo = prevent_fp64_optimization(a - aHi);\n return vec2f(aHi, aLo);\n}\n\nfn split2(a: vec2f) -> vec2f {\n var b = split(a.x);\n b.y = b.y + a.y;\n return b;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);\n let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);\n#else\n let sum = prevent_fp64_optimization(a + b);\n let err = prevent_fp64_optimization(b - (sum - a));\n#endif\n return vec2f(sum, err);\n}\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a + b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) +\n prevent_fp64_optimization(b - v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let s = prevent_fp64_optimization(a - b);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);\n let err =\n prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE) -\n prevent_fp64_optimization(b + v);\n#else\n let v = prevent_fp64_optimization(s - a);\n let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);\n#endif\n return vec2f(s, err);\n}\n\nfn twoSqr(a: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * a);\n let aFp64 = split(a);\n let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);\n let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);\n let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err =\n (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +\n crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +\n lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n#else\n let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);\n#endif\n return vec2f(prod, err);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n let prod = prevent_fp64_optimization(a * b);\n let aFp64 = split(a);\n let bFp64 = split(b);\n let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);\n let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);\n let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);\n let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let err1 = (highProduct - prod) * fp64arithmetic.ONE;\n let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;\n let err4 =\n lowProduct *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE *\n fp64arithmetic.ONE;\n#else\n let err1 = highProduct - prod;\n let err2 = crossProduct1;\n let err3 = crossProduct2;\n let err4 = lowProduct;\n#endif\n let err12InputA = prevent_fp64_optimization(err1);\n let err12InputB = prevent_fp64_optimization(err2);\n let err12 = prevent_fp64_optimization(err12InputA + err12InputB);\n let err123InputA = prevent_fp64_optimization(err12);\n let err123InputB = prevent_fp64_optimization(err3);\n let err123 = prevent_fp64_optimization(err123InputA + err123InputB);\n let err1234InputA = prevent_fp64_optimization(err123);\n let err1234InputB = prevent_fp64_optimization(err4);\n let err = prevent_fp64_optimization(err1234InputA + err1234InputB);\n return vec2f(prod, err);\n}\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSum(a.x, b.x);\n let t = twoSum(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n var s = twoSub(a.x, b.x);\n let t = twoSub(a.y, b.y);\n s.y = prevent_fp64_optimization(s.y + t.x);\n s = quickTwoSum(s.x, s.y);\n s.y = prevent_fp64_optimization(s.y + t.y);\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n var prod = twoProd(a.x, b.x);\n let crossProduct1 = prevent_fp64_optimization(a.x * b.y);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct1);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n let crossProduct2 = prevent_fp64_optimization(a.y * b.x);\n prod.y = prevent_fp64_optimization(prod.y + crossProduct2);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let xn = prevent_fp64_optimization(1.0 / b.x);\n let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));\n let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);\n let prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let x = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let yn = prevent_fp64_optimization(a.x * x);\n#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;\n#else\n let ynSqr = twoSqr(yn);\n#endif\n let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);\n let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);\n#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2f(yn, 0.0), prod);\n#endif\n}\n";
2
+ //# sourceMappingURL=fp64-arithmetic-wgsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fp64-arithmetic-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,yyNA+M9B,CAAC"}