@luma.gl/shadertools 9.2.6 → 9.3.0-alpha.10

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 (174) hide show
  1. package/dist/dist.dev.js +4798 -6439
  2. package/dist/dist.min.js +2047 -311
  3. package/dist/index.cjs +3033 -507
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +12 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -2
  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 +35 -8
  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 +20 -3
  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 +214 -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 +7 -4
  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 +91 -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 +209 -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 +12 -6
  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/assert.d.ts.map +1 -1
  37. package/dist/lib/utils/assert.js +3 -1
  38. package/dist/lib/utils/assert.js.map +1 -1
  39. package/dist/lib/utils/uniform-types.d.ts +11 -7
  40. package/dist/lib/utils/uniform-types.d.ts.map +1 -1
  41. package/dist/modules/engine/picking/picking.d.ts +5 -2
  42. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  43. package/dist/modules/engine/picking/picking.js +5 -2
  44. package/dist/modules/engine/picking/picking.js.map +1 -1
  45. package/dist/modules/engine/project/project.d.ts +1 -1
  46. package/dist/modules/engine/project/project.js +1 -1
  47. package/dist/modules/engine/skin/skin.d.ts +30 -0
  48. package/dist/modules/engine/skin/skin.d.ts.map +1 -0
  49. package/dist/modules/engine/skin/skin.js +86 -0
  50. package/dist/modules/engine/skin/skin.js.map +1 -0
  51. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +1 -0
  52. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  53. package/dist/modules/lighting/gouraud-material/gouraud-material.js +3 -0
  54. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  55. package/dist/modules/lighting/ibl/ibl.d.ts +26 -0
  56. package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
  57. package/dist/modules/lighting/ibl/ibl.js +33 -0
  58. package/dist/modules/lighting/ibl/ibl.js.map +1 -0
  59. package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
  60. package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
  61. package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
  62. package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
  63. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
  64. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
  65. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
  66. package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
  67. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
  68. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
  69. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
  70. package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
  71. package/dist/modules/lighting/lights/lighting-glsl.d.ts +1 -1
  72. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -1
  73. package/dist/modules/lighting/lights/lighting-glsl.js +44 -38
  74. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -1
  75. package/dist/modules/lighting/lights/lighting-wgsl.d.ts +1 -1
  76. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -1
  77. package/dist/modules/lighting/lights/lighting-wgsl.js +46 -18
  78. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -1
  79. package/dist/modules/lighting/lights/lighting.d.ts +104 -62
  80. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  81. package/dist/modules/lighting/lights/lighting.js +107 -68
  82. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  83. package/dist/modules/lighting/no-material/dirlight.d.ts +8 -3
  84. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  85. package/dist/modules/lighting/no-material/dirlight.js +4 -2
  86. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  87. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +1 -1
  88. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
  89. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +581 -28
  90. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
  91. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +2 -2
  92. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
  93. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +850 -107
  94. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
  95. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +172 -41
  96. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  97. package/dist/modules/lighting/pbr-material/pbr-material.js +109 -1
  98. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  99. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  100. package/dist/modules/lighting/pbr-material/pbr-projection.js +14 -2
  101. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  102. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts +40 -0
  103. package/dist/modules/lighting/pbr-material/pbr-scene.d.ts.map +1 -0
  104. package/dist/modules/lighting/pbr-material/pbr-scene.js +67 -0
  105. package/dist/modules/lighting/pbr-material/pbr-scene.js.map +1 -0
  106. package/dist/modules/lighting/phong-material/phong-material.d.ts +1 -0
  107. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  108. package/dist/modules/lighting/phong-material/phong-material.js +4 -0
  109. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  110. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
  111. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  112. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +17 -6
  113. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  114. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -40
  115. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  116. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +71 -76
  117. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  118. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
  119. package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
  120. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +42 -11
  121. package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -1
  122. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +2 -0
  123. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
  124. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +212 -0
  125. package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
  126. package/dist/modules/math/fp64/fp64.d.ts +1 -0
  127. package/dist/modules/math/fp64/fp64.d.ts.map +1 -1
  128. package/dist/modules/math/fp64/fp64.js +8 -2
  129. package/dist/modules/math/fp64/fp64.js.map +1 -1
  130. package/dist/modules/math/random/random.d.ts +1 -1
  131. package/dist/modules/math/random/random.d.ts.map +1 -1
  132. package/dist/modules/math/random/random.js +2 -3
  133. package/dist/modules/math/random/random.js.map +1 -1
  134. package/package.json +4 -5
  135. package/src/index.ts +37 -6
  136. package/src/lib/preprocessor/preprocessor.ts +44 -8
  137. package/src/lib/shader-assembler.ts +25 -3
  138. package/src/lib/shader-assembly/assemble-shaders.ts +384 -12
  139. package/src/lib/shader-assembly/wgsl-binding-debug.ts +216 -0
  140. package/src/lib/shader-generator/glsl/generate-glsl.ts +11 -5
  141. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +6 -0
  142. package/src/lib/shader-module/shader-module-uniform-layout.ts +346 -0
  143. package/src/lib/shader-module/shader-module.ts +17 -7
  144. package/src/lib/utils/assert.ts +3 -1
  145. package/src/lib/utils/uniform-types.ts +24 -9
  146. package/src/modules/engine/picking/picking.ts +5 -2
  147. package/src/modules/engine/project/project.ts +1 -1
  148. package/src/modules/engine/skin/skin.ts +114 -0
  149. package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
  150. package/src/modules/lighting/ibl/ibl.ts +44 -0
  151. package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
  152. package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
  153. package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
  154. package/src/modules/lighting/lights/lighting-glsl.ts +44 -38
  155. package/src/modules/lighting/lights/lighting-wgsl.ts +46 -18
  156. package/src/modules/lighting/lights/lighting.ts +198 -99
  157. package/src/modules/lighting/no-material/dirlight.ts +4 -2
  158. package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +581 -28
  159. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +850 -107
  160. package/src/modules/lighting/pbr-material/pbr-material.ts +185 -5
  161. package/src/modules/lighting/pbr-material/pbr-projection.ts +15 -2
  162. package/src/modules/lighting/pbr-material/pbr-scene.ts +91 -0
  163. package/src/modules/lighting/phong-material/phong-material.ts +5 -0
  164. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +17 -6
  165. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +71 -77
  166. package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +42 -11
  167. package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +212 -0
  168. package/src/modules/math/fp64/fp64.ts +9 -3
  169. package/src/modules/math/random/random.ts +2 -3
  170. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts +0 -8
  171. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +0 -1
  172. package/dist/lib/wgsl/get-shader-layout-wgsl.js +0 -95
  173. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +0 -1
  174. package/src/lib/wgsl/get-shader-layout-wgsl.ts +0 -105
