p5 2.2.1-rc.0 → 2.2.1

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 (117) hide show
  1. package/dist/accessibility/color_namer.js +5 -6
  2. package/dist/accessibility/describe.js +4 -26
  3. package/dist/accessibility/index.js +5 -6
  4. package/dist/accessibility/outputs.js +6 -38
  5. package/dist/app.js +5 -6
  6. package/dist/color/color_conversion.js +5 -6
  7. package/dist/color/creating_reading.js +1 -1
  8. package/dist/color/index.js +2 -2
  9. package/dist/color/p5.Color.js +1 -1
  10. package/dist/color/setting.js +59 -357
  11. package/dist/{constants-DEJVKr9Z.js → constants-DQyACdzq.js} +11 -61
  12. package/dist/core/constants.js +1 -1
  13. package/dist/core/environment.js +26 -158
  14. package/dist/core/filterShaders.js +1 -1
  15. package/dist/core/friendly_errors/fes_core.js +1 -1
  16. package/dist/core/friendly_errors/file_errors.js +1 -1
  17. package/dist/core/friendly_errors/index.js +1 -1
  18. package/dist/core/friendly_errors/param_validator.js +1 -1
  19. package/dist/core/friendly_errors/sketch_verifier.js +1 -1
  20. package/dist/core/helpers.js +1 -1
  21. package/dist/core/init.js +5 -6
  22. package/dist/core/internationalization.js +1 -1
  23. package/dist/core/legacy.js +5 -6
  24. package/dist/core/main.js +5 -6
  25. package/dist/core/p5.Graphics.js +4 -5
  26. package/dist/core/p5.Renderer.js +3 -4
  27. package/dist/core/p5.Renderer2D.js +5 -6
  28. package/dist/core/p5.Renderer3D.js +4 -5
  29. package/dist/core/rendering.js +4 -5
  30. package/dist/core/structure.js +13 -52
  31. package/dist/core/transform.js +32 -176
  32. package/dist/{creating_reading-CgHCHxqN.js → creating_reading-ZXzcZEsb.js} +3 -196
  33. package/dist/data/local_storage.js +4 -30
  34. package/dist/dom/dom.js +24 -159
  35. package/dist/dom/index.js +2 -2
  36. package/dist/dom/p5.Element.js +31 -208
  37. package/dist/dom/p5.File.js +1 -32
  38. package/dist/dom/p5.MediaElement.js +10 -113
  39. package/dist/events/acceleration.js +11 -64
  40. package/dist/events/keyboard.js +13 -81
  41. package/dist/events/pointer.js +18 -160
  42. package/dist/image/const.js +1 -1
  43. package/dist/image/filterRenderer2D.js +4 -5
  44. package/dist/image/image.js +4 -5
  45. package/dist/image/index.js +4 -5
  46. package/dist/image/loading_displaying.js +4 -5
  47. package/dist/image/p5.Image.js +3 -4
  48. package/dist/image/pixels.js +17 -100
  49. package/dist/io/files.js +4 -5
  50. package/dist/io/index.js +4 -5
  51. package/dist/io/p5.Table.js +66 -158
  52. package/dist/io/p5.TableRow.js +48 -71
  53. package/dist/io/p5.XML.js +6 -99
  54. package/dist/io/utilities.js +8 -3
  55. package/dist/{main-_RXV5Lx8.js → main-DvN69W3f.js} +13 -42
  56. package/dist/math/Matrices/Matrix.js +87 -126
  57. package/dist/math/Matrices/MatrixNumjs.js +1 -5
  58. package/dist/math/calculation.js +10 -112
  59. package/dist/math/index.js +1 -1
  60. package/dist/math/math.js +2 -12
  61. package/dist/math/noise.js +5 -32
  62. package/dist/math/p5.Matrix.js +3 -3
  63. package/dist/math/p5.Vector.js +104 -345
  64. package/dist/math/random.js +5 -32
  65. package/dist/math/trigonometry.js +15 -105
  66. package/dist/{p5.Renderer-QoFcvj3f.js → p5.Renderer-D-5LdCRz.js} +25 -178
  67. package/dist/{rendering-CsICjEXA.js → rendering-h9unX5K0.js} +254 -1156
  68. package/dist/shape/2d_primitives.js +33 -194
  69. package/dist/shape/attributes.js +12 -73
  70. package/dist/shape/curves.js +30 -95
  71. package/dist/shape/custom_shapes.js +63 -144
  72. package/dist/shape/index.js +2 -2
  73. package/dist/shape/vertex.js +21 -106
  74. package/dist/strands/p5.strands.js +248 -46
  75. package/dist/type/index.js +3 -4
  76. package/dist/type/p5.Font.js +4 -49
  77. package/dist/type/textCore.js +5 -158
  78. package/dist/utilities/conversion.js +17 -104
  79. package/dist/utilities/time_date.js +3 -40
  80. package/dist/utilities/utility_functions.js +6 -48
  81. package/dist/webgl/3d_primitives.js +4 -5
  82. package/dist/webgl/GeometryBuilder.js +1 -2
  83. package/dist/webgl/ShapeBuilder.js +22 -2
  84. package/dist/webgl/enums.js +1 -1
  85. package/dist/webgl/index.js +4 -5
  86. package/dist/webgl/interaction.js +6 -33
  87. package/dist/webgl/light.js +4 -5
  88. package/dist/webgl/loading.js +12 -46
  89. package/dist/webgl/material.js +4 -5
  90. package/dist/webgl/p5.Camera.js +4 -5
  91. package/dist/webgl/p5.DataArray.js +0 -4
  92. package/dist/webgl/p5.Framebuffer.js +4 -5
  93. package/dist/webgl/p5.Geometry.js +12 -106
  94. package/dist/webgl/p5.Quat.js +1 -1
  95. package/dist/webgl/p5.RendererGL.js +7 -18
  96. package/dist/webgl/p5.Shader.js +12 -36
  97. package/dist/webgl/p5.Texture.js +4 -5
  98. package/dist/webgl/text.js +4 -5
  99. package/dist/webgl/utils.js +4 -5
  100. package/dist/webgpu/index.js +1 -1
  101. package/dist/webgpu/p5.RendererWebGPU.js +529 -208
  102. package/dist/webgpu/shaders/color.js +32 -17
  103. package/dist/webgpu/shaders/filters/base.js +18 -7
  104. package/dist/webgpu/shaders/font.js +52 -40
  105. package/dist/webgpu/shaders/line.js +50 -36
  106. package/dist/webgpu/shaders/material.js +90 -83
  107. package/dist/webgpu/strands_wgslBackend.js +5 -2
  108. package/lib/p5.esm.js +5576 -7811
  109. package/lib/p5.esm.min.js +1 -1
  110. package/lib/p5.js +5576 -7811
  111. package/lib/p5.min.js +1 -1
  112. package/lib/p5.webgpu.esm.js +786 -453
  113. package/lib/p5.webgpu.js +786 -453
  114. package/lib/p5.webgpu.min.js +1 -1
  115. package/package.json +13 -13
  116. package/types/global.d.ts +16905 -16783
  117. package/types/p5.d.ts +11142 -11081
