@woosh/meep-engine 3.77.0 → 3.78.0

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 (40) hide show
  1. package/package.json +3 -2
  2. package/src/engine/EngineHarness.d.ts +4 -6
  3. package/src/engine/EngineHarness.d.ts.map +1 -1
  4. package/src/engine/EngineHarness.js +11 -19
  5. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +0 -1
  6. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  7. package/src/engine/sound/sopra/runtime/EventInstance.js +0 -1
  8. package/src/shade/renderer/extension/ShadowAtlas.d.ts +4 -2
  9. package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -1
  10. package/src/shade/renderer/extension/ShadowAtlas.js +4 -2
  11. package/src/shade/renderer/hair/hair_shadow_draw.d.ts +2 -2
  12. package/src/shade/renderer/hair/hair_shadow_draw.js +2 -2
  13. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts +7 -4
  14. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts.map +1 -1
  15. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js +66 -14
  16. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +20 -0
  17. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts.map +1 -0
  18. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +149 -0
  19. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts +8 -0
  20. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  21. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +100 -33
  22. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts +11 -0
  23. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts.map +1 -1
  24. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.js +24 -11
  25. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts +13 -0
  26. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts.map +1 -0
  27. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.js +42 -0
  28. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
  29. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +14 -5
  30. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +34 -0
  31. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -0
  32. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +106 -0
  33. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts +16 -0
  34. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts.map +1 -0
  35. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.js +50 -0
  36. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +25 -0
  37. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -0
  38. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +42 -0
  39. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.d.ts +1 -1
  40. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.js +5 -5
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Advanced 3D game engine",
7
7
  "type": "module",
8
8
  "author": "Alexander Goldring",
9
- "version": "3.77.0",
9
+ "version": "3.78.0",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -20,7 +20,8 @@
20
20
  "**/*.scss"
21
21
  ],
22
22
  "scripts": {
23
- "test:ci": "node scripts/check-types.mjs && vitest run --coverage --reporter=default --reporter=junit --outputFile=junit.xml",
23
+ "test:ci": "node scripts/check-types.mjs && vitest run --reporter=default --reporter=junit --outputFile=junit.xml",
24
+ "test:coverage": "vitest run --coverage --testTimeout=0",
24
25
  "build-module": "rollup -c rollup.config.js",
25
26
  "publish-npm": "npm publish",
26
27
  "generate-types": "tsc --project tsconfig.types.json",
@@ -105,26 +105,24 @@ export class EngineHarness {
105
105
  showFps?: boolean;
106
106
  }): Promise<void>;
107
107
  /**
108
+ * A sun. There is no ambient light: Shade lights indirect from the environment, see {@link LightSystem}.
109
+ *
108
110
  * @param {Object} param
109
111
  * @param {Engine} param.engine
110
112
  * @param {EntityComponentDataset} [param.ecd]
111
113
  * @param {boolean} [param.castShadow]
112
114
  * @param {Color} [param.sun]
113
- * @param {number} [param.sunIntensity]
115
+ * @param {number} [param.sunIntensity] lux, see {@link DEFAULT_SUNLIGHT_INTENSITY}
114
116
  * @param {Vector3} [param.sunDirection]
115
- * @param {Color} [param.ambient]
116
- * @param {number} [param.ambientIntensity]
117
117
  * @param {number} [param.sunShadowDistance] Maximum draw distance for sun's shadow. Allows better use of shadowmap resolution.
118
118
  */