@@ -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,
@@ -24,6 +92,19 @@ export const pbrMaterial = {
24
92
  HAS_OCCLUSIONMAP: false,
25
93
  HAS_BASECOLORMAP: false,
26
94
  HAS_METALROUGHNESSMAP: false,
95
+ HAS_SPECULARCOLORMAP: false,
96
+ HAS_SPECULARINTENSITYMAP: false,
97
+ HAS_TRANSMISSIONMAP: false,
98
+ HAS_THICKNESSMAP: false,
99
+ HAS_CLEARCOATMAP: false,
100
+ HAS_CLEARCOATROUGHNESSMAP: false,
101
+ HAS_CLEARCOATNORMALMAP: false,
102
+ HAS_SHEENCOLORMAP: false,
103
+ HAS_SHEENROUGHNESSMAP: false,
104
+ HAS_IRIDESCENCEMAP: false,
105
+ HAS_IRIDESCENCETHICKNESSMAP: false,
106
+ HAS_ANISOTROPYMAP: false,
107
+ USE_MATERIAL_EXTENSIONS: false,
27
108
  ALPHA_CUTOFF: false,
28
109
  USE_IBL: false,
29
110
  PBR_DEBUG: false
@@ -45,6 +126,33 @@ export const pbrMaterial = {
45
126
  occlusionStrength: 'f32', // #ifdef HAS_OCCLUSIONMAP
46
127
  alphaCutoffEnabled: 'i32',
47
128
  alphaCutoff: 'f32', // #ifdef ALPHA_CUTOFF
129
+ specularColorFactor: 'vec3<f32>',
130
+ specularIntensityFactor: 'f32',
131
+ specularColorMapEnabled: 'i32',
132
+ specularIntensityMapEnabled: 'i32',
133
+ ior: 'f32',
134
+ transmissionFactor: 'f32',
135
+ transmissionMapEnabled: 'i32',
136
+ thicknessFactor: 'f32',
137
+ attenuationDistance: 'f32',
138
+ attenuationColor: 'vec3<f32>',
139
+ clearcoatFactor: 'f32',
140
+ clearcoatRoughnessFactor: 'f32',
141
+ clearcoatMapEnabled: 'i32',
142
+ clearcoatRoughnessMapEnabled: 'i32',
143
+ sheenColorFactor: 'vec3<f32>',
144
+ sheenRoughnessFactor: 'f32',
145
+ sheenColorMapEnabled: 'i32',
146
+ sheenRoughnessMapEnabled: 'i32',
147
+ iridescenceFactor: 'f32',
148
+ iridescenceIor: 'f32',
149
+ iridescenceThicknessRange: 'vec2<f32>',
150
+ iridescenceMapEnabled: 'i32',
151
+ anisotropyStrength: 'f32',
152
+ anisotropyRotation: 'f32',
153
+ anisotropyDirection: 'vec2<f32>',
154
+ anisotropyMapEnabled: 'i32',
155
+ emissiveStrength: 'f32',
48
156
  // IBL
49
157
  IBLenabled: 'i32',
50
158
  scaleIBLAmbient: 'vec2<f32>', // #ifdef USE_IBL
@@ -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,EAA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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;AAWtE,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,CAY1D,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"}
@@ -2,15 +2,27 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  const uniformBlock = /* glsl */ `\
5
- uniform pbrProjectionUniforms {
5
+ layout(std140) uniform pbrProjectionUniforms {
6
6
  mat4 modelViewProjectionMatrix;
7
7
  mat4 modelMatrix;
8
8
  mat4 normalMatrix;
9
9
  vec3 camera;
10
10
  } pbrProjection;
11
11
  `;
12
+ const wgslUniformBlock = /* wgsl */ `\
13
+ struct pbrProjectionUniforms {
14
+ modelViewProjectionMatrix: mat4x4<f32>,
15
+ modelMatrix: mat4x4<f32>,
16
+ normalMatrix: mat4x4<f32>,
17
+ camera: vec3<f32>
18
+ };
19
+
20
+ @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms;
21
+ `;
12
22
  export const pbrProjection = {
13
23
  name: 'pbrProjection',
24
+ bindingLayout: [{ name: 'pbrProjection', group: 0 }],
25
+ source: wgslUniformBlock,
14
26
  vs: uniformBlock,
15
27
  fs: uniformBlock,
16
28
  // TODO why is this needed?
@@ -19,7 +31,7 @@ export const pbrProjection = {
19
31
  modelViewProjectionMatrix: 'mat4x4<f32>',
20
32
  modelMatrix: 'mat4x4<f32>',
21
33
  normalMatrix: 'mat4x4<f32>',
22
- camera: 'vec3<i32>'
34
+ camera: 'vec3<f32>'
23
35
  }
24
36
  };
25
37
  //# sourceMappingURL=pbr-projection.js.map
@@ -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;AASF,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,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"}
@@ -0,0 +1,40 @@
1
+ import type { Texture } from '@luma.gl/core';
2
+ import type { NumberArray2, NumberArray16 } from '@math.gl/core';
3
+ export type PBRSceneBindings = {
4
+ pbr_transmissionFramebufferSampler?: Texture | null;
5
+ };
6
+ export type PBRSceneUniforms = {
7
+ exposure?: number;
8
+ toneMapMode?: number;
9
+ environmentIntensity?: number;
10
+ environmentRotation?: number;
11
+ framebufferSize?: NumberArray2;
12
+ viewMatrix?: NumberArray16;
13
+ projectionMatrix?: NumberArray16;
14
+ };
15
+ export type PBRSceneProps = PBRSceneBindings & PBRSceneUniforms;
16
+ export declare const pbrScene: {
17
+ readonly name: "pbrScene";
18
+ readonly bindingLayout: readonly [{
19
+ readonly name: "pbrScene";
20
+ readonly group: 1;
21
+ }, {
22
+ readonly name: "pbr_transmissionFramebufferSampler";
23
+ readonly group: 1;
24
+ }];
25
+ readonly source: "struct pbrSceneUniforms {\n exposure: f32,\n toneMapMode: i32,\n environmentIntensity: f32,\n environmentRotation: f32,\n framebufferSize: vec2<f32>,\n viewMatrix: mat4x4<f32>,\n projectionMatrix: mat4x4<f32>\n};\n\n@group(1) @binding(auto) var<uniform> pbrScene: pbrSceneUniforms;\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\n@group(1) @binding(auto) var pbr_transmissionFramebufferSampler: texture_2d<f32>;\n@group(1) @binding(auto) var pbr_transmissionFramebufferSamplerSampler: sampler;\n#endif\n";
26
+ readonly vs: "layout(std140) uniform pbrSceneUniforms {\n float exposure;\n int toneMapMode;\n float environmentIntensity;\n float environmentRotation;\n vec2 framebufferSize;\n mat4 viewMatrix;\n mat4 projectionMatrix;\n} pbrScene;\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nuniform sampler2D pbr_transmissionFramebufferSampler;\n#endif\n";
27
+ readonly fs: "layout(std140) uniform pbrSceneUniforms {\n float exposure;\n int toneMapMode;\n float environmentIntensity;\n float environmentRotation;\n vec2 framebufferSize;\n mat4 viewMatrix;\n mat4 projectionMatrix;\n} pbrScene;\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nuniform sampler2D pbr_transmissionFramebufferSampler;\n#endif\n";
28
+ readonly getUniforms: (props: PBRSceneProps) => PBRSceneProps;
29
+ readonly uniformTypes: {
30
+ readonly exposure: "f32";
31
+ readonly toneMapMode: "i32";
32
+ readonly environmentIntensity: "f32";
33
+ readonly environmentRotation: "f32";
34
+ readonly framebufferSize: "vec2<f32>";
35
+ readonly viewMatrix: "mat4x4<f32>";
36
+ readonly projectionMatrix: "mat4x4<f32>";
37
+ };
38
+ readonly defaultUniforms: Required<PBRSceneUniforms>;
39
+ };
40
+ //# sourceMappingURL=pbr-scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbr-scene.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-scene.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAI/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kCAAkC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,gBAAgB,CAAC,EAAE,aAAa,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAuChE,eAAO,MAAM,QAAQ;;;;;;;;;;;;kCASE,aAAa;;;;;;;;;;8BAkB7B,QAAQ,CAAC,gBAAgB,CAAC;CACmD,CAAC"}
@@ -0,0 +1,67 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ const IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5
+ const uniformBlock = /* glsl */ `\
6
+ layout(std140) uniform pbrSceneUniforms {
7
+ float exposure;
8
+ int toneMapMode;
9
+ float environmentIntensity;
10
+ float environmentRotation;
11
+ vec2 framebufferSize;
12
+ mat4 viewMatrix;
13
+ mat4 projectionMatrix;
14
+ } pbrScene;
15
+
16
+ #ifdef USE_TRANSMISSION_FRAMEBUFFER
17
+ uniform sampler2D pbr_transmissionFramebufferSampler;
18
+ #endif
19
+ `;
20
+ const wgslUniformBlock = /* wgsl */ `\
21
+ struct pbrSceneUniforms {
22
+ exposure: f32,
23
+ toneMapMode: i32,
24
+ environmentIntensity: f32,
25
+ environmentRotation: f32,
26
+ framebufferSize: vec2<f32>,
27
+ viewMatrix: mat4x4<f32>,
28
+ projectionMatrix: mat4x4<f32>
29
+ };
30
+
31
+ @group(1) @binding(auto) var<uniform> pbrScene: pbrSceneUniforms;
32
+
33
+ #ifdef USE_TRANSMISSION_FRAMEBUFFER
34
+ @group(1) @binding(auto) var pbr_transmissionFramebufferSampler: texture_2d<f32>;
35
+ @group(1) @binding(auto) var pbr_transmissionFramebufferSamplerSampler: sampler;
36
+ #endif
37
+ `;
38
+ export const pbrScene = {
39
+ name: 'pbrScene',
40
+ bindingLayout: [
41
+ { name: 'pbrScene', group: 1 },
42
+ { name: 'pbr_transmissionFramebufferSampler', group: 1 }
43
+ ],
44
+ source: wgslUniformBlock,
45
+ vs: uniformBlock,
46
+ fs: uniformBlock,
47
+ getUniforms: (props) => props,
48
+ uniformTypes: {
49
+ exposure: 'f32',
50
+ toneMapMode: 'i32',
51
+ environmentIntensity: 'f32',
52
+ environmentRotation: 'f32',
53
+ framebufferSize: 'vec2<f32>',
54
+ viewMatrix: 'mat4x4<f32>',
55
+ projectionMatrix: 'mat4x4<f32>'
56
+ },
57
+ defaultUniforms: {
58
+ exposure: 1,
59
+ toneMapMode: 2,
60
+ environmentIntensity: 1,
61
+ environmentRotation: Math.PI * 0.5,
62
+ framebufferSize: [1, 1],
63
+ viewMatrix: IDENTITY_MATRIX,
64
+ projectionMatrix: IDENTITY_MATRIX
65
+ }
66
+ };
67
+ //# sourceMappingURL=pbr-scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3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,EAAE,eAAe;QAC3B,gBAAgB,EAAE,eAAe;KACJ;CACmD,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;AAIpC,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,UAAU,EAAC,gCAA6B;AAChD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gCAA6B;AAWxD,wIAAwI;AACxI,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAClD,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,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;KAC3B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,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,3 +1,3 @@
1
- export declare const PHONG_VS = "uniform phongMaterialUniforms {\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 = "#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 = "layout(std140) 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 = "layout(std140) 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,yMAQpB,CAAC;AAEF,eAAO,MAAM,QAAQ,0hFA0DpB,CAAC"}
@@ -2,7 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  export const PHONG_VS = /* glsl */ `\
5
- uniform phongMaterialUniforms {
5
+ layout(std140) 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
- uniform phongMaterialUniforms {
14
+ layout(std140) 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,41 +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 if (lighting.lightType == 0) {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n var directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\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 switch (lighting.lightType) {\n case 0, default: {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n case 1: {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n }\n return lightColor;\n}\n";
2
- /**
3
- for (int i = 0; i < MAX_LIGHTS; i++) {
4
- if (i >= lighting.pointLightCount) {
5
- break;
6
- }
7
- PointLight pointLight = lighting_getPointLight(i);
8
- vec3 light_position_worldspace = pointLight.position;
9
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
10
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
11
- }
12
-
13
- for (int i = 0; i < MAX_LIGHTS; i++) {
14
- if (i >= lighting.directionalLightCount) {
15
- break;
16
- }
17
- PointLight pointLight = lighting_getDirectionalLight(i);
18
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
19
- }
20
- }
21
- /**
22
- for (int i = 0; i < MAX_LIGHTS; i++) {
23
- if (i >= lighting.pointLightCount) {
24
- break;
25
- }
26
- PointLight pointLight = lighting_getPointLight(i);
27
- vec3 light_position_worldspace = pointLight.position;
28
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
29
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
30
- }
31
-
32
- for (int i = 0; i < MAX_LIGHTS; i++) {
33
- if (i >= lighting.directionalLightCount) {
34
- break;
35
- }
36
- PointLight pointLight = lighting_getDirectionalLight(i);
37
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
38
- }
39
- }
40
- */
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";
41
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,ywHAsFtB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsCI"}
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"}