matrix-engine-wgpu 1.2.12 → 1.2.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matrix-engine-wgpu",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "+HOTFIX raycast, webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -290,7 +290,7 @@ export default class MEMeshObj {
290
290
  });
291
291
 
292
292
  const depthTexture = this.device.createTexture({
293
- size: [canvas.width, canvas.height],
293
+ size: [canvas.width, canvas.height, 1],
294
294
  format: 'depth24plus-stencil8',
295
295
  usage: GPUTextureUsage.RENDER_ATTACHMENT,
296
296
  });
@@ -301,7 +301,7 @@ export default class MEMeshObj {
301
301
  // view is acquired and set in render loop.
302
302
  view: undefined,
303
303
  clearValue: {r: 0.5, g: 0.5, b: 0.5, a: 1.0},
304
- loadOp: 'load',
304
+ loadOp: 'clear',
305
305
  storeOp: 'store',
306
306
  },
307
307
  ],
@@ -326,7 +326,8 @@ export default class MEMeshObj {
326
326
  // one for the camera and one for the light.
327
327
  // Then a vec3 for the light position.
328
328
  // Rounded to the nearest multiple of 16.
329
- size: 2 * 4 * 16 + 4 * 4,
329
+ // size: 2 * 4 * 16 + 4 * 4,
330
+ size: 160,
330
331
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
331
332
  });
332
333
 
@@ -3,7 +3,8 @@ export let fragmentWGSL = `override shadowDepthTextureSize: f32 = 1024.0;
3
3
  struct Scene {
4
4
  lightViewProjMatrix : mat4x4f,
5
5
  cameraViewProjMatrix : mat4x4f,
6
- lightPos : vec3f,
6
+ lightPos : vec4f,
7
+ // padding: f32, // 👈 fix alignment
7
8
  }
8
9
 
9
10
  @group(0) @binding(0) var<uniform> scene : Scene;
@@ -39,7 +40,7 @@ fn main(input : FragmentInput) -> @location(0) vec4f {
39
40
  }
40
41
  }
41
42
  visibility /= 9.0;
42
- let lambertFactor = max(dot(normalize(scene.lightPos - input.fragPos), normalize(input.fragNorm)), 0.0);
43
+ let lambertFactor = max(dot(normalize(scene.lightPos.xyz - input.fragPos), normalize(input.fragNorm)), 0.0);
43
44
  let lightingFactor = min(ambientFactor + visibility * lambertFactor, 1.0);
44
45
  let textureColor = textureSample(meshTexture, meshSampler, input.uv);
45
46
 
@@ -1,7 +1,8 @@
1
1
  export let vertexWGSL = `struct Scene {
2
2
  lightViewProjMatrix: mat4x4f,
3
3
  cameraViewProjMatrix: mat4x4f,
4
- lightPos: vec3f,
4
+ lightPos: vec4f,
5
+ // padding: f32, // 👈 fix alignment
5
6
  }
6
7
 
7
8
  struct Model {
@@ -1,7 +1,8 @@
1
1
  export let vertexShadowWGSL = `struct Scene {
2
2
  lightViewProjMatrix: mat4x4f,
3
3
  cameraViewProjMatrix: mat4x4f,
4
- lightPos: vec3f,
4
+ lightPos: vec4f,
5
+ // padding: f32, // 👈 fix alignment
5
6
  }
6
7
 
7
8
  struct Model {