@@ -1,40 +1,29 @@
1
1
  const uniforms = `
2
- struct Uniforms {
3
- // @p5 ifdef Vertex getWorldInputs
4
- uModelMatrix: mat4x4<f32>,
5
- uModelNormalMatrix: mat3x3<f32>,
6
- uCameraNormalMatrix: mat3x3<f32>,
7
- // @p5 endif
8
- // @p5 ifndef Vertex getWorldInputs
9
- uModelViewMatrix: mat4x4<f32>,
10
- uNormalMatrix: mat3x3<f32>,
11
- // @p5 endif
12
- uViewMatrix: mat4x4<f32>,
13
- uProjectionMatrix: mat4x4<f32>,
14
- uMaterialColor: vec4<f32>,
2
+ // Group 0: Material Properties
3
+ struct MaterialUniforms {
15
4
  uUseVertexColor: u32,
16
-
17
5
  uHasSetAmbient: u32,
18
6
  uAmbientColor: vec3<f32>,
19
7
  uSpecularMatColor: vec4<f32>,
20
8
  uAmbientMatColor: vec4<f32>,
21
9
  uEmissiveMatColor: vec4<f32>,
22
-
23
10
  uTint: vec4<f32>,
24
11
  isTexture: u32,
12
+ uSpecular: u32,
13
+ uShininess: f32,
14
+ uMetallic: f32,
15
+ }
25
16
 
26
- uCameraRotation: mat3x3<f32>,
27
-
17
+ // Group 0: Lighting
18
+ struct LightingUniforms {
28
19
  uDirectionalLightCount: i32,
29
20
  uLightingDirection: array<vec3<f32>, 5>,
30
21
  uDirectionalDiffuseColors: array<vec3<f32>, 5>,
31
22
  uDirectionalSpecularColors: array<vec3<f32>, 5>,
32
-
33
23
  uPointLightCount: i32,
34
24
  uPointLightLocation: array<vec3<f32>, 5>,
35
25
  uPointLightDiffuseColors: array<vec3<f32>, 5>,
36
26
  uPointLightSpecularColors: array<vec3<f32>, 5>,
37
-
38
27
  uSpotLightCount: i32,
39
28
  uSpotLightAngle: vec4<f32>,
40
29
  uSpotLightConc: vec4<f32>,
@@ -42,18 +31,32 @@ struct Uniforms {
42
31
  uSpotLightSpecularColors: array<vec3<f32>, 4>,
43
32
  uSpotLightLocation: array<vec3<f32>, 4>,
44
33
  uSpotLightDirection: array<vec3<f32>, 4>,
45
-
46
- uSpecular: u32,
47
- uShininess: f32,
48
- uMetallic: f32,
49
-
50
34
  uConstantAttenuation: f32,
51
35
  uLinearAttenuation: f32,
52
36
  uQuadraticAttenuation: f32,
53
-
54
37
  uUseImageLight: u32,
55
38
  uUseLighting: u32,
56
- };
39
+ }
40
+
41
+ // Group 1: Model Transform
42
+ struct ModelUniforms {
43
+ // @p5 ifdef Vertex getWorldInputs
44
+ uModelMatrix: mat4x4<f32>,
45
+ uModelNormalMatrix: mat3x3<f32>,
46
+ // @p5 endif
47
+ // @p5 ifndef Vertex getWorldInputs
48
+ uModelViewMatrix: mat4x4<f32>,
49
+ uNormalMatrix: mat3x3<f32>,
50
+ // @p5 endif
51
+ uMaterialColor: vec4<f32>,
52
+ }
53
+
54
+ // Group 2: Camera and Projection
55
+ struct CameraUniforms {
56
+ uViewMatrix: mat4x4<f32>,
57
+ uProjectionMatrix: mat4x4<f32>,
58
+ uCameraNormalMatrix: mat3x3<f32>,
59
+ }
57
60
  `;
