@woosh/meep-engine 3.78.2 → 3.78.3

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 (31) hide show
  1. package/package.json +1 -1
  2. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
  3. package/src/engine/asset/loaders/GroomAssetLoader.js +2 -1
  4. package/src/engine/graphics/hair/Groom.d.ts +30 -0
  5. package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
  6. package/src/engine/graphics/hair/Groom.js +35 -0
  7. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +18 -2
  8. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
  9. package/src/engine/graphics/hair/GroomSerializationAdapter.js +36 -6
  10. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts +8 -0
  11. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts.map +1 -0
  12. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.js +44 -0
  13. package/src/engine/graphics/hair/groom_bake_shelter.d.ts +33 -0
  14. package/src/engine/graphics/hair/groom_bake_shelter.d.ts.map +1 -0
  15. package/src/engine/graphics/hair/groom_bake_shelter.js +288 -0
  16. package/src/engine/graphics/hair/groom_build_group.d.ts +10 -2
  17. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
  18. package/src/engine/graphics/hair/groom_build_group.js +8 -2
  19. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  20. package/src/shade/renderer/hair/GPUHairSystem.js +27 -2
  21. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
  22. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +4 -0
  23. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +27 -6
  24. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -1
  25. package/src/shade/renderer/hair/HAIR_SIMULATION.js +33 -6
  26. package/src/shade/renderer/hair/chunk_hair_guide.d.ts +9 -2
  27. package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -1
  28. package/src/shade/renderer/hair/chunk_hair_guide.js +30 -2
  29. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +5 -2
  30. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -1
  31. package/src/shade/renderer/hair/shader_hair_simulate.js +23 -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.78.2",