119
- static buildLights({ engine, ecd, castShadow, sun, sunIntensity, sunDirection, sunShadowDistance, ambient, ambientIntensity }: {
119
+ static buildLights({ engine, ecd, castShadow, sun, sunIntensity, sunDirection, sunShadowDistance, }: {
120
120
  engine: Engine;
121
121
  ecd?: EntityComponentDataset;
122
122
  castShadow?: boolean;
123
123
  sun?: Color;
124
124
  sunIntensity?: number;
125
125
  sunDirection?: Vector3;
126
- ambient?: Color;
127
- ambientIntensity?: number;
128
126
  sunShadowDistance?: number;
129
127
  }): Promise<void>;
130
128
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"EngineHarness.d.ts","sourceRoot":"","sources":["../../../src/engine/EngineHarness.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,MAAM;sBA2ChB;IAED;;;;;;OAMG;IACH;QAL0B,YAAY,GAA3B,MAAM;QACQ,MAAM,EAApB,MAAM;QACyB,GAAG,GAAlC,sBAAsB;QACpB,QAAQ,MAAM,CAAC,CAgD3B;IAGD;;;;;;;;;;OAUG;IACH;QAR2B,MAAM,EAAtB,MAAM;QACY,IAAI,GAAtB,OAAO;QACU,QAAQ;QACR,UAAU,GAA3B,MAAM;QACW,UAAU,GAA3B,MAAM;QACY,WAAW,GAA7B,OAAO;QACL,OAAO,CAwEnB;IAjfD;;;OAGG;IACH,YAFU,eAAQ,IAAI,CAEb;IAGL;;;OAGG;IACH,QAFU,MAAM,CAEiC;IA2DrD;;;;;OAKG;IACH;QAJkE,aAAa,GAApE,CAAC,MAAM,EAAC,mBAAmB,EAAC,MAAM,EAAC,MAAM,QAAI;QAC5B,mBAAmB,GAApC,OAAO;QACL,QAAQ,MAAM,CAAC,CA0D3B;CA8WJ;;IAID;;;OAGG;IACH,uCAMC;;qCAhjBY,OAAO,iCAAiC,EAAE,sBAAsB;mBA7B1D,aAAa;oCACI,0BAA0B;sBAQxC,kCAAkC;8BAnB1B,mCAAmC;oBAD7C,yBAAyB;mBAK1B,iBAAiB;sBATd,wBAAwB;oBAG1B,yBAAyB;oBASzB,8BAA8B"}
@@ -83,6 +83,13 @@ function setLocale(engine) {
83
83
  */
84
84
  const DEFAULT_SUNLIGHT_COLOR = Object.freeze(new Color(1, 0.93, 0.87));
85
85
 
86
+ /**
87
+ * The default sun's illuminance, lux: π, under which a white Lambertian surface facing the sun reflects a radiance of
88
+ * 1 (ρ·E/π), and an 18% grey one 0.18 — the luminance an exposure of one shows at middle grey. A sunlit scene of the
89
+ * defaults therefore meters at about an exposure of one, and automatic exposure has little to adapt away.
90
+ */
91
+ const DEFAULT_SUNLIGHT_INTENSITY = Math.PI;
92
+
86
93
  export class EngineHarness {
87
94
  /**
88
95
  * @readonly
@@ -390,15 +397,15 @@ export class EngineHarness {
390
397
 
391
398
 
392
399
  /**
400
+ * A sun. There is no ambient light: Shade lights indirect from the environment, see {@link LightSystem}.
401
+ *
393
402
  * @param {Object} param
394
403
  * @param {Engine} param.engine
395
404
  * @param {EntityComponentDataset} [param.ecd]
396
405
  * @param {boolean} [param.castShadow]
397
406
  * @param {Color} [param.sun]
398
- * @param {number} [param.sunIntensity]
407
+ * @param {number} [param.sunIntensity] lux, see {@link DEFAULT_SUNLIGHT_INTENSITY}
399
408
  * @param {Vector3} [param.sunDirection]
400
- * @param {Color} [param.ambient]
401
- * @param {number} [param.ambientIntensity]
402
409
  * @param {number} [param.sunShadowDistance] Maximum draw distance for sun's shadow. Allows better use of shadowmap resolution.
403
410
  */
404
411
  static async buildLights({
@@ -406,11 +413,9 @@ export class EngineHarness {
406
413
  ecd = engine.entityManager.dataset,
407
414
  castShadow = true,
408
415
  sun = DEFAULT_SUNLIGHT_COLOR,
409
- sunIntensity = 0.9,
416
+ sunIntensity = DEFAULT_SUNLIGHT_INTENSITY,
410
417
  sunDirection = new Vector3(0.17, -1, 0.17),
411
418
  sunShadowDistance = 1000,
412
- ambient = Color.white,
413
- ambientIntensity = 0.07
414
419
  }) {
415
420
  const em = engine.entityManager;
416
421
 
@@ -444,19 +449,6 @@ export class EngineHarness {
444
449
  .add(transform)
445
450
  .add(Tag.fromJSON(["Light", "Key"]))
446
451
  .build(ecd);
447
-
448
-
449
- const fill = new Light();
450
- fill.type.set(Light.Type.AMBIENT);
451
- fill.color.copy(ambient);
452
- fill.intensity.set(ambientIntensity);
453
-
454
-
455
- new Entity()
456
- .add(fill)
457
- .add(new Transform64())
458
- .add(Tag.fromJSON(["Light", "Ambient"]))
459
- .build(ecd);
460
452
  }
461
453
 
462
454
  /**
@@ -253,7 +253,6 @@ export class EventInstance {
253
253
  }
254
254
  export type Quaternion = import("../../../../core/geom/Quaternion.js").Quaternion;
255
255
  export type Vector3 = import("../../../../core/geom/Vector3.js").Vector3;
256
- export type AcousticSolution = import("../../simulation/core/AcousticSolution.js").AcousticSolution;
257
256
  export type AcousticDirectivity = import("../../simulation/definition/AcousticDirectivity.js").AcousticDirectivity;
258
257
  export type SopraEngine = import("../SopraEngine.js").SopraEngine;
259
258
  export type EventDescription = import("../definition/EventDescription.js").EventDescription;
@@ -1 +1 @@
1
- {"version":3,"file":"EventInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra/runtime/EventInstance.js"],"names":[],"mappings":";;;iCAkCU,MAAM;;;;;;AAsChB;;;;;;;;;GASG;AACH;IAqSI;;;;OAIG;IACH,oBAJW,WAAW,eACX,gBAAgB,4HAChB;QAAC,KAAK,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAC,OAAO,CAAC;QAAC,OAAO,CAAC,EAAC,OAAO,CAAC;QAAC,WAAW,CAAC,EAAC,MAAM,CAAC;QAAC,eAAe,CAAC,EAAC,oBAAoB,CAAC;QAAC,SAAS,CAAC,EAAC,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAC,OAAO,CAAC;QAAC,YAAY,CAAC,EAAC,MAAM,CAAC;QAAC,WAAW,CAAC,EAAC,UAAU,CAAC;QAAC,WAAW,CAAC,EAAC,mBAAmB,CAAA;KAAC,EAkFjP;IAxXD;;OAEG;IACH,WAFU,MAAM,CAEF;IAEd;;OAEG;IACH,OAFU,kBAAkB,GAAC,MAAM,CAEA;IAEnC;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;;OAKG;IACH,cAFU,MAAM,CAE8B;IAE9C;;;OAGG;IACH,aAAuB;IAwRnB;;OAEG;IACH,QAFU,WAAW,CAED;IAEpB;;OAEG;IACH,aAFU,gBAAgB,CAEI;IAE9B;;OAEG;IACH,OAFU,MAAM,CAEE;IAElB;;;;;;;;;OASG;IACH,UAFU,UAAU,MAAM,CAAC,GAAC,IAAI,CAER;IAExB;;;;;OAKG;IACH,aAFU,UAAU,GAAC,IAAI,CAEK;IAE9B;;;;;OAKG;IACH,aAFU,mBAAmB,GAAC,IAAI,CAEJ;IAE9B;;OAEG;IACH,SAFU,OAAO,CAEK;IAEtB;;OAEG;IACH,oBAFU,MAAM,CAEqB;IAErC;;OAEG;IACH,iBAFU,oBAAoB,CAEQ;IAc1C;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,2CAeC;IAED;;;OAGG;IACH,WAFW,MAAM,QAyChB;IAwKD;;;;;;;;;;;;OAYG;IACH,4BAJW,MAAM,QACN,MAAM,SACN,MAAM,QAIhB;IAED;;;;;;;;;OASG;IACH,iCALW,MAAM,QACN,MAAM,SACN,MAAM,gBACN,MAAM,QAIhB;IAED;;;;;OAKG;IACH,4BAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;IAaD;;;OAGG;IACH,qBAEC;IAED;;;;OAIG;IACH,wBAEC;IAED;;;OAGG;IACH,cAFW,MAAM,QAQhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,sBAFW,gBAAgB,QA4H1B;IAqED;;;;;OAKG;IACH,uBAJW,MAAM,YACN,MAAM,eACN,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,yBAHW,MAAM,eACN,MAAM,QAqBhB;IAED;;;;OAIG;IACH,cAFW,MAAM,QAehB;IAED;;OAEG;IACH,gBAEC;IAED;;;;;;;;OAQG;IACH,YAFW,MAAM,QA+DhB;IAED;;;;;;;OAOG;IACH,cAEC;IAwJD;;OAEG;IACH,aAgDC;;CACJ;yBAp0CY,OAAO,qCAAqC,EAAE,UAAU;sBACxD,OAAO,kCAAkC,EAAE,OAAO;+BAClD,OAAO,2CAA2C,EAAE,gBAAgB;kCACpE,OAAO,oDAAoD,EAAE,mBAAmB;0BAChF,OAAO,mBAAmB,EAAE,WAAW;+BACvC,OAAO,mCAAmC,EAAE,gBAAgB;mCAC5D,OAAO,2BAA2B,EAAE,oBAAoB;oBACxD,OAAO,YAAY,EAAE,KAAK;iCAdN,2CAA2C"}
1
+ {"version":3,"file":"EventInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/sound/sopra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AYG;IACH,4BAJW,MAAM,QACN,MAAM,SACN,MAAM,QAIhB;IAED;;;;;;;;;OASG;IACH,iCALW,MAAM,QACN,MAAM,SACN,MAAM,gBACN,MAAM,QAIhB;IAED;;;;;OAKG;IACH,4BAJW,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB;IAaD;;;OAGG;IACH,qBAEC;IAED;;;;OAIG;IACH,wBAEC;IAED;;;OAGG;IACH,cAFW,MAAM,QAQhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,sBAFW,gBAAgB,QA4H1B;IAqED;;;;;OAKG;IACH,uBAJW,MAAM,YACN,MAAM,eACN,MAAM,QAqBhB;IAED;;;;;OAKG;IACH,yBAHW,MAAM,eACN,MAAM,QAqBhB;IAED;;;;OAIG;IACH,cAFW,MAAM,QAehB;IAED;;OAEG;IACH,gBAEC;IAED;;;;;;;;OAQG;IACH,YAFW,MAAM,QA+DhB;IAED;;;;;;;OAOG;IACH,cAEC;IAwJD;;OAEG;IACH,aAgDC;;CACJ;yBAn0CY,OAAO,qCAAqC,EAAE,UAAU;sBACxD,OAAO,kCAAkC,EAAE,OAAO;kCAClD,OAAO,oDAAoD,EAAE,mBAAmB;0BAChF,OAAO,mBAAmB,EAAE,WAAW;+BACvC,OAAO,mCAAmC,EAAE,gBAAgB;mCAC5D,OAAO,2BAA2B,EAAE,oBAAoB;oBACxD,OAAO,YAAY,EAAE,KAAK;iCAbN,2CAA2C"}
@@ -22,7 +22,6 @@ import { v3_length } from "../../../../core/geom/vec3/v3_length.js";
22
22
  /**
23
23
  * @typedef {import("../../../../core/geom/Quaternion.js").Quaternion} Quaternion
24
24
  * @typedef {import("../../../../core/geom/Vector3.js").Vector3} Vector3
25
- * @typedef {import("../../simulation/core/AcousticSolution.js").AcousticSolution} AcousticSolution
26
25
  * @typedef {import("../../simulation/definition/AcousticDirectivity.js").AcousticDirectivity} AcousticDirectivity
27
26
  * @typedef {import("../SopraEngine.js").SopraEngine} SopraEngine
28
27
  * @typedef {import("../definition/EventDescription.js").EventDescription} EventDescription
@@ -2,8 +2,10 @@
2
2
  * The shadow atlas as the frame's shadow maps left it, and the views drawn into it this frame, for an extension whose
3
3
  * surfaces cast shadows the scene's rasterizer does not draw.
4
4
  *
5
- * Such an extension draws its casters' depth into each view's rectangle, through the view's camera, as the scene's
6
- * casters were drawn (`DEPTH_STENCIL_STATE_SHADOW`: reversed depth, `greater`), and publishes the atlas it wrote.
5
+ * Such an extension draws its casters' depth into each view's rectangle, through the view's camera, in reversed depth
6
+ * with `greater` (`DEPTH_STENCIL_STATE_SHADOW`, whose rasterizer bias the scene's spot-light casters also take), and
7
+ * publishes the atlas it wrote. A directional light's cascade casters of the scene are pushed in the vertex stage
8
+ * instead (`shadow_cascade_rasterization_pass_descriptor`); an extension's keep the rasterizer's bias there.
7
9
  * Everything that samples the shadow maps after this phase — shading, the volumetrics, the extensions that light —
8
10
  * then sees those casters.
9
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ShadowAtlas.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/extension/ShadowAtlas.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;GAeG;AACH;IAiBI,0CAEC;IAWD,0BAEC;IAXD;;;;OAIG;IACH,oBAEC;IAMD;;;;;OAKG;IACH,sBAEC;IAED;;;;OAIG;IACH,+BAIC;IAED;;OAEG;IACH,yBAIC;IAED;;;;OAIG;IACH,oBAFW,qBAAqB,GAAC,IAAI,QAKpC;;CAmBJ;;;;;;YA/Ha,OAAO,qBAAqB,EAAE,MAAM;;;;;;;;cAGpC,MAAM,EAAE;;;;;;;uBAQI,eAAe,EAAE;sBAC7B,MAAM;;4BAhBQ,kBAAkB"}
1
+ {"version":3,"file":"ShadowAtlas.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/extension/ShadowAtlas.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;GAiBG;AACH;IAiBI,0CAEC;IAWD,0BAEC;IAXD;;;;OAIG;IACH,oBAEC;IAMD;;;;;OAKG;IACH,sBAEC;IAED;;;;OAIG;IACH,+BAIC;IAED;;OAEG;IACH,yBAIC;IAED;;;;OAIG;IACH,oBAFW,qBAAqB,GAAC,IAAI,QAKpC;;CAmBJ;;;;;;YAjIa,OAAO,qBAAqB,EAAE,MAAM;;;;;;;;cAGpC,MAAM,EAAE;;;;;;;uBAQI,eAAe,EAAE;sBAC7B,MAAM;;4BAhBQ,kBAAkB"}
@@ -27,8 +27,10 @@ const NO_VIEWS = Object.freeze([]);
27
27
  * The shadow atlas as the frame's shadow maps left it, and the views drawn into it this frame, for an extension whose
28
28
  * surfaces cast shadows the scene's rasterizer does not draw.
29
29
  *
30
- * Such an extension draws its casters' depth into each view's rectangle, through the view's camera, as the scene's
31
- * casters were drawn (`DEPTH_STENCIL_STATE_SHADOW`: reversed depth, `greater`), and publishes the atlas it wrote.
30
+ * Such an extension draws its casters' depth into each view's rectangle, through the view's camera, in reversed depth
31
+ * with `greater` (`DEPTH_STENCIL_STATE_SHADOW`, whose rasterizer bias the scene's spot-light casters also take), and
32
+ * publishes the atlas it wrote. A directional light's cascade casters of the scene are pushed in the vertex stage
33
+ * instead (`shadow_cascade_rasterization_pass_descriptor`); an extension's keep the rasterizer's bias there.
32
34
  * Everything that samples the shadow maps after this phase — shading, the volumetrics, the extensions that light —
33
35
  * then sees those casters.
34
36
  *
@@ -11,8 +11,8 @@ export const HAIR_SHADOW_TARGET_STRUCT: WebGPUStruct;
11
11
  */
12
12
  export const HAIR_SHADOW_RESOURCES: ShaderResourceSetDescriptor;
13
13
  /**
14
- * Draws the frame's strands into a shadow view's depth, as the scene's casters are drawn
15
- * (`DEPTH_STENCIL_STATE_SHADOW`).
14
+ * Draws the frame's strands into a shadow view's depth with the rasterizer's bias (`DEPTH_STENCIL_STATE_SHADOW`), in
15
+ * cascades as well: a strand has no surface normal for the cascade casters' vertex-stage push to read.
16
16
  *
17
17
  * An instance is an entry of the view's list (`shader_hair_shadow_list`), a strand, drawn as `hair_id_draw.js` draws
18
18
  * it for the eye: a triangle strip a pair of vertices at each of its points, `2 (2^class + 1)` vertices, one draw a
@@ -100,8 +100,8 @@ const descriptor = ShaderDescriptor.from({ label: "Hair Shadow", body, resources
100
100
  export const HAIR_SHADOW_RESOURCES = resources;
101
101
 
102
102
  /**
103
- * Draws the frame's strands into a shadow view's depth, as the scene's casters are drawn
104
- * (`DEPTH_STENCIL_STATE_SHADOW`).
103
+ * Draws the frame's strands into a shadow view's depth with the rasterizer's bias (`DEPTH_STENCIL_STATE_SHADOW`), in
104
+ * cascades as well: a strand has no surface normal for the cascade casters' vertex-stage push to read.
105
105
  *
106
106
  * An instance is an entry of the view's list (`shader_hair_shadow_list`), a strand, drawn as `hair_id_draw.js` draws
107
107
  * it for the eye: a triangle strip a pair of vertices at each of its points, `2 (2^class + 1)` vertices, one draw a
@@ -1,25 +1,28 @@
1
1
  /**
2
- * The vertex of an indexed meshlet draw.
2
+ * What a draw index of the indexed form names, and the vertex it draws.
3
3
  *
4
4
  * ```wgsl
5
+ * fn meshlet_draw_source_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawSource
5
6
  * fn meshlet_draw_vertex_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex
6
7
  * ```
7
8
  *
8
9
  * `vertex_index` is an index `shader_meshlet_draw_indices` wrote, and `instance_index` the slot of the
9
- * draw's first meshlet.
10
+ * draw's first meshlet. Every source of this form `has_area`.
10
11
  *
11
12
  * @type {CodeChunk}
12
13
  */
13
14
  export const chunk_meshlet_draw_vertex_indexed: CodeChunk;
14
15
  /**
15
- * The vertex of a meshlet draw in the corner form.
16
+ * What a draw index of the corner form names, and the vertex it draws.
16
17
  *
17
18
  * ```wgsl
19
+ * fn meshlet_draw_source_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawSource
18
20
  * fn meshlet_draw_vertex_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex
19
21
  * ```
20
22
  *
21
23
  * `vertex_index` is a corner and `instance_index` the meshlet's slot. A corner past the meshlet's triangles
22
- * is the zero position, so its triangle has no area.
24
+ * has no area — its source holds nothing else — and its vertex is the zero position, so its triangle has no
25
+ * area.
23
26
  *
24
27
  * @type {CodeChunk}
25
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_meshlet_draw_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js"],"names":[],"mappings":"AA0CA;;;;;;;;;;;GAWG;AACH,gDAFU,SAAS,CA4BjB;AAEF;;;;;;;;;;;GAWG;AACH,+CAFU,SAAS,CAoCjB;0BAtHwB,oCAAoC"}
1
+ {"version":3,"file":"chunk_meshlet_draw_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;GAYG;AACH,gDAFU,SAAS,CAwCjB;AAEF;;;;;;;;;;;;;GAaG;AACH,+CAFU,SAAS,CAuDjB;0BA1KwB,oCAAoC"}
@@ -9,6 +9,7 @@ import {
9
9
  chunk_triangle_list_reverse_winding
10
10
  } from "../../shader/chunk/geometry/triangle/chunk_triangle_list_reverse_winding.js";
11
11
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
12
+ import { MESHLET_METADATA_STRUCT } from "../../geometry/meshlet/encoding/MESHLET_METADATA_STRUCT.js";
12
13
  import { chunk_triangle_winding_is_reversed } from "../chunk_triangle_winding_is_reversed.js";
13
14
  import { VISIBILITY_TRIANGLE_BITS } from "../visibility/VISIBILITY_BUFFER.js";
14
15
  import {
@@ -27,6 +28,9 @@ import {
27
28
  triangle`, where the slot is the meshlet's place in the list the draw takes its meshlets from; it is right
28
29
  on the first vertex of a triangle, which is where a flat varying is taken from.
29
30
 
31
+ Each form's vertex is its source — the meshlet, the node and the vertex within the meshlet a draw index names
32
+ — put through the view: a pass that needs more of the vertex than its position reads the source instead.
33
+
30
34
  The shader binds `camera`, `scene_database`, `meshlets`, `meshlet_metadata`, `meshlet_data` and, for the
31
35
  corner form, `materials`, as `rasterization_shader_resources` declares them.
32
36
  */
@@ -40,67 +44,98 @@ struct MeshletDrawVertex {
40
44
  }
41
45
  `);
42
46
 
47
+ const chunk_meshlet_draw_source_struct = CodeChunk.from(
48
+ //language=WGSL
49
+ `
50
+ struct MeshletDrawSource {
51
+ header: ${MESHLET_METADATA_STRUCT.wgsl_ref},
52
+ node_global: mat4x4<f32>,
53
+ vertex_id: u32,
54
+ visibility: u32,
55
+ has_area: bool,
56
+ }
57
+ `, [
58
+ MESHLET_METADATA_STRUCT.declaration_chunk,
59
+ ]);
60
+
43
61
  /**
44
- * The vertex of an indexed meshlet draw.
62
+ * What a draw index of the indexed form names, and the vertex it draws.
45
63
  *
46
64
  * ```wgsl
65
+ * fn meshlet_draw_source_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawSource
47
66
  * fn meshlet_draw_vertex_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex
48
67
  * ```
49
68
  *
50
69
  * `vertex_index` is an index `shader_meshlet_draw_indices` wrote, and `instance_index` the slot of the
51
- * draw's first meshlet.
70
+ * draw's first meshlet. Every source of this form `has_area`.
52
71
  *
53
72
  * @type {CodeChunk}
54
73
  */
55
74
  export const chunk_meshlet_draw_vertex_indexed = CodeChunk.from(
56
75
  //language=WGSL
57
76
  `
58
- fn meshlet_draw_vertex_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex {
77
+ fn meshlet_draw_source_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawSource {
59
78
  let slot = instance_index + (vertex_index >> ${MESHLET_DRAW_INDEX_PLACE_SHIFT}u);
60
79
 
61
80
  let meshlet_def = meshlets.elements[slot];
62
- let meshlet_header = meshlet_metadata[meshlet_def.index];
63
81
 
64
82
  let mesh = scene_read_mesh(&scene_database, meshlet_def.mesh);
65
83
  let node = scene_read_node(&scene_database, mesh.node);
66
84
 
67
85
  let triangle_index = (vertex_index >> ${MESHLET_DRAW_INDEX_VERTEX_BITS}u) & ${2 ** MESHLET_DRAW_INDEX_TRIANGLE_BITS - 1}u;
68
86
 
69
- let geometry_position = read_meshlet_vertex_position(meshlet_header, vertex_index & ${2 ** MESHLET_DRAW_INDEX_VERTEX_BITS - 1}u);
87
+ return MeshletDrawSource(
88
+ meshlet_metadata[meshlet_def.index],
89
+ node.global,
90
+ vertex_index & ${2 ** MESHLET_DRAW_INDEX_VERTEX_BITS - 1}u,
91
+ (slot << ${VISIBILITY_TRIANGLE_BITS}u) | triangle_index,
92
+ true,
93
+ );
94
+ }
95
+
96
+ fn meshlet_draw_vertex_indexed(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex {
97
+ let source = meshlet_draw_source_indexed(vertex_index, instance_index);
98
+
99
+ let geometry_position = read_meshlet_vertex_position(source.header, source.vertex_id);
70
100
 
71
101
  return MeshletDrawVertex(
72
- camera.view_projection_matrix * node.global * vec4(geometry_position, 1.0),
73
- (slot << ${VISIBILITY_TRIANGLE_BITS}u) | triangle_index,
102
+ camera.view_projection_matrix * source.node_global * vec4(geometry_position, 1.0),
103
+ source.visibility,
74
104
  );
75
105
  }
76
106
  `, [
77
107
  chunk_meshlet_draw_vertex_struct,
108
+ chunk_meshlet_draw_source_struct,
78
109
  chunk_read_meshlet_vertex_position,
79
110
  chunk_scene_database_access,
80
111
  ]
81
112
  );
82
113
 
83
114
  /**
84
- * The vertex of a meshlet draw in the corner form.
115
+ * What a draw index of the corner form names, and the vertex it draws.
85
116
  *
86
117
  * ```wgsl
118
+ * fn meshlet_draw_source_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawSource
87
119
  * fn meshlet_draw_vertex_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex
88
120
  * ```
89
121
  *
90
122
  * `vertex_index` is a corner and `instance_index` the meshlet's slot. A corner past the meshlet's triangles
91
- * is the zero position, so its triangle has no area.
123
+ * has no area — its source holds nothing else — and its vertex is the zero position, so its triangle has no
124
+ * area.
92
125
  *
93
126
  * @type {CodeChunk}
94
127
  */
95
128
  export const chunk_meshlet_draw_vertex_corner = CodeChunk.from(
96
129
  //language=WGSL
97
130
  `
98
- fn meshlet_draw_vertex_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex {
131
+ fn meshlet_draw_source_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawSource {
132
+ var source: MeshletDrawSource;
133
+
99
134
  let meshlet_def = meshlets.elements[instance_index];
100
135
  let meshlet_header = meshlet_metadata[meshlet_def.index];
101
136
 
102
137
  if (vertex_index >= meshlet_header.primitive_count * 3u) {
103
- return MeshletDrawVertex(vec4<f32>(0.0), 0u);
138
+ return source;
104
139
  }
105
140
 
106
141
  let mesh = scene_read_mesh(&scene_database, meshlet_def.mesh);
@@ -111,15 +146,32 @@ fn meshlet_draw_vertex_corner(vertex_index: u32, instance_index: u32) -> Meshlet
111
146
  triangle_winding_is_reversed(node, materials[mesh.material].draw_side)
112
147
  );
113
148
 
114
- let geometry_position = read_meshlet_vertex_position(meshlet_header, read_meshlet_resolved_index(meshlet_header, corner));
149
+ source.header = meshlet_header;
150
+ source.node_global = node.global;
151
+ source.vertex_id = read_meshlet_resolved_index(meshlet_header, corner);
152
+ source.visibility = (instance_index << ${VISIBILITY_TRIANGLE_BITS}u) | (corner / 3u);
153
+ source.has_area = true;
154
+
155
+ return source;
156
+ }
157
+
158
+ fn meshlet_draw_vertex_corner(vertex_index: u32, instance_index: u32) -> MeshletDrawVertex {
159
+ let source = meshlet_draw_source_corner(vertex_index, instance_index);
160
+
161
+ if (!source.has_area) {
162
+ return MeshletDrawVertex(vec4<f32>(0.0), 0u);
163
+ }
164
+
165
+ let geometry_position = read_meshlet_vertex_position(source.header, source.vertex_id);
115
166
 
116
167
  return MeshletDrawVertex(
117
- camera.view_projection_matrix * node.global * vec4(geometry_position, 1.0),
118
- (instance_index << ${VISIBILITY_TRIANGLE_BITS}u) | (corner / 3u),
168
+ camera.view_projection_matrix * source.node_global * vec4(geometry_position, 1.0),
169
+ source.visibility,
119
170
  );
120
171
  }
121
172
  `, [
122
173
  chunk_meshlet_draw_vertex_struct,
174
+ chunk_meshlet_draw_source_struct,
123
175
  chunk_read_meshlet_vertex_position,
124
176
  chunk_read_meshlet_resolved_index,
125
177
  chunk_scene_database_access,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The shadow pass's depth state with no bias: a cascade's casters are biased in the vertex stage alone.
3
+ *
4
+ * @type {Readonly<DepthStencilState>}
5
+ */
6
+ export const DEPTH_STENCIL_STATE_SHADOW_CASCADE: Readonly<DepthStencilState>;
7
+ /**
8
+ * The opaque casters of a directional light's cascades, into the shadow atlas: the shadow pass
9
+ * (`shadow_rasterization_pass_descriptor`) with Unreal's cascade caster bias in the vertex stage,
10
+ * {@link chunk_shadow_cascade_caster_position}, in place of the rasterizer's.
11
+ *
12
+ * Orthographic views only: the vertex stage reads the light's direction and the texel's world size off the
13
+ * view's matrix as an orthographic projection has them.
14
+ *
15
+ * @type {RenderPassDescriptor}
16
+ */
17
+ export const shadow_cascade_rasterization_pass_descriptor: RenderPassDescriptor;
18
+ import { DepthStencilState } from "../../../../descriptor/pipeline/render/DepthStencilState.js";
19
+ import { RenderPassDescriptor } from "../../../shader/pass/RenderPassDescriptor.js";
20
+ //# sourceMappingURL=shadow_cascade_rasterization_pass_descriptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadow_cascade_rasterization_pass_descriptor.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,iDAFU,SAAS,iBAAiB,CAAC,CAQjC;AAmEJ;;;;;;;;;GASG;AACH,2DAFU,oBAAoB,CAEyD;kCA3HrD,6DAA6D;qCAa1D,8CAA8C"}
@@ -0,0 +1,149 @@
1
+ import { DepthStencilState } from "../../../../descriptor/pipeline/render/DepthStencilState.js";
2
+ import { RenderPipelineDescriptor } from "../../../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
3
+ import { DEPTH_BACKGROUND_VALUE } from "../../../depth/DEPTH_BACKGROUND_VALUE.js";
4
+ import {
5
+ chunk_shadow_cascade_caster_position
6
+ } from "../../../shadow/map/shader/chunk_shadow_cascade_caster_position.js";
7
+ import {
8
+ chunk_read_meshlet_vertex_normal
9
+ } from "../../../shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.js";
10
+ import {
11
+ chunk_read_meshlet_vertex_position
12
+ } from "../../../shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_position.js";
13
+ import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
14
+ import { RenderPassDescriptor } from "../../../shader/pass/RenderPassDescriptor.js";
15
+ import { ShaderResourceSetDescriptor } from "../../../shader/resource/ShaderResourceSetDescriptor.js";
16
+ import { ShaderDescriptor } from "../../../shader/ShaderDescriptor.js";
17
+ import { VIEW_UNIFORM_STRUCT } from "../../../view/VIEW_UNIFORM_STRUCT.js";
18
+ import { DEPTH_STENCIL_STATE_SHADOW } from "../../DEPTH_STENCIL_STATE_SHADOW.js";
19
+ import {
20
+ chunk_meshlet_draw_vertex_corner,
21
+ chunk_meshlet_draw_vertex_indexed
22
+ } from "../../draw/chunk_meshlet_draw_vertex.js";
23
+ import { rasterization_primitive_state } from "../rasterization_primitive_state.js";
24
+ import { add_rasterization_bindings } from "../rasterization_shader_resources.js";
25
+
26
+ /**
27
+ * A meshlet draw's bindings, and the view: its `width` and `height` are the cascade's tile, which sizes a texel.
28
+ *
29
+ * @type {ShaderResourceSetDescriptor}
30
+ */
31
+ const resources = new ShaderResourceSetDescriptor();
32
+
33
+ add_rasterization_bindings(resources.createGroup())
34
+ .addUniform("view", VIEW_UNIFORM_STRUCT);
35
+
36
+ /**
37
+ * The shadow pass's depth state with no bias: a cascade's casters are biased in the vertex stage alone.
38
+ *
39
+ * @type {Readonly<DepthStencilState>}
40
+ */
41
+ export const DEPTH_STENCIL_STATE_SHADOW_CASCADE = Object.freeze(DepthStencilState.from({
42
+ depthWriteEnabled: DEPTH_STENCIL_STATE_SHADOW.depthWriteEnabled,
43
+ depthCompare: DEPTH_STENCIL_STATE_SHADOW.depthCompare,
44
+ format: DEPTH_STENCIL_STATE_SHADOW.format,
45
+ depthBias: 0,
46
+ depthBiasSlopeScale: 0,
47
+ }));
48
+
49
+ const chunk_cascade_caster_vertex = CodeChunk.from(
50
+ //language=WGSL
51
+ `
52
+ fn shadow_cascade_caster_vertex(source: MeshletDrawSource) -> vec4f {
53
+ return shadow_cascade_caster_position(
54
+ source.node_global,
55
+ read_meshlet_vertex_position(source.header, source.vertex_id),
56
+ read_meshlet_vertex_normal(source.header, source.vertex_id)
57
+ );
58
+ }
59
+ `, [
60
+ chunk_shadow_cascade_caster_position,
61
+ chunk_read_meshlet_vertex_normal,
62
+ chunk_read_meshlet_vertex_position,
63
+ ]
64
+ );
65
+
66
+ const vertex_shader = ShaderDescriptor.from({
67
+ resources,
68
+ body: CodeChunk.from(
69
+ //language=WGSL
70
+ `
71
+ @vertex
72
+ fn main(
73
+ @builtin(vertex_index) vertex_index : u32,
74
+ @builtin(instance_index) instance_index : u32,
75
+ ) -> @builtin(position) vec4f {
76
+
77
+ return shadow_cascade_caster_vertex(meshlet_draw_source_indexed(vertex_index, instance_index));
78
+
79
+ }
80
+ `, [
81
+ chunk_meshlet_draw_vertex_indexed,
82
+ chunk_cascade_caster_vertex,
83
+ ]
84
+ )
85
+ });
86
+
87
+ const vertex_shader_corner = ShaderDescriptor.from({
88
+ resources,
89
+ body: CodeChunk.from(
90
+ //language=WGSL
91
+ `
92
+ @vertex
93
+ fn main(
94
+ @builtin(vertex_index) vertex_index : u32,
95
+ @builtin(instance_index) instance_index : u32,
96
+ ) -> @builtin(position) vec4f {
97
+
98
+ let source = meshlet_draw_source_corner(vertex_index, instance_index);
99
+
100
+ if (!source.has_area) {
101
+ return vec4f(0.0);
102
+ }
103
+
104
+ return shadow_cascade_caster_vertex(source);
105
+
106
+ }
107
+ `, [
108
+ chunk_meshlet_draw_vertex_corner,
109
+ chunk_cascade_caster_vertex,
110
+ ]
111
+ )
112
+ });
113
+
114
+ /**
115
+ * The opaque casters of a directional light's cascades, into the shadow atlas: the shadow pass
116
+ * (`shadow_rasterization_pass_descriptor`) with Unreal's cascade caster bias in the vertex stage,
117
+ * {@link chunk_shadow_cascade_caster_position}, in place of the rasterizer's.
118
+ *
119
+ * Orthographic views only: the vertex stage reads the light's direction and the texel's world size off the
120
+ * view's matrix as an orthographic projection has them.
121
+ *
122
+ * @type {RenderPassDescriptor}
123
+ */
124
+ export const shadow_cascade_rasterization_pass_descriptor = new RenderPassDescriptor();
125
+ shadow_cascade_rasterization_pass_descriptor.resources = resources;
126
+ shadow_cascade_rasterization_pass_descriptor.pipeline = RenderPipelineDescriptor.from({
127
+ label: "Rasterize to Depth Buffer / opaque / cascade",
128
+ layout: resources.generatePipelineLayout(GPUShaderStage.VERTEX),
129
+ vertex: {
130
+ module: {
131
+ code: vertex_shader.source
132
+ }
133
+ },
134
+ depthStencil: DEPTH_STENCIL_STATE_SHADOW_CASCADE,
135
+ primitive: rasterization_primitive_state
136
+ });
137
+ shadow_cascade_rasterization_pass_descriptor.corner_pipeline = RenderPipelineDescriptor.from({
138
+ label: "Rasterize to Depth Buffer / opaque corners / cascade",
139
+ layout: resources.generatePipelineLayout(GPUShaderStage.VERTEX),
140
+ vertex: {
141
+ module: {
142
+ code: vertex_shader_corner.source
143
+ }
144
+ },
145
+ depthStencil: DEPTH_STENCIL_STATE_SHADOW_CASCADE,
146
+ primitive: rasterization_primitive_state
147
+ });
148
+
149
+ shadow_cascade_rasterization_pass_descriptor.depthStencilAttachment.depthClearValue = DEPTH_BACKGROUND_VALUE;
@@ -5,5 +5,13 @@
5
5
  * @type {TemplatePassDescriptor}
6
6
  */
7
7
  export const shadow_rasterization_alpha_tested_pass_descriptor: TemplatePassDescriptor;
8
+ /**
9
+ * The same for a directional light's cascades, its casters biased as `shadow_cascade_rasterization_pass_descriptor`
10
+ * biases the opaque ones.
11
+ *
12
+ * @type {TemplatePassDescriptor}
13
+ */
14
+ export const shadow_cascade_alpha_tested_pass_descriptor: TemplatePassDescriptor;
15
+ export type DepthStencilState = import("../../../../descriptor/pipeline/render/DepthStencilState.js").DepthStencilState;
8
16
  import { TemplatePassDescriptor } from "../../TemplatePassDescriptor.js";
9
17
  //# sourceMappingURL=shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shadow_rasterization_alpha_tested_pass_descriptor.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js"],"names":[],"mappings":"AAoJA;;;;;GAKG;AACH,gEAFU,sBAAsB,CA4B7B;uCAvJoC,iCAAiC"}
1
+ {"version":3,"file":"shadow_rasterization_alpha_tested_pass_descriptor.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js"],"names":[],"mappings":"AAsOA;;;;;GAKG;AACH,gEAFU,sBAAsB,CAM9B;AAEF;;;;;GAKG;AACH,0DAFU,sBAAsB,CAM9B;gCA3PY,OAAO,6DAA6D,EAAE,iBAAiB;uCAqC9D,iCAAiC"}