58
61
 
59
62
  const materialVertexShader = `
@@ -73,7 +76,10 @@ struct VertexOutput {
73
76
  };
74
77
 
75
78
  ${uniforms}
76
- @group(0) @binding(0) var<uniform> uniforms: Uniforms;
79
+ @group(0) @binding(0) var<uniform> material: MaterialUniforms;
80
+ @group(0) @binding(1) var<uniform> lighting: LightingUniforms;
81
+ @group(1) @binding(0) var<uniform> model: ModelUniforms;
82
+ @group(2) @binding(0) var<uniform> camera: CameraUniforms;
77
83
 
78
84
  struct Vertex {
79
85
  position: vec3<f32>,
@@ -87,12 +93,12 @@ fn main(input: VertexInput) -> VertexOutput {
87
93
  HOOK_beforeVertex();
88
94
  var output: VertexOutput;
89
95
 
90
- let useVertexColor = (uniforms.uUseVertexColor != 0 && input.aVertexColor.x >= 0.0);
96
+ let useVertexColor = (material.uUseVertexColor != 0 && input.aVertexColor.x >= 0.0);
91
97
  var inputs = Vertex(
92
98
  input.aPosition,
93
99
  input.aNormal,
94
100
  input.aTexCoord,
95
- select(uniforms.uMaterialColor, input.aVertexColor, useVertexColor)
101
+ select(model.uMaterialColor, input.aVertexColor, useVertexColor)
96
102
  );
97
103
 
98
104
  // @p5 ifdef Vertex getObjectInputs
@@ -100,20 +106,20 @@ fn main(input: VertexInput) -> VertexOutput {
100
106
  // @p5 endif
101
107
 
102
108
  // @p5 ifdef Vertex getWorldInputs
103
- inputs.position = (uniforms.uModelMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
104
- inputs.normal = uniforms.uModelNormalMatrix * inputs.normal;
109
+ inputs.position = (model.uModelMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
110
+ inputs.normal = model.uModelNormalMatrix * inputs.normal;
105
111
  inputs = HOOK_getWorldInputs(inputs);
106
112
  // @p5 endif
107
113
 
108
114
  // @p5 ifdef Vertex getWorldInputs
109
115
  // Already multiplied by the model matrix, just apply view
110
- inputs.position = (uniforms.uViewMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
111
- inputs.normal = uniforms.uCameraNormalMatrix * inputs.normal;
116
+ inputs.position = (camera.uViewMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
117
+ inputs.normal = camera.uCameraNormalMatrix * inputs.normal;
112
118
  // @p5 endif
113
119
  // @p5 ifndef Vertex getWorldInputs
114
120
  // Apply both at once
115
- inputs.position = (uniforms.uModelViewMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
116
- inputs.normal = uniforms.uNormalMatrix * inputs.normal;
121
+ inputs.position = (model.uModelViewMatrix * vec4<f32>(inputs.position, 1.0)).xyz;
122
+ inputs.normal = model.uNormalMatrix * inputs.normal;
117
123
  // @p5 endif
118
124
 
119
125
  // @p5 ifdef Vertex getCameraInputs
@@ -125,7 +131,7 @@ fn main(input: VertexInput) -> VertexOutput {
125
131
  output.vNormal = normalize(inputs.normal);
126
132
  output.vColor = inputs.color;
127
133
 
128
- output.Position = uniforms.uProjectionMatrix * vec4<f32>(inputs.position, 1.0);
134
+ output.Position = camera.uProjectionMatrix * vec4<f32>(inputs.position, 1.0);
129
135
 
130
136
  HOOK_afterVertex();
131
137
  return output;
@@ -141,15 +147,16 @@ struct FragmentInput {
141
147
  };
142
148
 
143
149
  ${uniforms}
144
- @group(0) @binding(0) var<uniform> uniforms: Uniforms;
145
-
146
- @group(0) @binding(1) var uSampler: texture_2d<f32>;
147
- @group(0) @binding(2) var uSampler_sampler: sampler;
148
-
149
- @group(0) @binding(3) var environmentMapDiffused: texture_2d<f32>;
150
- @group(0) @binding(4) var environmentMapDiffused_sampler: sampler;
151
- @group(0) @binding(5) var environmentMapSpecular: texture_2d<f32>;
152
- @group(0) @binding(6) var environmentMapSpecular_sampler: sampler;
150
+ @group(0) @binding(0) var<uniform> material: MaterialUniforms;
151
+ @group(0) @binding(1) var<uniform> lighting: LightingUniforms;
152
+ @group(0) @binding(2) var uSampler: texture_2d<f32>;
153
+ @group(0) @binding(3) var uSampler_sampler: sampler;
154
+ @group(0) @binding(4) var environmentMapDiffused: texture_2d<f32>;
155
+ @group(0) @binding(5) var environmentMapDiffused_sampler: sampler;
156
+ @group(0) @binding(6) var environmentMapSpecular: texture_2d<f32>;
157
+ @group(0) @binding(7) var environmentMapSpecular_sampler: sampler;
158
+ @group(1) @binding(0) var<uniform> model: ModelUniforms;
159
+ @group(2) @binding(0) var<uniform> camera: CameraUniforms;
153
160
 
154
161
  struct ColorComponents {
155
162
  baseColor: vec3<f32>,
@@ -212,7 +219,7 @@ fn mapTextureToNormal(v: vec3<f32>) -> vec2<f32> {
212
219
  fn calculateImageDiffuse(vNormal: vec3<f32>, vViewPosition: vec3<f32>, metallic: f32) -> vec3<f32> {
213
220
  // make 2 seperate builds
214
221
  let worldCameraPosition = vec3<f32>(0.0, 0.0, 0.0); // hardcoded world camera position
215
- let worldNormal = normalize(vNormal * uniforms.uCameraRotation);
222
+ let worldNormal = normalize(vNormal * camera.uCameraNormalMatrix);
216
223
  let newTexCoord = mapTextureToNormal(worldNormal);
217
224
  let texture = textureSample(environmentMapDiffused, environmentMapDiffused_sampler, newTexCoord);
218
225
  // this is to make the darker sections more dark
@@ -224,7 +231,7 @@ fn calculateImageSpecular(vNormal: vec3<f32>, vViewPosition: vec3<f32>, shinines
224
231
  let worldCameraPosition = vec3<f32>(0.0, 0.0, 0.0);
225
232
  let worldNormal = normalize(vNormal);
226
233
  let lightDirection = normalize(vViewPosition - worldCameraPosition);
227
- let R = reflect(lightDirection, worldNormal) * uniforms.uCameraRotation;
234
+ let R = reflect(lightDirection, worldNormal) * camera.uCameraNormalMatrix;
228
235
  let newTexCoord = mapTextureToNormal(R);
229
236
 
230
237
  // In p5js the range of shininess is >= 1,
@@ -273,7 +280,7 @@ fn singleLight(
273
280
  let specular = select(
274
281
  0.,
275
282
  phongSpecular(lightDir, viewDirection, normal, shininess) * specularIntensity,
276
- uniforms.uSpecular == 1
283
+ material.uSpecular == 1
277
284
  );
278
285
  return LightIntensityResult(diffuse, specular);
279
286
  }
@@ -287,69 +294,69 @@ fn totalLight(
287
294
  var totalSpecular = vec3<f32>(0.0, 0.0, 0.0);
288
295
  var totalDiffuse = vec3<f32>(0.0, 0.0, 0.0);
289
296
 
290
- if (uniforms.uUseLighting == 0) {
297
+ if (lighting.uUseLighting == 0) {
291
298
  return LightResult(vec3<f32>(1.0, 1.0, 1.0), totalSpecular);
292
299
  }
293
300
 
294
301
  let viewDirection = normalize(-modelPosition);
295
302
 
296
303
  for (var j = 0; j < 5; j++) {
297
- if (j < uniforms.uDirectionalLightCount) {
298
- let lightVector = (uniforms.uViewMatrix * vec4<f32>(
299
- uniforms.uLightingDirection[j],
304
+ if (j < lighting.uDirectionalLightCount) {
305
+ let lightVector = (camera.uViewMatrix * vec4<f32>(
306
+ lighting.uLightingDirection[j],
300
307
  0.0
301
308
  )).xyz;
302
- let lightColor = uniforms.uDirectionalDiffuseColors[j];
303
- let specularColor = uniforms.uDirectionalSpecularColors[j];
309
+ let lightColor = lighting.uDirectionalDiffuseColors[j];
310
+ let specularColor = lighting.uDirectionalSpecularColors[j];
304
311
  let result = singleLight(viewDirection, normal, lightVector, shininess, metallic);
305
312
  totalDiffuse += result.diffuse * lightColor;
306
313
  totalSpecular += result.specular * specularColor;
307
314
  }
308
315
 
309
- if (j < uniforms.uPointLightCount) {
310
- let lightPosition = (uniforms.uViewMatrix * vec4<f32>(
311
- uniforms.uPointLightLocation[j],
316
+ if (j < lighting.uPointLightCount) {
317
+ let lightPosition = (camera.uViewMatrix * vec4<f32>(
318
+ lighting.uPointLightLocation[j],
312
319
  1.0
313
320
  )).xyz;
314
321
  let lightVector = modelPosition - lightPosition;
315
322
  let lightDistance = length(lightVector);
316
323
  let lightFalloff = 1.0 / (
317
- uniforms.uConstantAttenuation +
318
- lightDistance * uniforms.uLinearAttenuation +
319
- lightDistance * lightDistance * uniforms.uQuadraticAttenuation
324
+ lighting.uConstantAttenuation +
325
+ lightDistance * lighting.uLinearAttenuation +
326
+ lightDistance * lightDistance * lighting.uQuadraticAttenuation
320
327
  );
321
- let lightColor = uniforms.uPointLightDiffuseColors[j] * lightFalloff;
322
- let specularColor = uniforms.uPointLightSpecularColors[j] * lightFalloff;
328
+ let lightColor = lighting.uPointLightDiffuseColors[j] * lightFalloff;
329
+ let specularColor = lighting.uPointLightSpecularColors[j] * lightFalloff;
323
330
  let result = singleLight(viewDirection, normal, lightVector, shininess, metallic);
324
331
  totalDiffuse += result.diffuse * lightColor;
325
332
  totalSpecular += result.specular * specularColor;
326
333
  }
327
334
 
328
- if (j < uniforms.uSpotLightCount) {
329
- let lightPosition = (uniforms.uViewMatrix * vec4<f32>(
330
- uniforms.uSpotLightLocation[j],
335
+ if (j < lighting.uSpotLightCount) {
336
+ let lightPosition = (camera.uViewMatrix * vec4<f32>(
337
+ lighting.uSpotLightLocation[j],
331
338
  1.0
332
339
  )).xyz;
333
340
  let lightVector = modelPosition - lightPosition;
334
341
  let lightDistance = length(lightVector);
335
342
  var lightFalloff = 1.0 / (
336
- uniforms.uConstantAttenuation +
337
- lightDistance * uniforms.uLinearAttenuation +
338
- lightDistance * lightDistance * uniforms.uQuadraticAttenuation
343
+ lighting.uConstantAttenuation +
344
+ lightDistance * lighting.uLinearAttenuation +
345
+ lightDistance * lightDistance * lighting.uQuadraticAttenuation
339
346
  );
340
- let lightDirection = (uniforms.uViewMatrix * vec4<f32>(
341
- uniforms.uSpotLightDirection[j],
347
+ let lightDirection = (camera.uViewMatrix * vec4<f32>(
348
+ lighting.uSpotLightDirection[j],
342
349
  0.0
343
350
  )).xyz;
344
351
  let spotDot = dot(normalize(lightVector), normalize(lightDirection));
345
352
  let spotFalloff = select(
346
353
  0.0,
347
- pow(spotDot, uniforms.uSpotLightConc[j]),
348
- spotDot < uniforms.uSpotLightAngle[j]
354
+ pow(spotDot, lighting.uSpotLightConc[j]),
355
+ spotDot < lighting.uSpotLightAngle[j]
349
356
  );
350
357
  lightFalloff *= spotFalloff;
351
- let lightColor = uniforms.uSpotLightDiffuseColors[j];
352
- let specularColor = uniforms.uSpotLightSpecularColors[j];
358
+ let lightColor = lighting.uSpotLightDiffuseColors[j];
359
+ let specularColor = lighting.uSpotLightSpecularColors[j];
353
360
  let result = singleLight(viewDirection, normal, lightVector, shininess, metallic);
354
361
  totalDiffuse += result.diffuse * lightColor;
355
362
  totalSpecular += result.specular * specularColor;
@@ -357,7 +364,7 @@ fn totalLight(
357
364
  }
358
365
 
359
366
  // Image light contribution
360
- if (uniforms.uUseImageLight != 0) {
367
+ if (lighting.uUseImageLight != 0) {
361
368
  totalDiffuse += calculateImageDiffuse(normal, modelPosition, metallic);
362
369
  totalSpecular += calculateImageSpecular(normal, modelPosition, shininess, metallic);
363
370
  }
@@ -374,19 +381,19 @@ fn main(input: FragmentInput) -> @location(0) vec4<f32> {
374
381
 
375
382
  let color = select(
376
383
  input.vColor,
377
- textureSample(uSampler, uSampler_sampler, input.vTexCoord) * (uniforms.uTint/255.0),
378
- uniforms.isTexture == 1
384
+ textureSample(uSampler, uSampler_sampler, input.vTexCoord) * (material.uTint/255.0),
385
+ material.isTexture == 1
379
386
  ); // TODO: check isTexture and apply tint
380
387
  var inputs = Inputs(
381
388
  normalize(input.vNormal),
382
389
  input.vTexCoord,
383
- uniforms.uAmbientColor,
384
- select(color.rgb, uniforms.uAmbientMatColor.rgb, uniforms.uHasSetAmbient == 1),
385
- uniforms.uSpecularMatColor.rgb,
386
- uniforms.uEmissiveMatColor.rgb,
390
+ material.uAmbientColor,
391
+ select(color.rgb, material.uAmbientMatColor.rgb, material.uHasSetAmbient == 1),
392
+ material.uSpecularMatColor.rgb,
393
+ material.uEmissiveMatColor.rgb,
387
394
  color,
388
- uniforms.uShininess,
389
- uniforms.uMetallic
395
+ material.uShininess,
396
+ material.uMetallic
390
397
  );
391
398
  inputs = HOOK_getPixelInputs(inputs);
392
399
 
@@ -198,7 +198,10 @@ const wgslBackend = {
198
198
  if (!strandsContext.renderer || !strandsContext.baseShader) return;
199
199
 
200
200
  // Get the next available binding index from the renderer
201
- let bindingIndex = strandsContext.renderer.getNextBindingIndex(strandsContext.baseShader);
201
+ let bindingIndex = strandsContext.renderer.getNextBindingIndex({
202
+ vert: strandsContext.baseShader.vertSrc(),
203
+ frag: strandsContext.baseShader.fragSrc(),
204
+ });
202
205
 
203
206
  for (const {name, typeInfo} of strandsContext.uniforms) {
204
207
  if (typeInfo.baseType === 'sampler2D') {
@@ -367,7 +370,7 @@ const wgslBackend = {
367
370
  // Check if this is a uniform variable (but not a texture)
368
371
  const uniform = generationContext.strandsContext?.uniforms?.find(uniform => uniform.name === node.identifier);
369
372
  if (uniform && uniform.typeInfo.baseType !== 'sampler2D') {
370
- return `uniforms.${node.identifier}`;
373
+ return `hooks.${node.identifier}`;
371
374
  }
372
375
 
373
376
  return node.identifier;