9
+ "version": "3.78.3",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -1 +1 @@
1
- {"version":3,"file":"GroomAssetLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/GroomAssetLoader.js"],"names":[],"mappings":"AAyBA;;;;;;GAMG;AACH,qCAHW,KAAK,GACH,WAAW,CAcvB;AAED;;;;;GAKG;AACH,sCAHW,WAAW,GACT,KAAK,CAsBjB;AA5DD;;;GAGG;AACH,+BAFU,MAAM,CAE2B;AA0D3C;;;;GAIG;AACH;;IAaI,8FAmBC;CACJ;sBA7GqB,8BAA8B;4BAOxB,kBAAkB;sBAHxB,aAAa"}
1
+ {"version":3,"file":"GroomAssetLoader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/asset/loaders/GroomAssetLoader.js"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,qCAHW,KAAK,GACH,WAAW,CAcvB;AAED;;;;;GAKG;AACH,sCAHW,WAAW,GACT,KAAK,CAsBjB;AA5DD;;;GAGG;AACH,+BAFU,MAAM,CAE2B;AA0D3C;;;;GAIG;AACH;;IAaI,8FAmBC;CACJ;sBA9GqB,8BAA8B;4BAQxB,kBAAkB;sBAHxB,aAAa"}
@@ -4,6 +4,7 @@ import { load_groom_usd } from "../../../shade/renderer/loader/usd/usd_groom_ext
4
4
  import { Groom } from "../../graphics/hair/Groom.js";
5
5
  import { GroomSerializationAdapter } from "../../graphics/hair/GroomSerializationAdapter.js";
6
6
  import { GroomSerializationUpgrader_0_1 } from "../../graphics/hair/GroomSerializationUpgrader_0_1.js";
7
+ import { GroomSerializationUpgrader_1_2 } from "../../graphics/hair/GroomSerializationUpgrader_1_2.js";
7
8
  import { executeBinaryClassUpgraderChain } from "../../ecs/storage/binary/executeBinaryClassUpgraderChain.js";
8
9
  import { Asset } from "../Asset.js";
9
10
  import { GameAssetType } from "../GameAssetType.js";
@@ -21,7 +22,7 @@ export const GROOM_FILE_MAGIC = 0x4D52474D;
21
22
  * `v` to `v + 1`.
22
23
  * @type {import("../../ecs/storage/binary/BinaryClassUpgrader.js").BinaryClassUpgrader[]}
23
24
  */
24
- const GROOM_UPGRADERS = [new GroomSerializationUpgrader_0_1()];
25
+ const GROOM_UPGRADERS = [new GroomSerializationUpgrader_0_1(), new GroomSerializationUpgrader_1_2()];
25
26
 
26
27
  /**
27
28
  * A {@link Groom} as a file: {@link GROOM_FILE_MAGIC}, the format's version (u32), then the groom
@@ -24,6 +24,17 @@ export const GROOM_POINT_COUNT_MAX: number;
24
24
  * @type {number}
25
25
  */
26
26
  export const GROOM_GUIDE_LIMIT: number;
27
+ /**
28
+ * Depths a guide's node has in {@link GroomGroup#guide_shelter}: toward +x, −x, +y, −y, +z and −z.
29
+ * @type {number}
30
+ */
31
+ export const GROOM_SHELTER_WORDS: number;
32
+ /**
33
+ * The depth that stands for hair nothing passes, and for anything solid. A fibre's drag coefficient is never under
34
+ * one, so no more than `e^(−depth / 2)` of a wind crosses a depth: past this, less than a float32 tells from none.
35
+ * @type {number}
36
+ */
37
+ export const GROOM_SHELTER_OPAQUE: number;
27
38
  /**
28
39
  * Strands of hair that share a point count, as they are at rest: a scalp, the brows, the lashes, a beard.
29
40
  *
@@ -106,6 +117,25 @@ export class GroomGroup {
106
117
  * @type {number}
107
118
  */
108
119
  guide_reach: number;
120
+ /**
121
+ * How much hair stands between each guide's node and the open air along each of the group's axes
122
+ * (`groom_bake_shelter`): {@link GROOM_SHELTER_WORDS} depths a node, a guide's nodes in turn, guide after guide.
123
+ * A depth is the fibres' frontal area along the way out over the area crossed, a pure number, never past
124
+ * {@link GROOM_SHELTER_OPAQUE}.
125
+ * @type {Float32Array}
126
+ */
127
+ guide_shelter: Float32Array;
128
+ /**
129
+ * The area the group's strands cover seen from a direction, averaged over every direction, square metres
130
+ * (`groom_bake_shelter`): what of a wind the group stands in the way of.
131
+ * @type {number}
132
+ */
133
+ silhouette: number;
134
+ /**
135
+ * The length of every strand of the group, summed, metres.
136
+ * @type {number}
137
+ */
138
+ fibre_length: number;
109
139
  /**
110
140
  * @returns {number} guides the group has
111
141
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Groom.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/Groom.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;GAGG;AACH,2CAFU,MAAM,CAEmC;AAEnD;;;GAGG;AACH,sCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,oCAFU,MAAM,CAEyB;AAEzC;;;GAGG;AACH,gCAFU,MAAM,CAEyB;AAEzC;;;;;;;;;GASG;AACH;IACI;;OAEG;IACH,MAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;OAEG;IACH,cAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,QAFU,YAAY,CAEO;IAE7B;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;;OAIG;IACH,YAFU,MAAM,CAED;IAEf;;;;OAIG;IACH,cAFU,MAAM,CAEC;IAEjB;;;;OAIG;IACH,mBAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,WAAW,CAEa;IAElC;;;OAGG;IACH,oBAFU,WAAW,CAEmB;IAExC;;;OAGG;IACH,gBAFU,YAAY,CAEe;IAErC;;;OAGG;IACH,cAFU,YAAY,CAEa;IAEnC;;;OAGG;IACH,cAFU,WAAW,CAEa;IAElC;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;OAEG;IACH,0BAEC;IAED;;;OAGG;IACH,QAFU,WAAW,CAEO;IAE5B;;;;OAIG;IACH,WAFU,UAAU,CAEU;IAE9B;;;;;OAKG;IACH,YAFU,YAAY,CAEW;IAEjC;;OAEG;IACH,0BAEC;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,UACN,MAAM,SACN,MAAM,QAehB;IAED;;;;;;OAMG;IACH,mBAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAMlB;CACJ;AAED;;;GAGG;AACH;IACI;;OAEG;IACH,QAFU,UAAU,EAAE,CAEV;IAEZ;;OAEG;IACH,2BAQC;IAED;;OAEG;IACH,0BAUC;IAED;;OAEG;IACH,WAFW,UAAU,QAOpB;CACJ"}
1
+ {"version":3,"file":"Groom.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/Groom.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;GAGG;AACH,2CAFU,MAAM,CAEmC;AAEnD;;;GAGG;AACH,sCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,oCAFU,MAAM,CAEyB;AAEzC;;;GAGG;AACH,gCAFU,MAAM,CAEyB;AAEzC;;;GAGG;AACH,kCAFU,MAAM,CAEqB;AAErC;;;;GAIG;AACH,mCAFU,MAAM,CAEuB;AAEvC;;;;;;;;;GASG;AACH;IACI;;OAEG;IACH,MAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;OAEG;IACH,cAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,QAFU,YAAY,CAEO;IAE7B;;;OAGG;IACH,WAFU,MAAM,CAEF;IAEd;;;;OAIG;IACH,YAFU,MAAM,CAED;IAEf;;;;OAIG;IACH,cAFU,MAAM,CAEC;IAEjB;;;;OAIG;IACH,mBAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,WAAW,CAEa;IAElC;;;OAGG;IACH,oBAFU,WAAW,CAEmB;IAExC;;;OAGG;IACH,gBAFU,YAAY,CAEe;IAErC;;;OAGG;IACH,cAFU,YAAY,CAEa;IAEnC;;;OAGG;IACH,cAFU,WAAW,CAEa;IAElC;;;OAGG;IACH,aAFU,MAAM,CAEA;IAEhB;;;;;;OAMG;IACH,eAFU,YAAY,CAEc;IAEpC;;;;OAIG;IACH,YAFU,MAAM,CAED;IAEf;;;OAGG;IACH,cAFU,MAAM,CAEC;IAEjB;;OAEG;IACH,0BAEC;IAED;;;OAGG;IACH,QAFU,WAAW,CAEO;IAE5B;;;;OAIG;IACH,WAFU,UAAU,CAEU;IAE9B;;;;;OAKG;IACH,YAFU,YAAY,CAEW;IAEjC;;OAEG;IACH,0BAEC;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,UACN,MAAM,SACN,MAAM,QAehB;IAED;;;;;;OAMG;IACH,mBAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAMlB;CACJ;AAED;;;GAGG;AACH;IACI;;OAEG;IACH,QAFU,UAAU,EAAE,CAEV;IAEZ;;OAEG;IACH,2BAQC;IAED;;OAEG;IACH,0BAUC;IAED;;OAEG;IACH,WAFW,UAAU,QAOpB;CACJ"}
@@ -31,6 +31,19 @@ export const GROOM_POINT_COUNT_MAX = 129;
31
31
  */
32
32
  export const GROOM_GUIDE_LIMIT = 0x10000;
33
33
 
34
+ /**
35
+ * Depths a guide's node has in {@link GroomGroup#guide_shelter}: toward +x, −x, +y, −y, +z and −z.
36
+ * @type {number}
37
+ */
38
+ export const GROOM_SHELTER_WORDS = 6;
39
+
40
+ /**
41
+ * The depth that stands for hair nothing passes, and for anything solid. A fibre's drag coefficient is never under
42
+ * one, so no more than `e^(−depth / 2)` of a wind crosses a depth: past this, less than a float32 tells from none.
43
+ * @type {number}
44
+ */
45
+ export const GROOM_SHELTER_OPAQUE = 32;
46
+
34
47
  /**
35
48
  * Strands of hair that share a point count, as they are at rest: a scalp, the brows, the lashes, a beard.
36
49
  *
@@ -127,6 +140,28 @@ export class GroomGroup {
127
140
  */
128
141
  guide_reach = 0;
129
142
 
143
+ /**
144
+ * How much hair stands between each guide's node and the open air along each of the group's axes
145
+ * (`groom_bake_shelter`): {@link GROOM_SHELTER_WORDS} depths a node, a guide's nodes in turn, guide after guide.
146
+ * A depth is the fibres' frontal area along the way out over the area crossed, a pure number, never past
147
+ * {@link GROOM_SHELTER_OPAQUE}.
148
+ * @type {Float32Array}
149
+ */
150
+ guide_shelter = new Float32Array(0);
151
+
152
+ /**
153
+ * The area the group's strands cover seen from a direction, averaged over every direction, square metres
154
+ * (`groom_bake_shelter`): what of a wind the group stands in the way of.
155
+ * @type {number}
156
+ */
157
+ silhouette = 0;
158
+
159
+ /**
160
+ * The length of every strand of the group, summed, metres.
161
+ * @type {number}
162
+ */
163
+ fibre_length = 0;
164
+
130
165
  /**
131
166
  * @returns {number} guides the group has
132
167
  */
@@ -19,6 +19,20 @@ export function groom_write_group_v0(buffer: import("../../../core/binary/Binary
19
19
  * @param {GroomGroup} group
20
20
  */
21
21
  export function groom_write_guides(buffer: import("../../../core/binary/BinaryBuffer.js").BinaryBuffer, group: GroomGroup): void;
22
+ /**
23
+ * Write how a group shelters itself from the air, as version 2 follows its guides with it.
24
+ *
25
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
26
+ * @param {GroomGroup} group
27
+ */
28
+ export function groom_write_shelter(buffer: import("../../../core/binary/BinaryBuffer.js").BinaryBuffer, group: GroomGroup): void;
29
+ /**
30
+ * Read a group's guides, as version 1 follows its version 0 fields with them.
31
+ *
32
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
33
+ * @param {GroomGroup} group
34
+ */
35
+ export function groom_read_guides(buffer: import("../../../core/binary/BinaryBuffer.js").BinaryBuffer, group: GroomGroup): void;
22
36
  /**
23
37
  * A {@link Groom} as bytes: its groups, each as the renderer reads it, so a load is a copy and nothing is rebuilt.
24
38
  *
@@ -26,9 +40,11 @@ export function groom_write_guides(buffer: import("../../../core/binary/BinaryBu
26
40
  * the mean width (f32 each), the decimation table (a u8 count, then f32 each), the rest points (u32, `GROOM_POINT_WORDS`
27
41
  * a point) and the strands' variation bytes; then its guides: the node count and the guide count (u32 each), each
28
42
  * guide's strand and strand count (u32 each), wisp diameter and length (f32 each), each strand's guide (u16) and the
29
- * reach (f32). The group count (u32) leads.
43
+ * reach (f32); then how it shelters itself from the air: its silhouette and its fibres' length (f32 each) and its
44
+ * guides' depths (f32, `GROOM_SHELTER_WORDS` a node). The group count (u32) leads.
30
45
  *
31
- * Version 0 had no guides; `GroomSerializationUpgrader_0_1` gives its groups theirs.
46
+ * Version 0 had no guides; `GroomSerializationUpgrader_0_1` gives its groups theirs. Version 1 had no shelter;
47
+ * `GroomSerializationUpgrader_1_2` works it out, with nothing solid about the hair.
32
48
  */
33
49
  export class GroomSerializationAdapter extends BinaryClassSerializationAdapter<any> {
34
50
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"GroomSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/GroomSerializationAdapter.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,4CAHW,OAAO,sCAAsC,EAAE,YAAY,GACzD,UAAU,CAsBtB;AAED;;;;;GAKG;AACH,6CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAepB;AAED;;;;;GAKG;AACH,2CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAapB;AA6BD;;;;;;;;;;GAUG;AACH;;IACI,oBAAc;IAGd;;;OAGG;IACH,kBAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,KAAK,QAWf;IAED;;;OAGG;IACH,oBAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,KAAK,QAiBf;CACJ;2BApJoD,YAAY;gDADjB,6DAA6D;sBACxD,YAAY"}
1
+ {"version":3,"file":"GroomSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/GroomSerializationAdapter.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,4CAHW,OAAO,sCAAsC,EAAE,YAAY,GACzD,UAAU,CAsBtB;AAED;;;;;GAKG;AACH,6CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAepB;AAED;;;;;GAKG;AACH,2CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAapB;AAED;;;;;GAKG;AACH,4CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAMpB;AAcD;;;;;GAKG;AACH,0CAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,UAAU,QAuBpB;AAED;;;;;;;;;;;;GAYG;AACH;;IACI,oBAAc;IAGd;;;OAGG;IACH,kBAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,KAAK,QAYf;IAED;;;OAGG;IACH,oBAHW,OAAO,sCAAsC,EAAE,YAAY,SAC3D,KAAK,QAkBf;CACJ;2BAlLyE,YAAY;gDADtC,6DAA6D;sBACnC,YAAY"}
@@ -1,5 +1,5 @@
1
1
  import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
- import { GROOM_POINT_WORDS, Groom, GroomGroup } from "./Groom.js";
2
+ import { GROOM_POINT_WORDS, GROOM_SHELTER_WORDS, Groom, GroomGroup } from "./Groom.js";
3
3
  import { groom_root_spacing } from "./groom_root_spacing.js";
4
4
 
5
5
  /**
@@ -71,10 +71,36 @@ export function groom_write_guides(buffer, group) {
71
71
  }
72
72
 
73
73
  /**
74
+ * Write how a group shelters itself from the air, as version 2 follows its guides with it.
75
+ *
76
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
77
+ * @param {GroomGroup} group
78
+ */
79
+ export function groom_write_shelter(buffer, group) {
80
+ buffer.writeFloat32(group.silhouette);
81
+ buffer.writeFloat32(group.fibre_length);
82
+ buffer.writeFloat32Array(group.guide_shelter, 0, group.guide_count * group.guide_point_count * GROOM_SHELTER_WORDS);
83
+ }
84
+
85
+ /**
86
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
87
+ * @param {GroomGroup} group with its guides
88
+ */
89
+ function read_shelter(buffer, group) {
90
+ group.silhouette = buffer.readFloat32();
91
+ group.fibre_length = buffer.readFloat32();
92
+
93
+ group.guide_shelter = new Float32Array(group.guide_count * group.guide_point_count * GROOM_SHELTER_WORDS);
94
+ buffer.readFloat32Array(group.guide_shelter, 0, group.guide_shelter.length);
95
+ }
96
+
97
+ /**
98
+ * Read a group's guides, as version 1 follows its version 0 fields with them.
99
+ *
74
100
  * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
75
101
  * @param {GroomGroup} group
76
102
  */
77
- function read_guides(buffer, group) {
103
+ export function groom_read_guides(buffer, group) {
78
104
  group.guide_point_count = buffer.readUint32();
79
105
 
80
106
  const count = buffer.readUint32();
@@ -104,13 +130,15 @@ function read_guides(buffer, group) {
104
130
  * the mean width (f32 each), the decimation table (a u8 count, then f32 each), the rest points (u32, `GROOM_POINT_WORDS`
105
131
  * a point) and the strands' variation bytes; then its guides: the node count and the guide count (u32 each), each
106
132
  * guide's strand and strand count (u32 each), wisp diameter and length (f32 each), each strand's guide (u16) and the
107
- * reach (f32). The group count (u32) leads.
133
+ * reach (f32); then how it shelters itself from the air: its silhouette and its fibres' length (f32 each) and its
134
+ * guides' depths (f32, `GROOM_SHELTER_WORDS` a node). The group count (u32) leads.
108
135
  *
109
- * Version 0 had no guides; `GroomSerializationUpgrader_0_1` gives its groups theirs.
136
+ * Version 0 had no guides; `GroomSerializationUpgrader_0_1` gives its groups theirs. Version 1 had no shelter;
137
+ * `GroomSerializationUpgrader_1_2` works it out, with nothing solid about the hair.
110
138
  */
111
139
  export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
112
140
  klass = Groom;
113
- version = 1;
141
+ version = 2;
114
142
 
115
143
  /**
116
144
  * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} buffer
@@ -124,6 +152,7 @@ export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
124
152
  for (let g = 0; g < groups.length; g++) {
125
153
  groom_write_group_v0(buffer, groups[g]);
126
154
  groom_write_guides(buffer, groups[g]);
155
+ groom_write_shelter(buffer, groups[g]);
127
156
  }
128
157
  }
129
158
 
@@ -139,7 +168,8 @@ export class GroomSerializationAdapter extends BinaryClassSerializationAdapter {
139
168
  for (let g = 0; g < count; g++) {
140
169
  const group = groom_read_group_v0(buffer);
141
170
 
142
- read_guides(buffer, group);
171
+ groom_read_guides(buffer, group);
172
+ read_shelter(buffer, group);
143
173
 
144
174
  // derived from the roots, so not written
145
175
  group.root_spacing = groom_root_spacing(group);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A version 1 groom as version 2: each group and its guides as they were, followed by how it shelters itself from the
3
+ * air as `groom_bake_shelter` works it out with nothing solid about the hair.
4
+ */
5
+ export class GroomSerializationUpgrader_1_2 extends BinaryClassUpgrader {
6
+ }
7
+ import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
8
+ //# sourceMappingURL=GroomSerializationUpgrader_1_2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroomSerializationUpgrader_1_2.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/GroomSerializationUpgrader_1_2.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;CA4BC;oCA3CmC,iDAAiD"}
@@ -0,0 +1,44 @@
1
+ import { BinaryClassUpgrader } from "../../ecs/storage/binary/BinaryClassUpgrader.js";
2
+ import { groom_bake_shelter } from "./groom_bake_shelter.js";
3
+ import { groom_root_spacing } from "./groom_root_spacing.js";
4
+ import {
5
+ groom_read_group_v0,
6
+ groom_read_guides,
7
+ groom_write_group_v0,
8
+ groom_write_guides,
9
+ groom_write_shelter
10
+ } from "./GroomSerializationAdapter.js";
11
+
12
+ /**
13
+ * A version 1 groom as version 2: each group and its guides as they were, followed by how it shelters itself from the
14
+ * air as `groom_bake_shelter` works it out with nothing solid about the hair.
15
+ */
16
+ export class GroomSerializationUpgrader_1_2 extends BinaryClassUpgrader {
17
+ __startVersion = 1;
18
+ __targetVersion = 2;
19
+
20
+ /**
21
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} source
22
+ * @param {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} target
23
+ */
24
+ upgrade(source, target) {
25
+ const count = source.readUint32();
26
+
27
+ target.writeUint32(count);
28
+
29
+ for (let g = 0; g < count; g++) {
30
+ const group = groom_read_group_v0(source);
31
+
32
+ groom_read_guides(source, group);
33
+
34
+ // not written, and what the bake takes its cells from
35
+ group.root_spacing = groom_root_spacing(group);
36
+
37
+ groom_bake_shelter(group, null);
38
+
39
+ groom_write_group_v0(target, group);
40
+ groom_write_guides(target, group);
41
+ groom_write_shelter(target, group);
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Work out how a group's hair shelters itself from the air, from its strands at rest: for every node of every guide,
3
+ * how much hair stands between it and the open air along each axis ({@link GroomGroup#guide_shelter}); and for the
4
+ * group, the area it stands in the wind's way with ({@link GroomGroup#silhouette}) and its fibres' length
5
+ * ({@link GroomGroup#fibre_length}). The guides are to be chosen already (`groom_build_guides`).
6
+ *
7
+ * **The hair as a density.** Every strand's frontal area, its length times the group's mean width, is laid into a
8
+ * grid a cell at a time, as frontal area a unit volume, and the grid is averaged with a 3 × 3 × 3 box so no one
9
+ * strand stands out of it. A cell is as wide as the wisp a guide stands for, the mean of the guides' diameters, or
10
+ * as the strands grow apart ({@link GroomGroup#root_spacing}) where that is wider, and wider still where the grid
11
+ * would pass {@link GROOM_SHELTER_CELL_LIMIT}.
12
+ *
13
+ * **A node's depths.** Air crossing hair is slowed by the fibres' drag: over a path whose frontal area a unit area
14
+ * crossed is `N`, a wind keeps `e^(−C_d N / 2)` of its speed, `C_d` a fibre's drag coefficient at that speed.
15
+ * A node keeps `N` along the way out toward each of +x, −x, +y, −y, +z and −z, from where it is to the grid's edge,
16
+ * and the wind's speed is applied by whoever reads them. A cell `solid` reaches into is one nothing passes
17
+ * (`shape3_voxelize_to_grid`), and a depth stops at {@link GROOM_SHELTER_OPAQUE}.
18
+ *
19
+ * **The silhouette.** The cells any strand passes through, seen along each axis, give three areas; the mean over
20
+ * every direction is taken of the ellipsoid with those three, whose area seen along a unit `n` is
21
+ * `√((A_x n_x)² + (A_y n_y)² + (A_z n_z)²)`.
22
+ *
23
+ * @param {import("./Groom.js").GroomGroup} group with its points and its guides
24
+ * @param {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air does
25
+ * not pass, in the group's metres: the head the hair grows on
26
+ */
27
+ export function groom_bake_shelter(group: import("./Groom.js").GroomGroup, solid?: import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D | null): void;
28
+ /**
29
+ * The most cells the bake's grid has, a safety net: a group whose cells would be more takes larger ones.
30
+ * @type {number}
31
+ */
32
+ export const GROOM_SHELTER_CELL_LIMIT: number;
33
+ //# sourceMappingURL=groom_bake_shelter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groom_bake_shelter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_bake_shelter.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,0CAJW,OAAO,YAAY,EAAE,UAAU,UAC/B,OAAO,gDAAgD,EAAE,eAAe,GAAC,IAAI,QA2NvF;AA1RD;;;GAGG;AACH,uCAFU,MAAM,CAEgC"}
@@ -0,0 +1,288 @@
1
+ import { assert } from "../../../core/assert.js";
2
+ import { shape3_voxelize_to_grid } from "../../../core/geom/3d/shape/util/shape3_voxelize_to_grid.js";
3
+ import { sphere_fibonacci_point } from "../../../core/geom/3d/sphere/sphere_fibonacci_point.js";
4
+ import { GROOM_SHELTER_OPAQUE, GROOM_SHELTER_WORDS } from "./Groom.js";
5
+
6
+ /**
7
+ * The most cells the bake's grid has, a safety net: a group whose cells would be more takes larger ones.
8
+ * @type {number}
9
+ */
10
+ export const GROOM_SHELTER_CELL_LIMIT = 1 << 24;
11
+
12
+ /**
13
+ * Directions the mean silhouette is taken over, evenly over the sphere.
14
+ */
15
+ const SILHOUETTE_DIRECTIONS = 2048;
16
+
17
+ /**
18
+ * Average a grid with its two neighbours along one axis, `source` into `target`; past the grid there is nothing.
19
+ *
20
+ * @param {Float32Array} source
21
+ * @param {Float32Array} target
22
+ * @param {number} count cells
23
+ * @param {number} stride cells from a cell to its neighbour along the axis
24
+ * @param {number} size cells along the axis
25
+ */
26
+ function blur_axis(source, target, count, stride, size) {
27
+ const span = stride * size;
28
+
29
+ for (let i = 0; i < count; i++) {
30
+ const along = Math.floor((i % span) / stride);
31
+
32
+ let sum = source[i];
33
+
34
+ if (along > 0) {
35
+ sum += source[i - stride];
36
+ }
37
+
38
+ if (along < size - 1) {
39
+ sum += source[i + stride];
40
+ }
41
+
42
+ target[i] = sum / 3;
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Work out how a group's hair shelters itself from the air, from its strands at rest: for every node of every guide,
48
+ * how much hair stands between it and the open air along each axis ({@link GroomGroup#guide_shelter}); and for the
49
+ * group, the area it stands in the wind's way with ({@link GroomGroup#silhouette}) and its fibres' length
50
+ * ({@link GroomGroup#fibre_length}). The guides are to be chosen already (`groom_build_guides`).
51
+ *
52
+ * **The hair as a density.** Every strand's frontal area, its length times the group's mean width, is laid into a
53
+ * grid a cell at a time, as frontal area a unit volume, and the grid is averaged with a 3 × 3 × 3 box so no one
54
+ * strand stands out of it. A cell is as wide as the wisp a guide stands for, the mean of the guides' diameters, or
55
+ * as the strands grow apart ({@link GroomGroup#root_spacing}) where that is wider, and wider still where the grid
56
+ * would pass {@link GROOM_SHELTER_CELL_LIMIT}.
57
+ *
58
+ * **A node's depths.** Air crossing hair is slowed by the fibres' drag: over a path whose frontal area a unit area
59
+ * crossed is `N`, a wind keeps `e^(−C_d N / 2)` of its speed, `C_d` a fibre's drag coefficient at that speed.
60
+ * A node keeps `N` along the way out toward each of +x, −x, +y, −y, +z and −z, from where it is to the grid's edge,
61
+ * and the wind's speed is applied by whoever reads them. A cell `solid` reaches into is one nothing passes
62
+ * (`shape3_voxelize_to_grid`), and a depth stops at {@link GROOM_SHELTER_OPAQUE}.
63
+ *
64
+ * **The silhouette.** The cells any strand passes through, seen along each axis, give three areas; the mean over
65
+ * every direction is taken of the ellipsoid with those three, whose area seen along a unit `n` is
66
+ * `√((A_x n_x)² + (A_y n_y)² + (A_z n_z)²)`.
67
+ *
68
+ * @param {import("./Groom.js").GroomGroup} group with its points and its guides
69
+ * @param {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air does
70
+ * not pass, in the group's metres: the head the hair grows on
71
+ */
72
+ export function groom_bake_shelter(group, solid = null) {
73
+ const strand_count = group.strand_count;
74
+ const point_count = group.point_count;
75
+ const guide_count = group.guide_count;
76
+ const node_count = group.guide_point_count;
77
+
78
+ assert.greaterThan(guide_count, 0, 'the group has guides');
79
+
80
+ const bounds = group.bounds;
81
+
82
+ let cell = 0;
83
+
84
+ for (let g = 0; g < guide_count; g++) {
85
+ cell += group.guide_diameter[g];
86
+ }
87
+
88
+ cell = Math.max(cell / guide_count, group.root_spacing);
89
+
90
+ assert.greaterThan(cell, 0, 'cell');
91
+
92
+ const extent_x = bounds[3] - bounds[0];
93
+ const extent_y = bounds[4] - bounds[1];
94
+ const extent_z = bounds[5] - bounds[2];
95
+
96
+ // a cell of margin every side, which the averaging spills into
97
+ let nx = Math.ceil(extent_x / cell) + 3;
98
+ let ny = Math.ceil(extent_y / cell) + 3;
99
+ let nz = Math.ceil(extent_z / cell) + 3;
100
+
101
+ if (nx * ny * nz > GROOM_SHELTER_CELL_LIMIT) {
102
+ cell *= Math.cbrt(nx * ny * nz / GROOM_SHELTER_CELL_LIMIT);
103
+
104
+ nx = Math.ceil(extent_x / cell) + 3;
105
+ ny = Math.ceil(extent_y / cell) + 3;
106
+ nz = Math.ceil(extent_z / cell) + 3;
107
+ }
108
+
109
+ const origin_x = bounds[0] - cell;
110
+ const origin_y = bounds[1] - cell;
111
+ const origin_z = bounds[2] - cell;
112
+
113
+ const count = nx * ny * nz;
114
+ const stride_y = nx;
115
+ const stride_z = nx * ny;
116
+
117
+ let density = new Float32Array(count);
118
+ let scratch = new Float32Array(count);
119
+
120
+ // what the strands cover, seen along x, y and z
121
+ const cover_x = new Uint8Array(ny * nz);
122
+ const cover_y = new Uint8Array(nx * nz);
123
+ const cover_z = new Uint8Array(nx * ny);
124
+
125
+ const a = [0, 0, 0];
126
+ const b = [0, 0, 0];
127
+
128
+ const frontal = group.width_mean / (cell * cell * cell);
129
+
130
+ let fibre_length = 0;
131
+
132
+ for (let s = 0; s < strand_count; s++) {
133
+ group.read_point(a, 0, s, 0);
134
+
135
+ for (let i = 1; i < point_count; i++) {
136
+ group.read_point(b, 0, s, i);
137
+
138
+ const dx = b[0] - a[0];
139
+ const dy = b[1] - a[1];
140
+ const dz = b[2] - a[2];
141
+
142
+ const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
143
+
144
+ fibre_length += length;
145
+
146
+ // pieces no longer than half a cell, each laid where its middle is
147
+ const pieces = Math.max(1, Math.ceil(2 * length / cell));
148
+ const share = frontal * length / pieces;
149
+
150
+ for (let k = 0; k < pieces; k++) {
151
+ const t = (k + 0.5) / pieces;
152
+
153
+ const x = Math.floor((a[0] + dx * t - origin_x) / cell);
154
+ const y = Math.floor((a[1] + dy * t - origin_y) / cell);
155
+ const z = Math.floor((a[2] + dz * t - origin_z) / cell);
156
+
157
+ density[x + stride_y * y + stride_z * z] += share;
158
+
159
+ cover_x[y + ny * z] = 1;
160
+ cover_y[x + nx * z] = 1;
161
+ cover_z[x + nx * y] = 1;
162
+ }
163
+
164
+ a[0] = b[0];
165
+ a[1] = b[1];
166
+ a[2] = b[2];
167
+ }
168
+ }
169
+
170
+ blur_axis(density, scratch, count, 1, nx);
171
+ blur_axis(scratch, density, count, stride_y, ny);
172
+ blur_axis(density, scratch, count, stride_z, nz);
173
+
174
+ const swap = density;
175
+
176
+ density = scratch;
177
+ scratch = swap;
178
+
179
+ if (solid !== null) {
180
+ // a cell's index to its middle, and back
181
+ const grid_to_world = new Float64Array(16);
182
+ const world_to_grid = new Float64Array(16);
183
+
184
+ grid_to_world[0] = grid_to_world[5] = grid_to_world[10] = cell;
185
+ grid_to_world[12] = origin_x + 0.5 * cell;
186
+ grid_to_world[13] = origin_y + 0.5 * cell;
187
+ grid_to_world[14] = origin_z + 0.5 * cell;
188
+ grid_to_world[15] = 1;
189
+
190
+ world_to_grid[0] = world_to_grid[5] = world_to_grid[10] = 1 / cell;
191
+ world_to_grid[12] = -grid_to_world[12] / cell;
192
+ world_to_grid[13] = -grid_to_world[13] / cell;
193
+ world_to_grid[14] = -grid_to_world[14] / cell;
194
+ world_to_grid[15] = 1;
195
+
196
+ const inside = new Uint8Array(count);
197
+
198
+ shape3_voxelize_to_grid(solid, world_to_grid, grid_to_world, inside, nx, ny, nz);
199
+
200
+ for (let i = 0; i < count; i++) {
201
+ if (inside[i] !== 0) {
202
+ density[i] = Infinity;
203
+ }
204
+ }
205
+ }
206
+
207
+ const shelter = new Float32Array(guide_count * node_count * GROOM_SHELTER_WORDS);
208
+ const stride = (point_count - 1) / (node_count - 1);
209
+
210
+ const sizes = [nx, ny, nz];
211
+ const strides = [1, stride_y, stride_z];
212
+ const place = [0, 0, 0];
213
+ const index = [0, 0, 0];
214
+
215
+ for (let g = 0; g < guide_count; g++) {
216
+ const strand = group.guide_strand[g];
217
+
218
+ for (let i = 0; i < node_count; i++) {
219
+ group.read_point(a, 0, strand, i * stride);
220
+
221
+ place[0] = (a[0] - origin_x) / cell;
222
+ place[1] = (a[1] - origin_y) / cell;
223
+ place[2] = (a[2] - origin_z) / cell;
224
+
225
+ index[0] = Math.floor(place[0]);
226
+ index[1] = Math.floor(place[1]);
227
+ index[2] = Math.floor(place[2]);
228
+
229
+ const home = index[0] + stride_y * index[1] + stride_z * index[2];
230
+ const at = (g * node_count + i) * GROOM_SHELTER_WORDS;
231
+
232
+ for (let axis = 0; axis < 3; axis++) {
233
+ const within = place[axis] - index[axis];
234
+
235
+ for (let side = 0; side < 2; side++) {
236
+ const step = side === 0 ? strides[axis] : -strides[axis];
237
+ const cells = side === 0 ? sizes[axis] - 1 - index[axis] : index[axis];
238
+
239
+ // what is left of the node's own cell, then every cell to the edge
240
+ let depth = density[home] * cell * (side === 0 ? 1 - within : within);
241
+
242
+ for (let k = 1; k <= cells && depth < GROOM_SHELTER_OPAQUE; k++) {
243
+ depth += density[home + step * k] * cell;
244
+ }
245
+
246
+ // a node inside something solid is no depth of nothing: opaque as well
247
+ shelter[at + axis * 2 + side] = depth < GROOM_SHELTER_OPAQUE ? depth : GROOM_SHELTER_OPAQUE;
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ let area_x = 0;
254
+ let area_y = 0;
255
+ let area_z = 0;
256
+
257
+ for (let i = 0; i < cover_x.length; i++) {
258
+ area_x += cover_x[i];
259
+ }
260
+
261
+ for (let i = 0; i < cover_y.length; i++) {
262
+ area_y += cover_y[i];
263
+ }
264
+
265
+ for (let i = 0; i < cover_z.length; i++) {
266
+ area_z += cover_z[i];
267
+ }
268
+
269
+ area_x *= cell * cell;
270
+ area_y *= cell * cell;
271
+ area_z *= cell * cell;
272
+
273
+ let silhouette = 0;
274
+
275
+ for (let i = 0; i < SILHOUETTE_DIRECTIONS; i++) {
276
+ sphere_fibonacci_point(a, 0, i, SILHOUETTE_DIRECTIONS);
277
+
278
+ const sx = area_x * a[0];
279
+ const sy = area_y * a[1];
280
+ const sz = area_z * a[2];
281
+
282
+ silhouette += Math.sqrt(sx * sx + sy * sy + sz * sz);
283
+ }
284
+
285
+ group.guide_shelter = shelter;
286
+ group.silhouette = silhouette / SILHOUETTE_DIRECTIONS;
287
+ group.fibre_length = fibre_length;
288
+ }
@@ -14,6 +14,8 @@
14
14
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
15
15
  * @property {number} [width] metres, for curves that carry no widths
16
16
  * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
17
+ * @property {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air
18
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
17
19
  */
18
20
  /**
19
21
  * Whether `n` is `2^k + 1` for some `k ≥ 0`, within what a group may hold.
@@ -42,13 +44,14 @@ export function groom_point_count_for(curves: GroomCurves, tolerance: number): n
42
44
  /**
43
45
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
44
46
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
45
- * from what was quantized, and the guides chosen from it (`groom_build_guides`).
47
+ * from what was quantized, the guides chosen from it (`groom_build_guides`), and how the hair shelters itself from
48
+ * the air worked out for them (`groom_bake_shelter`).
46
49
  *
47
50
  * @param {GroomCurves} curves
48
51
  * @param {GroomBuildOptions} options
49
52
  * @returns {GroomGroup}
50
53
  */
51
- export function groom_build_group(curves: GroomCurves, { name, point_count, width, guide_tolerance }: GroomBuildOptions): GroomGroup;
54
+ export function groom_build_group(curves: GroomCurves, { name, point_count, width, guide_tolerance, solid }: GroomBuildOptions): GroomGroup;
52
55
  /**
53
56
  * Curves as an importer or a generator hands them over: any number of points a curve.
54
57
  */
@@ -85,6 +88,11 @@ export type GroomBuildOptions = {
85
88
  * metres: how far a strand strays from the guide it follows (`groom_build_guides`)
86
89
  */
87
90
  guide_tolerance?: number;
91
+ /**
92
+ * what the air
93
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
94
+ */
95
+ solid?: import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D | null;
88
96
  };
89
97
  import { GroomGroup } from "./Groom.js";
90
98
  //# sourceMappingURL=groom_build_group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;GAQG;AACH,0CAJW,WAAW,iDACX,iBAAiB,GACf,UAAU,CAwItB;;;;;;;;eApZa,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;sBACN,MAAM;;2BArBb,YAAY"}
1
+ {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;;GASG;AACH,0CAJW,WAAW,wDACX,iBAAiB,GACf,UAAU,CA0ItB;;;;;;;;eAzZa,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;sBACN,MAAM;;;;;YACN,OAAO,gDAAgD,EAAE,eAAe,GAAC,IAAI;;2BAvBpF,YAAY"}
@@ -6,6 +6,7 @@ import {
6
6
  GROOM_POINT_WORDS,
7
7
  GroomGroup
8
8
  } from "./Groom.js";
9
+ import { groom_bake_shelter } from "./groom_bake_shelter.js";
9
10
  import { groom_build_guides, GROOM_GUIDE_DEFAULT_TOLERANCE } from "./groom_build_guides.js";
10
11
  import { groom_rank_order } from "./groom_rank_order.js";
11
12
  import { groom_root_spacing } from "./groom_root_spacing.js";
@@ -27,6 +28,8 @@ import { groom_root_spacing } from "./groom_root_spacing.js";
27
28
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
28
29
  * @property {number} [width] metres, for curves that carry no widths
29
30
  * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
31
+ * @property {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air
32
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
30
33
  */
31
34
 
32
35
  /**
@@ -278,7 +281,8 @@ function sample_at(positions, lengths, first, count, s, out, out_offset) {
278
281
  /**
279
282
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
280
283
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
281
- * from what was quantized, and the guides chosen from it (`groom_build_guides`).
284
+ * from what was quantized, the guides chosen from it (`groom_build_guides`), and how the hair shelters itself from
285
+ * the air worked out for them (`groom_bake_shelter`).
282
286
  *
283
287
  * @param {GroomCurves} curves
284
288
  * @param {GroomBuildOptions} options
@@ -288,7 +292,8 @@ export function groom_build_group(curves, {
288
292
  name = "",
289
293
  point_count,
290
294
  width = 70e-6,
291
- guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE
295
+ guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE,
296
+ solid = null
292
297
  }) {
293
298
  assert.ok(groom_point_count_is_valid(point_count), `point_count ${point_count} is not 2^k + 1 within ${GROOM_POINT_COUNT_MAX}`);
294
299
 
@@ -416,6 +421,7 @@ export function groom_build_group(curves, {
416
421
  group.root_spacing = groom_root_spacing(group);
417
422
 
418
423
  groom_build_guides(group, guide_tolerance);
424
+ groom_bake_shelter(group, solid);
419
425
 
420
426
  return group;
421
427
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GPUHairSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/GPUHairSystem.js"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"GPUHairSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/GPUHairSystem.js"],"names":[],"mappings":"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"}
@@ -1,7 +1,7 @@
1
1
  import { assert } from "../../../core/assert.js";
2
2
  import { ALLOCATOR_NO_SPACE } from "../../../core/binary/allocator/OffsetAllocator.js";
3
3
  import { groom_bind_to_mesh, groom_mesh_binder } from "../../../engine/graphics/hair/groom_bind_to_mesh.js";
4
- import { GROOM_POINT_WORDS } from "../../../engine/graphics/hair/Groom.js";
4
+ import { GROOM_POINT_WORDS, GROOM_SHELTER_WORDS } from "../../../engine/graphics/hair/Groom.js";
5
5
  import { TextureViewDescriptor } from "../../descriptor/texture/TextureViewDescriptor.js";
6
6
  import { BufferResourceDescriptor } from "../../device/graph/BufferResourceDescriptor.js";
7
7
  import { TextureResourceDescriptor } from "../../device/graph/TextureResourceDescriptor.js";
@@ -56,6 +56,7 @@ import {
56
56
  HAIR_BINDING_NONE,
57
57
  HAIR_COLLIDER_LIMIT,
58
58
  HAIR_COLLIDER_WORDS,
59
+ HAIR_FIBRE_DENSITY,
59
60
  hair_frame_steps,
60
61
  HAIR_FRAME_STEPS_BLEND,
61
62
  HAIR_FRAME_STEPS_COUNT,
@@ -523,6 +524,8 @@ export class GPUHairSystem {
523
524
  meshlet_base: 0,
524
525
  bindings: 0,
525
526
  roots: 0,
527
+ body_diameter: 0,
528
+ body_mass: 0,
526
529
  };
527
530
 
528
531
  #view_words = new ArrayBuffer(HAIR_VIEW_STRUCT.size);
@@ -1778,6 +1781,14 @@ export class GPUHairSystem {
1778
1781
 
1779
1782
  record.guide_length_max = length_max;
1780
1783
 
1784
+ // the group as one body in the wind's way: a cylinder across the disc of its silhouette, with its fibres' mass
1785
+ const silhouette = group.silhouette;
1786
+ const body_diameter = Math.sqrt(4 * silhouette / Math.PI);
1787
+ const fibre_mass = HAIR_FIBRE_DENSITY * Math.PI / 4 * group.width_mean * group.width_mean * group.fibre_length;
1788
+
1789
+ record.body_diameter = body_diameter;
1790
+ record.body_mass = silhouette > 0 ? fibre_mass * body_diameter / silhouette : 0;
1791
+
1781
1792
  const dynamics = context.dynamics;
1782
1793
  const state = dynamics === null ? null : context.states[g];
1783
1794
 
@@ -1822,8 +1833,13 @@ export class GPUHairSystem {
1822
1833
  for (let g = 0; g < groups.length; g++) {
1823
1834
  const group = groups[g];
1824
1835
 
1836
+ assert.equal(
1837
+ group.guide_shelter.length, group.guide_count * group.guide_point_count * GROOM_SHELTER_WORDS,
1838
+ 'the group carries its shelter (groom_bake_shelter)'
1839
+ );
1840
+
1825
1841
  words += group.strand_count * group.point_count * GROOM_POINT_WORDS + group.strand_count
1826
- + group.guide_count * HAIR_GUIDE_RECORD_WORDS;
1842
+ + group.guide_count * HAIR_GUIDE_RECORD_WORDS + group.guide_shelter.length;
1827
1843
  }
1828
1844
 
1829
1845
  const run = this.#pool.allocate(words);
@@ -1874,6 +1890,15 @@ export class GPUHairSystem {
1874
1890
  }
1875
1891
 
1876
1892
  at += guides.length;
1893
+
1894
+ // the guides' shelter follows their records
1895
+ const shelter = group.guide_shelter;
1896
+
1897
+ if (shelter.length > 0) {
1898
+ this.#pool.write(at, new Uint32Array(shelter.buffer, shelter.byteOffset, shelter.length), shelter.length);
1899
+ }
1900
+
1901
+ at += shelter.length;
1877
1902
  }
1878
1903
 
1879
1904
  this.#grooms.set(groom, entry);
@@ -1 +1 @@
1
- {"version":3,"file":"HAIR_DATABASE_SPEC.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/HAIR_DATABASE_SPEC.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,gDAmE0B;AAE1B,oCAA4C;AAE5C,gDAAwD;AAExD,mDAAoD;AAEpD;;;GAGG;AACH,uDAEmB;AAYnB,oHAAoF;6BAnGvD,gCAAgC;sCAHvB,0CAA0C"}
1
+ {"version":3,"file":"HAIR_DATABASE_SPEC.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/HAIR_DATABASE_SPEC.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,gDAuE0B;AAE1B,oCAA4C;AAE5C,gDAAwD;AAExD,mDAAoD;AAEpD;;;GAGG;AACH,uDAEmB;AAYnB,oHAAoF;6BAvGvD,gCAAgC;sCAHvB,0CAA0C"}
@@ -75,6 +75,10 @@ export const HAIR_INSTANCE_STRUCT = WebGPUStruct.from({
75
75
  bindings: u32,
76
76
  /** the instance's first root frame in the guide state pool, `HAIR_ROOT_FRAME_VECTORS` a strand */
77
77
  roots: u32,
78
+ /** the group as one body in the wind's way: the diameter of the disc of its silhouette, groom metres */
79
+ body_diameter: f32,
80
+ /** that body's mass a unit length as a cylinder across the wind: its fibres' mass over its diameter, kg a metre */
81
+ body_mass: f32,
78
82
  }, "HairInstance").pack();
79
83
 
80
84
  export const HAIR_PAGE_SIZE = 16 * KILOBYTE;
@@ -12,11 +12,24 @@
12
12
  */
13
13
  export function hair_frame_steps(result: Float64Array | number[], owed: number, seconds: number): void;
14
14
  /**
15
- * The rate a node's velocity relaxes toward the air's by drag, per second: the drag of the wisp its guide stands for,
16
- * a cylinder of diameter `diameter` across the flow at relative speed `speed`, over the wisp's mass a unit length,
17
- * `k = ½ ρ C_d(Re) D |w| / μ`. The cylinder's drag coefficient is White's correlation, `C_d = 1 + 10 Re^(-2/3)`
18
- * (good to ±10% for `1 < Re < 2·10⁵`), so `k = (½ ρ D / μ)(|w| + 10 |w|^(1/3) (ρ D / μ_air)^(-2/3))`, which goes to
19
- * zero with the speed. The WGSL `hair_drag_rate` is its twin.
15
+ * The drag coefficient of a cylinder of diameter `diameter` across a flow of speed `speed`: White's correlation,
16
+ * `C_d = 1 + 10 Re^(-2/3)`, good to ±10% for `1 < Re < 2·10⁵`, and held under `Re = 1` at its value there, so that
17
+ * still air's is a number. The WGSL `hair_drag_coefficient` is its twin.
18
+ *
19
+ * @param {number} speed metres a second
20
+ * @param {number} diameter metres
21
+ * @returns {number}
22
+ */
23
+ export function hair_drag_coefficient(speed: number, diameter: number): number;
24
+ /**
25
+ * The rate a body's velocity relaxes toward the air's by drag, per second: the drag of a cylinder of diameter
26
+ * `diameter` across the flow at relative speed `speed`, over its mass a unit length, `k = ½ ρ C_d(Re) D |w| / m`.
27
+ * The cylinder's drag coefficient is White's correlation, `C_d = 1 + 10 Re^(-2/3)` (good to ±10% for
28
+ * `1 < Re < 2·10⁵`), so `k = (½ ρ D / m)(|w| + 10 |w|^(1/3) (ρ D / μ_air)^(-2/3))`, which goes to zero with the
29
+ * speed. The WGSL `hair_drag_rate` is its twin.
30
+ *
31
+ * A guide's node takes it twice (`shader_hair_simulate.js`): for a fibre of its group alone in open air, and for the
32
+ * group as one body in the wind's way, a cylinder across the disc of its silhouette with the mass of all its fibres.
20
33
  *
21
34
  * @param {number} speed metres a second
22
35
  * @param {number} diameter metres
@@ -101,7 +114,9 @@ export const HAIR_STATE_PREVIOUS_POSITION: 7;
101
114
  export const HAIR_STATE_PREVIOUS_ROTATION: 8;
102
115
  /**
103
116
  * Words of a guide's record in the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and
104
- * its length (f32 bits each, groom metres).
117
+ * its length (f32 bits each, groom metres). A group's guide records are followed by its guides' shelter
118
+ * (`GroomGroup#guide_shelter`): `GROOM_SHELTER_WORDS` depths a node (f32 bits), a guide's nodes in turn, guide after
119
+ * guide.
105
120
  * @type {number}
106
121
  */
107
122
  export const HAIR_GUIDE_RECORD_WORDS: number;
@@ -142,6 +157,12 @@ export const HAIR_AIR_VISCOSITY: number;
142
157
  * @type {number}
143
158
  */
144
159
  export const HAIR_FIBRE_DENSITY: number;
160
+ /**
161
+ * The most of its own drag in open air a fibre of a groom takes, where nothing stands between it and the wind: the
162
+ * hair about it still shares its load. A chosen value, not a derived one.
163
+ * @type {number}
164
+ */
165
+ export const HAIR_EXPOSED_DRAG_SHARE: number;
145
166
  /**
146
167
  * The share of a node's follow-the-leader correction taken back out of its parent's velocity (Müller et al. 2012's
147
168
  * `s`), which keeps the correction from feeding the velocity it was made to undo.
@@ -1 +1 @@
1
- {"version":3,"file":"HAIR_SIMULATION.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/HAIR_SIMULATION.js"],"names":[],"mappings":"AA+GA;;;;;;;;;;;GAWG;AACH,yCAJW,YAAY,GAAC,MAAM,EAAE,QACrB,MAAM,WACN,MAAM,QAehB;AAkED;;;;;;;;;;;GAWG;AACH,sCALW,MAAM,YACN,MAAM,mBACN,MAAM,GACJ,MAAM,CAOlB;AA3ND;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;GAGG;AACH,8BAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;;GAIG;AACH,sCAFU,MAAM,CAEyB;AAEzC;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC,oCAAqC;AACrC,oCAAqC;AACrC,iCAAkC;AAClC,yCAA0C;AAC1C,sCAAuC;AACvC,2CAA4C;AAC5C,2CAA4C;AAC5C,6CAA8C;AAC9C,6CAA8C;AAE9C;;;;GAIG;AACH,sCAFU,MAAM,CAEyB;AAEzC;;;;GAIG;AACH,wBAFU,MAAM,CAEgB;AAEhC,8EAA8E;AAC9E,uCAAwC;AAExC,wHAAwH;AACxH,sCAAuC;AAEvC,oGAAoG;AACpG,uCAAwC;AAExC,oGAAoG;AACpG,wCAAyC;AAEzC,wHAAwH;AACxH,uCAAwC;AA6BxC;;;;GAIG;AACH,kCAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,+BAFU,MAAM,CAEsB;AAEtC;;;GAGG;AACH,iCAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,iCAFU,MAAM,CAEuB;AAEvC;;;;GAIG;AACH,6CAFU,MAAM,CAEkC;AAElD;;;GAGG;AACH,kCAFU,MAAM,CAEsB;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,kCAFU,MAAM,CAEsB;AAEtC;;;;;GAKG;AACH,sCAFU,MAAM,CAEyB"}
1
+ {"version":3,"file":"HAIR_SIMULATION.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/HAIR_SIMULATION.js"],"names":[],"mappings":"AAiHA;;;;;;;;;;;GAWG;AACH,yCAJW,YAAY,GAAC,MAAM,EAAE,QACrB,MAAM,WACN,MAAM,QAehB;AAyED;;;;;;;;GAQG;AACH,6CAJW,MAAM,YACN,MAAM,GACJ,MAAM,CAMlB;AAED;;;;;;;;;;;;;;GAcG;AACH,sCALW,MAAM,YACN,MAAM,mBACN,MAAM,GACJ,MAAM,CAOlB;AAtPD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;GAGG;AACH,8BAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;;GAIG;AACH,sCAFU,MAAM,CAEyB;AAEzC;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC,oCAAqC;AACrC,oCAAqC;AACrC,iCAAkC;AAClC,yCAA0C;AAC1C,sCAAuC;AACvC,2CAA4C;AAC5C,2CAA4C;AAC5C,6CAA8C;AAC9C,6CAA8C;AAE9C;;;;;;GAMG;AACH,sCAFU,MAAM,CAEyB;AAEzC;;;;GAIG;AACH,wBAFU,MAAM,CAEgB;AAEhC,8EAA8E;AAC9E,uCAAwC;AAExC,wHAAwH;AACxH,sCAAuC;AAEvC,oGAAoG;AACpG,uCAAwC;AAExC,oGAAoG;AACpG,wCAAyC;AAEzC,wHAAwH;AACxH,uCAAwC;AA6BxC;;;;GAIG;AACH,kCAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,+BAFU,MAAM,CAEsB;AAEtC;;;GAGG;AACH,iCAFU,MAAM,CAE0B;AAE1C;;;GAGG;AACH,iCAFU,MAAM,CAEuB;AAEvC;;;;GAIG;AACH,sCAFU,MAAM,CAE2B;AAE3C;;;;GAIG;AACH,6CAFU,MAAM,CAEkC;AAElD;;;GAGG;AACH,kCAFU,MAAM,CAEsB;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,kCAFU,MAAM,CAEsB;AAEtC;;;;;GAKG;AACH,sCAFU,MAAM,CAEyB"}
@@ -82,7 +82,9 @@ export const HAIR_STATE_PREVIOUS_ROTATION = 8;
82
82
 
83
83
  /**
84
84
  * Words of a guide's record in the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and
85
- * its length (f32 bits each, groom metres).
85
+ * its length (f32 bits each, groom metres). A group's guide records are followed by its guides' shelter
86
+ * (`GroomGroup#guide_shelter`): `GROOM_SHELTER_WORDS` depths a node (f32 bits), a guide's nodes in turn, guide after
87
+ * guide.
86
88
  * @type {number}
87
89
  */
88
90
  export const HAIR_GUIDE_RECORD_WORDS = 4;
@@ -161,6 +163,13 @@ export const HAIR_AIR_VISCOSITY = 1.81e-5;
161
163
  */
162
164
  export const HAIR_FIBRE_DENSITY = 1300;
163
165
 
166
+ /**
167
+ * The most of its own drag in open air a fibre of a groom takes, where nothing stands between it and the wind: the
168
+ * hair about it still shares its load. A chosen value, not a derived one.
169
+ * @type {number}
170
+ */
171
+ export const HAIR_EXPOSED_DRAG_SHARE = 0.3;
172
+
164
173
  /**
165
174
  * The share of a node's follow-the-leader correction taken back out of its parent's velocity (Müller et al. 2012's
166
175
  * `s`), which keeps the correction from feeding the velocity it was made to undo.
@@ -201,11 +210,29 @@ export const HAIR_COLLIDER_WORDS = 24;
201
210
  export const HAIR_GUIDE_BOUNDS_WORDS = 8;
202
211
 
203
212
  /**
204
- * The rate a node's velocity relaxes toward the air's by drag, per second: the drag of the wisp its guide stands for,
205
- * a cylinder of diameter `diameter` across the flow at relative speed `speed`, over the wisp's mass a unit length,
206
- * `k = ½ ρ C_d(Re) D |w| / μ`. The cylinder's drag coefficient is White's correlation, `C_d = 1 + 10 Re^(-2/3)`
207
- * (good to ±10% for `1 < Re < 2·10⁵`), so `k = (½ ρ D / μ)(|w| + 10 |w|^(1/3) (ρ D / μ_air)^(-2/3))`, which goes to
208
- * zero with the speed. The WGSL `hair_drag_rate` is its twin.
213
+ * The drag coefficient of a cylinder of diameter `diameter` across a flow of speed `speed`: White's correlation,
214
+ * `C_d = 1 + 10 Re^(-2/3)`, good to ±10% for `1 < Re < 2·10⁵`, and held under `Re = 1` at its value there, so that
215
+ * still air's is a number. The WGSL `hair_drag_coefficient` is its twin.
216
+ *
217
+ * @param {number} speed metres a second
218
+ * @param {number} diameter metres
219
+ * @returns {number}
220
+ */
221
+ export function hair_drag_coefficient(speed, diameter) {
222
+ const reynolds = HAIR_AIR_DENSITY * speed * diameter / HAIR_AIR_VISCOSITY;
223
+
224
+ return 1 + 10 * Math.pow(Math.max(reynolds, 1), -2 / 3);
225
+ }
226
+
227
+ /**
228
+ * The rate a body's velocity relaxes toward the air's by drag, per second: the drag of a cylinder of diameter
229
+ * `diameter` across the flow at relative speed `speed`, over its mass a unit length, `k = ½ ρ C_d(Re) D |w| / m`.
230
+ * The cylinder's drag coefficient is White's correlation, `C_d = 1 + 10 Re^(-2/3)` (good to ±10% for
231
+ * `1 < Re < 2·10⁵`), so `k = (½ ρ D / m)(|w| + 10 |w|^(1/3) (ρ D / μ_air)^(-2/3))`, which goes to zero with the
232
+ * speed. The WGSL `hair_drag_rate` is its twin.
233
+ *
234
+ * A guide's node takes it twice (`shader_hair_simulate.js`): for a fibre of its group alone in open air, and for the
235
+ * group as one body in the wind's way, a cylinder across the disc of its silhouette with the mass of all its fibres.
209
236
  *
210
237
  * @param {number} speed metres a second
211
238
  * @param {number} diameter metres
@@ -18,7 +18,9 @@ export const HAIR_GUIDE_STATE_RESOURCE: ShaderResourceDescriptor;
18
18
  * fn hair_state_index(instance: HairInstance, plane: u32, node: u32, guide: u32) -> u32
19
19
  * fn hair_guide_record(instance: HairInstance, guide: u32) -> vec4<u32>
20
20
  * fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32>
21
+ * fn hair_drag_coefficient(speed: f32, diameter: f32) -> f32
21
22
  * fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32
23
+ * fn hair_guide_reach(instance: HairInstance, node: u32, guide: u32, upwind: vec3<f32>, half_drag: f32) -> f32
22
24
  * ```
23
25
  *
24
26
  * `hair_strand_frame` is what carries a strand's rest points into the world: its root frame (`shader_hair_roots.js`)
@@ -27,8 +29,13 @@ export const HAIR_GUIDE_STATE_RESOURCE: ShaderResourceDescriptor;
27
29
  * frame's step holds another tenant's nodes, or none, and its strands ride the entity until the next step lays it.
28
30
  * Reads the state's header. `hair_state_index` is a vector of the state pool, node-interleaved. `hair_guide_record` is a guide's four words in
29
31
  * the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and its length (f32 bits).
30
- * `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_rate` is `hair_drag_rate`'s twin
31
- * (`HAIR_SIMULATION.js`): the rate a node's velocity relaxes toward the air's.
32
+ * `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_coefficient` and `hair_drag_rate`
33
+ * are their namesakes' twins (`HAIR_SIMULATION.js`): a cylinder's drag coefficient, and the rate its velocity relaxes
34
+ * toward the air's. `hair_guide_reach` is the share of a wind that reaches a guide's node through the hair of its
35
+ * group, from the node's shelter (`GroomGroup#guide_shelter`): `upwind` is where the wind comes from, a unit vector
36
+ * in the groom's rest space, and `half_drag` half a fibre's drag coefficient at the wind's speed. Each axis gives
37
+ * `e^(−half_drag · depth)` for the depth on the side the wind comes from, and the three are weighed by the squares of
38
+ * `upwind`'s parts; an `upwind` of no length gives none.
32
39
  *
33
40
  * @type {CodeChunk}
34
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_hair_guide.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_guide.js"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,8BAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,wCAFU,wBAAwB,CAE2F;AAE7H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+BAFU,SAAS,CAwDhB;AAKH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,sCAFU,SAAS,CAyChB;yCA7KsC,gDAAgD;0BAD/D,iCAAiC"}
1
+ {"version":3,"file":"chunk_hair_guide.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_guide.js"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,8BAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,wCAFU,wBAAwB,CAE2F;AAE7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,+BAFU,SAAS,CA4EhB;AAKH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,sCAFU,SAAS,CAyChB;yCAxMsC,gDAAgD;0BAD/D,iCAAiC"}
@@ -1,3 +1,4 @@
1
+ import { GROOM_SHELTER_WORDS } from "../../../engine/graphics/hair/Groom.js";
1
2
  import { chunk_quat_rotate_v3 } from "../shader/chunk/geometry/quaternion/chunk_v3_apply_quat.js";
2
3
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
3
4
  import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
@@ -41,7 +42,9 @@ export const HAIR_GUIDE_STATE_RESOURCE = ShaderResourceDescriptor.storageBuffer(
41
42
  * fn hair_state_index(instance: HairInstance, plane: u32, node: u32, guide: u32) -> u32
42
43
  * fn hair_guide_record(instance: HairInstance, guide: u32) -> vec4<u32>
43
44
  * fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32>
45
+ * fn hair_drag_coefficient(speed: f32, diameter: f32) -> f32
44
46
  * fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32
47
+ * fn hair_guide_reach(instance: HairInstance, node: u32, guide: u32, upwind: vec3<f32>, half_drag: f32) -> f32
45
48
  * ```
46
49
  *
47
50
  * `hair_strand_frame` is what carries a strand's rest points into the world: its root frame (`shader_hair_roots.js`)
@@ -50,8 +53,13 @@ export const HAIR_GUIDE_STATE_RESOURCE = ShaderResourceDescriptor.storageBuffer(
50
53
  * frame's step holds another tenant's nodes, or none, and its strands ride the entity until the next step lays it.
51
54
  * Reads the state's header. `hair_state_index` is a vector of the state pool, node-interleaved. `hair_guide_record` is a guide's four words in
52
55
  * the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and its length (f32 bits).
53
- * `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_rate` is `hair_drag_rate`'s twin
54
- * (`HAIR_SIMULATION.js`): the rate a node's velocity relaxes toward the air's.
56
+ * `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_coefficient` and `hair_drag_rate`
57
+ * are their namesakes' twins (`HAIR_SIMULATION.js`): a cylinder's drag coefficient, and the rate its velocity relaxes
58
+ * toward the air's. `hair_guide_reach` is the share of a wind that reaches a guide's node through the hair of its
59
+ * group, from the node's shelter (`GroomGroup#guide_shelter`): `upwind` is where the wind comes from, a unit vector
60
+ * in the groom's rest space, and `half_drag` half a fibre's drag coefficient at the wind's speed. Each axis gives
61
+ * `e^(−half_drag · depth)` for the depth on the side the wind comes from, and the three are weighed by the squares of
62
+ * `upwind`'s parts; an `upwind` of no length gives none.
55
63
  *
56
64
  * @type {CodeChunk}
57
65
  */
@@ -101,6 +109,26 @@ fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32> {
101
109
  return normalize(mix(a, b * side, t));
102
110
  }
103
111
 
112
+ fn hair_drag_coefficient(speed: f32, diameter: f32) -> f32 {
113
+ let reynolds = ${HAIR_AIR_DENSITY} * speed * diameter / ${HAIR_AIR_VISCOSITY};
114
+
115
+ return 1.0 + 10.0 * pow(max(reynolds, 1.0), -2.0 / 3.0);
116
+ }
117
+
118
+ fn hair_guide_reach(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, node: u32, guide: u32, upwind: vec3<f32>, half_drag: f32) -> f32 {
119
+ let at = instance.guides + instance.guide_count * ${HAIR_GUIDE_RECORD_WORDS}u
120
+ + (guide * instance.guide_point_count + node) * ${GROOM_SHELTER_WORDS}u;
121
+
122
+ // each axis's depth on the side the wind comes from
123
+ let depth = vec3<f32>(
124
+ bitcast<f32>(hair_grooms[at + select(0u, 1u, upwind.x < 0.0)]),
125
+ bitcast<f32>(hair_grooms[at + select(2u, 3u, upwind.y < 0.0)]),
126
+ bitcast<f32>(hair_grooms[at + select(4u, 5u, upwind.z < 0.0)]),
127
+ );
128
+
129
+ return dot(upwind * upwind, exp(-half_drag * depth));
130
+ }
131
+
104
132
  fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32 {
105
133
  let reynolds_per_speed = ${HAIR_AIR_DENSITY} * diameter / ${HAIR_AIR_VISCOSITY};
106
134
 
@@ -32,8 +32,11 @@ export const HAIR_SIMULATE_SETTINGS: WebGPUStruct;
32
32
  * carried. Each step, from the node after the root to the tip, a node:
33
33
  *
34
34
  * - **predicts**: its velocity loses `1 − e^(−damping·h)`, gains gravity, and relaxes toward the air's
35
- * (`wind_field_sample` at the node) as `v ← u + (v − u) e^(−k h)`, `k` the wisp's drag rate
36
- * (`hair_drag_rate`); it moves by the velocity;
35
+ * (`wind_field_sample` at the node) as `v ← u + (v − u) e^(−k h)`; it moves by the velocity. The drag rate `k`
36
+ * lies between two (`hair_drag_rate`): at the least the node's even share of the drag of its group as one body in
37
+ * the wind's way, and at the most `HAIR_EXPOSED_DRAG_SHARE` of a fibre's own in open air, by the share of the wind
38
+ * that reaches the node through the hair upwind of it (`hair_guide_reach`, from the groom's baked shelter); never
39
+ * more than the fibre's own;
37
40
  * - is pulled toward its rest place in the entity's frame (**global shape**) at a rate that falls from
38
41
  * `global_shape_rate` at the root to nothing at `global_shape_range` of the length, and toward its rest
39
42
  * direction turned by its parent's frame (**local shape**) at `local_shape_rate`, each a share
@@ -1 +1 @@
1
- {"version":3,"file":"shader_hair_simulate.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_simulate.js"],"names":[],"mappings":";AAuDA;;;;;;;;GAQG;AACH,yCAFU,aAAa,CAkEpB;AAEH,uDAK+B;AAU/B;;;;;;GAMG;AACH,yCAFU,aAAa,CAqCpB;AAEH,kDAe2B;AAuY3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,mCAFU,aAAa,CAMpB;8BA/mB2B,4BAA4B;6BAK7B,gCAAgC"}
1
+ {"version":3,"file":"shader_hair_simulate.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_simulate.js"],"names":[],"mappings":";AAwDA;;;;;;;;GAQG;AACH,yCAFU,aAAa,CAkEpB;AAEH,uDAK+B;AAU/B;;;;;;GAMG;AACH,yCAFU,aAAa,CAqCpB;AAEH,kDAe2B;AAqZ3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,mCAFU,aAAa,CAMpB;8BAjoB2B,4BAA4B;6BAK7B,gCAAgC"}
@@ -25,6 +25,7 @@ import {
25
25
  HAIR_BINDING_NONE,
26
26
  HAIR_COLLIDER_LIMIT,
27
27
  HAIR_COLLIDER_WORDS,
28
+ HAIR_EXPOSED_DRAG_SHARE,
28
29
  HAIR_FIBRE_DENSITY,
29
30
  HAIR_FOLLOW_THE_LEADER_DAMPING,
30
31
  HAIR_GUIDE_BOUNDS_WORDS,
@@ -341,7 +342,10 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
341
342
  let scale = max(length(now[0]), max(length(now[1]), length(now[2])));
342
343
  let diameter = bitcast<f32>(record.z) * scale;
343
344
  let width = instance.width_mean * scale;
344
- let mass = f32(record.y) * ${HAIR_FIBRE_DENSITY}.0 * 0.78539816 * width * width;
345
+ // a fibre's mass a unit length; and the group as one body in the wind's way, as the entity scales it
346
+ let fibre_mass = ${HAIR_FIBRE_DENSITY}.0 * 0.78539816 * width * width;
347
+ let body_diameter = instance.body_diameter * scale;
348
+ let body_mass = instance.body_mass * scale * scale;
345
349
  let radius = 0.5 * diameter + instance.thickness;
346
350
 
347
351
  const IDENTITY = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@@ -451,13 +455,24 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
451
455
  let x = hair_guide_state[hair_state_index(instance, ${HAIR_STATE_SOLVED_POSITION}u, i, guide)].xyz;
452
456
  var v = hair_guide_state[hair_state_index(instance, ${HAIR_STATE_VELOCITY}u, i, guide)].xyz;
453
457
 
454
- // predict: damping and gravity, then the drag of the wisp relaxing the velocity toward the air's
458
+ // predict: damping and gravity, then drag relaxing the velocity toward the air's
455
459
  v = v * keep_velocity + gravity * h;
456
460
 
457
461
  let air = wind_field_sample(anchor + x);
458
462
  let relative = v - air;
463
+ let speed = length(relative);
459
464
 
460
- v = air + relative * exp(-hair_drag_rate(length(relative), diameter, mass) * h);
465
+ // a fibre's own drag in open air, and its even share of the group's as one body: never more than its own
466
+ let own = hair_drag_rate(speed, width, fibre_mass);
467
+ let even = min(own, hair_drag_rate(speed, body_diameter, body_mass));
468
+
469
+ // what of the wind reaches the node through the hair upwind of it, in the groom's rest space
470
+ let upwind = quat_rotate_v3(quat_conjugate(turn), relative / max(speed, 1e-30));
471
+ let exposed = hair_guide_reach(instance, i, guide, upwind, 0.5 * hair_drag_coefficient(speed, width));
472
+
473
+ let drag = mix(even, max(even, ${HAIR_EXPOSED_DRAG_SHARE} * own), exposed);
474
+
475
+ v = air + relative * exp(-drag * h);
461
476
 
462
477
  var p = x + v * h;
463
478
 
@@ -606,8 +621,11 @@ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocatio
606
621
  * carried. Each step, from the node after the root to the tip, a node:
607
622
  *
608
623
  * - **predicts**: its velocity loses `1 − e^(−damping·h)`, gains gravity, and relaxes toward the air's
609
- * (`wind_field_sample` at the node) as `v ← u + (v − u) e^(−k h)`, `k` the wisp's drag rate
610
- * (`hair_drag_rate`); it moves by the velocity;
624
+ * (`wind_field_sample` at the node) as `v ← u + (v − u) e^(−k h)`; it moves by the velocity. The drag rate `k`
625
+ * lies between two (`hair_drag_rate`): at the least the node's even share of the drag of its group as one body in
626
+ * the wind's way, and at the most `HAIR_EXPOSED_DRAG_SHARE` of a fibre's own in open air, by the share of the wind
627
+ * that reaches the node through the hair upwind of it (`hair_guide_reach`, from the groom's baked shelter); never
628
+ * more than the fibre's own;
611
629
  * - is pulled toward its rest place in the entity's frame (**global shape**) at a rate that falls from
612
630
  * `global_shape_rate` at the root to nothing at `global_shape_range` of the length, and toward its rest
613
631
  * direction turned by its parent's frame (**local shape**) at `local_shape_rate`, each a share