@woosh/meep-engine 3.78.4 → 3.79.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 (121) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/package.json +1 -1
  3. package/src/engine/asset/GameAssetType.d.ts +2 -0
  4. package/src/engine/asset/GameAssetType.js +10 -0
  5. package/src/engine/asset/guessAssetType.d.ts.map +1 -1
  6. package/src/engine/asset/guessAssetType.js +4 -0
  7. package/src/engine/asset/load_model_scene_bundle.d.ts +1 -1
  8. package/src/engine/asset/load_model_scene_bundle.js +2 -2
  9. package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts +42 -0
  10. package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts.map +1 -0
  11. package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.js +83 -0
  12. package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts +36 -0
  13. package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts.map +1 -0
  14. package/src/engine/asset/loaders/MTFTextureAssetLoader.js +78 -0
  15. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts +6 -1
  16. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts.map +1 -1
  17. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +8 -2
  18. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  19. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  20. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
  21. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  22. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +33 -0
  23. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -0
  24. package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +196 -0
  25. package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts +25 -0
  26. package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts.map +1 -0
  27. package/src/shade/renderer/animation/SkinSerializationAdapter.js +85 -0
  28. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  29. package/src/shade/renderer/hair/GPUHairSystem.js +16 -7
  30. package/src/shade/renderer/hair/HAIR.d.ts +5 -3
  31. package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
  32. package/src/shade/renderer/hair/HAIR.js +6 -4
  33. package/src/shade/renderer/hair/hair_shadow_draw.d.ts +10 -10
  34. package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -1
  35. package/src/shade/renderer/hair/hair_shadow_draw.js +21 -17
  36. package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
  37. package/src/shade/renderer/hair/shader_hair_cull.js +6 -2
  38. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +5 -4
  39. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -1
  40. package/src/shade/renderer/hair/shader_hair_shadow_list.js +10 -12
  41. package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts +38 -0
  42. package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts.map +1 -0
  43. package/src/shade/renderer/loader/SceneNodeSerializationAdapter.js +198 -0
  44. package/src/shade/renderer/loader/mtf/MTFTexture.d.ts +88 -0
  45. package/src/shade/renderer/loader/mtf/MTFTexture.d.ts.map +1 -0
  46. package/src/shade/renderer/loader/mtf/MTFTexture.js +159 -0
  47. package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts +30 -0
  48. package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts.map +1 -0
  49. package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.js +136 -0
  50. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts +7 -0
  51. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts.map +1 -0
  52. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.js +6 -0
  53. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +8 -0
  54. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -0
  55. package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +7 -0
  56. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts +7 -0
  57. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts.map +1 -0
  58. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.js +6 -0
  59. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts +7 -0
  60. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts.map +1 -0
  61. package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.js +6 -0
  62. package/src/shade/renderer/loader/mtf/load_mtf.d.ts +41 -0
  63. package/src/shade/renderer/loader/mtf/load_mtf.d.ts.map +1 -0
  64. package/src/shade/renderer/loader/mtf/load_mtf.js +73 -0
  65. package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts +19 -0
  66. package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts.map +1 -0
  67. package/src/shade/renderer/loader/mtf/mtf_bundle_textures.js +57 -0
  68. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +9 -0
  69. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -0
  70. package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +78 -0
  71. package/src/shade/renderer/loader/mtf/mtf_export.d.ts +45 -0
  72. package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -0
  73. package/src/shade/renderer/loader/mtf/mtf_export.js +161 -0
  74. package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts +9 -0
  75. package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts.map +1 -0
  76. package/src/shade/renderer/loader/mtf/mtf_is_texture.js +12 -0
  77. package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts +24 -0
  78. package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts.map +1 -0
  79. package/src/shade/renderer/loader/mtf/mtf_read_collection.js +37 -0
  80. package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +27 -0
  81. package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -0
  82. package/src/shade/renderer/loader/mtf/mtf_read_scene.js +121 -0
  83. package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts +18 -0
  84. package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts.map +1 -0
  85. package/src/shade/renderer/loader/mtf/mtf_read_textures.js +51 -0
  86. package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts +21 -0
  87. package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts.map +1 -0
  88. package/src/shade/renderer/loader/mtf/mtf_resolve_uri.js +98 -0
  89. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +25 -0
  90. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -0
  91. package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +51 -0
  92. package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts +20 -0
  93. package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts.map +1 -0
  94. package/src/shade/renderer/loader/mtf/mtf_texture_read.js +80 -0
  95. package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts +24 -0
  96. package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts.map +1 -0
  97. package/src/shade/renderer/loader/mtf/mtf_texture_select.js +42 -0
  98. package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts +31 -0
  99. package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts.map +1 -0
  100. package/src/shade/renderer/loader/mtf/mtf_texture_write.js +87 -0
  101. package/src/shade/renderer/loader/mtf/mtf_write.d.ts +36 -0
  102. package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -0
  103. package/src/shade/renderer/loader/mtf/mtf_write.js +161 -0
  104. package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts +39 -0
  105. package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts.map +1 -0
  106. package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.js +207 -0
  107. package/src/shade/renderer/scene/optimization/source_to_sampler2d.d.ts.map +1 -1
  108. package/src/shade/renderer/scene/optimization/source_to_sampler2d.js +3 -1
  109. package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.d.ts +5 -5
  110. package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.js +5 -5
  111. package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
  112. package/src/shade/renderer/scene/serialization/deserialize_scene.js +491 -528
  113. package/src/shade/renderer/scene/serialization/serialize_scene.d.ts +0 -10
  114. package/src/shade/renderer/scene/serialization/serialize_scene.d.ts.map +1 -1
  115. package/src/shade/renderer/scene/serialization/serialize_scene.js +15 -71
  116. package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts +11 -0
  117. package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts.map +1 -0
  118. package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.js +14 -0
  119. package/src/shade/renderer/texture/texture_role_image_quality.d.ts +10 -0
  120. package/src/shade/renderer/texture/texture_role_image_quality.d.ts.map +1 -0
  121. package/src/shade/renderer/texture/texture_role_image_quality.js +29 -0
@@ -0,0 +1,196 @@
1
+ import {
2
+ deserialize_animation_curve,
3
+ serialize_animation_curve
4
+ } from "../../../engine/animation/curve/animation_curve_binary_codec.js";
5
+ import { BinaryClassSerializationAdapter } from "../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
6
+ import { ShadeAnimationChannel } from "./ShadeAnimationChannel.js";
7
+ import { ShadeAnimationClip } from "./ShadeAnimationClip.js";
8
+
9
+ /**
10
+ * @typedef {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
11
+ * @typedef {import("../../../engine/animation/curve/AnimationCurve.js").AnimationCurve} AnimationCurve
12
+ */
13
+
14
+ /**
15
+ * Written in place of a curve's index, for a component that is not animated.
16
+ *
17
+ * @type {number}
18
+ */
19
+ const NO_CURVE = 0xFFFFFFFF;
20
+
21
+ /**
22
+ * Give a curve a place in the clip's table the first time it is met.
23
+ *
24
+ * @param {Map<AnimationCurve, number>} indices
25
+ * @param {AnimationCurve[]} table
26
+ * @param {AnimationCurve|undefined} curve
27
+ */
28
+ function collect_curve(indices, table, curve) {
29
+ if (curve === undefined || curve === null || indices.has(curve)) {
30
+ return;
31
+ }
32
+
33
+ indices.set(curve, table.length);
34
+ table.push(curve);
35
+ }
36
+
37
+ /**
38
+ * @param {BinaryBuffer} buffer
39
+ * @param {Map<AnimationCurve, number>} indices
40
+ * @param {AnimationCurve|undefined} curve
41
+ */
42
+ function write_curve_index(buffer, indices, curve) {
43
+ if (curve === undefined || curve === null) {
44
+ buffer.writeUint32(NO_CURVE);
45
+ } else {
46
+ buffer.writeUint32(indices.get(curve));
47
+ }
48
+ }
49
+
50
+ /**
51
+ * @param {BinaryBuffer} buffer
52
+ * @param {AnimationCurve[]} table
53
+ * @param {string} clip_name named if the index is outside the table
54
+ * @returns {AnimationCurve|undefined}
55
+ */
56
+ function read_curve_index(buffer, table, clip_name) {
57
+ const index = buffer.readUint32();
58
+
59
+ if (index === NO_CURVE) {
60
+ return undefined;
61
+ }
62
+
63
+ if (index >= table.length) {
64
+ throw new Error(`clip '${clip_name}' names curve ${index}, and it holds ${table.length}`);
65
+ }
66
+
67
+ return table[index];
68
+ }
69
+
70
+ /**
71
+ * A {@link ShadeAnimationClip} on disk, as a loader's bundle holds it: a channel's target is a place in the
72
+ * bundle's nodes.
73
+ *
74
+ * <pre>
75
+ * UTF8 name
76
+ * UintVar curve count
77
+ * curves each as {@link serialize_animation_curve} writes one: a key count, then time, value, in tangent
78
+ * and out tangent of every key as float32s
79
+ * UintVar channel count
80
+ * channels each: u32 target, u8 property ({@link Node3DProperty}), then u32 x 4 for x, y, z and w: a curve's
81
+ * place in this clip's curves, or 0xFFFFFFFF for a component that is not animated
82
+ * </pre>
83
+ *
84
+ * A curve is in the record once however many components it drives, and a clip read back shares exactly the
85
+ * curves the clip written did: a uniform scale is one curve under three axes, and the animation manager uploads a
86
+ * curve once by which object it is.
87
+ *
88
+ * @extends BinaryClassSerializationAdapter<ShadeAnimationClip>
89
+ *
90
+ * @author Alex Goldring
91
+ * @copyright Company Named Limited (c) 2026
92
+ */
93
+ export class ShadeAnimationClipSerializationAdapter extends BinaryClassSerializationAdapter {
94
+ klass = ShadeAnimationClip;
95
+ version = 0;
96
+
97
+ /**
98
+ * Where each curve of the clip being written is in its table. Held between calls so writing a clip allocates
99
+ * no map.
100
+ *
101
+ * @type {Map<AnimationCurve, number>}
102
+ */
103
+ #indices = new Map();
104
+
105
+ /**
106
+ * @param {BinaryBuffer} buffer
107
+ * @param {ShadeAnimationClip} value
108
+ */
109
+ serialize(buffer, value) {
110
+ const channels = value.channels;
111
+ const channel_count = channels.length;
112
+
113
+ const indices = this.#indices;
114
+
115
+ // a clip that could not be written leaves its curves here, and they are not this clip's
116
+ indices.clear();
117
+
118
+ /** @type {AnimationCurve[]} */
119
+ const table = [];
120
+
121
+ for (let i = 0; i < channel_count; i++) {
122
+ const curves = channels[i].curves;
123
+
124
+ collect_curve(indices, table, curves.x);
125
+ collect_curve(indices, table, curves.y);
126
+ collect_curve(indices, table, curves.z);
127
+ collect_curve(indices, table, curves.w);
128
+ }
129
+
130
+ buffer.writeUTF8String(value.name);
131
+
132
+ buffer.writeUintVar(table.length);
133
+
134
+ for (let i = 0; i < table.length; i++) {
135
+ serialize_animation_curve(buffer, table[i]);
136
+ }
137
+
138
+ buffer.writeUintVar(channel_count);
139
+
140
+ for (let i = 0; i < channel_count; i++) {
141
+ const channel = channels[i];
142
+ const curves = channel.curves;
143
+
144
+ buffer.writeUint32(channel.target);
145
+ buffer.writeUint8(channel.property);
146
+
147
+ write_curve_index(buffer, indices, curves.x);
148
+ write_curve_index(buffer, indices, curves.y);
149
+ write_curve_index(buffer, indices, curves.z);
150
+ write_curve_index(buffer, indices, curves.w);
151
+ }
152
+
153
+ indices.clear();
154
+ }
155
+
156
+ /**
157
+ * @param {BinaryBuffer} buffer
158
+ * @param {ShadeAnimationClip} value
159
+ */
160
+ deserialize(buffer, value) {
161
+ const name = buffer.readUTF8String();
162
+
163
+ const curve_count = buffer.readUintVar();
164
+
165
+ /** @type {AnimationCurve[]} */
166
+ const table = new Array(curve_count);
167
+
168
+ for (let i = 0; i < curve_count; i++) {
169
+ table[i] = deserialize_animation_curve(buffer);
170
+ }
171
+
172
+ const channel_count = buffer.readUintVar();
173
+
174
+ /** @type {ShadeAnimationChannel[]} */
175
+ const channels = new Array(channel_count);
176
+
177
+ for (let i = 0; i < channel_count; i++) {
178
+ const channel = new ShadeAnimationChannel();
179
+
180
+ channel.target = buffer.readUint32();
181
+ channel.property = buffer.readUint8();
182
+
183
+ const curves = channel.curves;
184
+
185
+ curves.x = read_curve_index(buffer, table, name);
186
+ curves.y = read_curve_index(buffer, table, name);
187
+ curves.z = read_curve_index(buffer, table, name);
188
+ curves.w = read_curve_index(buffer, table, name);
189
+
190
+ channels[i] = channel;
191
+ }
192
+
193
+ value.name = name;
194
+ value.channels = channels;
195
+ }
196
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A {@link Skin} on disk, as a loader's bundle holds it: joints and meshes are places in the bundle's nodes.
3
+ *
4
+ * <pre>
5
+ * UTF8 name
6
+ * UintVar joint count
7
+ * u32 x count joints, in the order per-vertex joint indices mean
8
+ * f32 x 16 each inverse_bind_matrices, column-major, one a joint
9
+ * UintVar mesh count
10
+ * u32 x count meshes, the nodes this skin deforms
11
+ * </pre>
12
+ *
13
+ * @extends BinaryClassSerializationAdapter<Skin>
14
+ *
15
+ * @author Alex Goldring
16
+ * @copyright Company Named Limited (c) 2026
17
+ */
18
+ export class SkinSerializationAdapter extends BinaryClassSerializationAdapter<Skin> {
19
+ constructor();
20
+ klass: typeof Skin;
21
+ }
22
+ export type BinaryBuffer = import("../../../core/binary/BinaryBuffer.js").BinaryBuffer;
23
+ import { Skin } from "./Skin.js";
24
+ import { BinaryClassSerializationAdapter } from "../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
25
+ //# sourceMappingURL=SkinSerializationAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkinSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/animation/SkinSerializationAdapter.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;GAgBG;AACH;;IACI,mBAAa;CA4ChB;2BAhFY,OAAO,sCAAsC,EAAE,YAAY;qBAHnD,WAAW;gDADgB,uEAAuE"}
@@ -0,0 +1,85 @@
1
+ import { BinaryClassSerializationAdapter } from "../../../engine/ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
+ import { Skin } from "./Skin.js";
3
+
4
+ /**
5
+ * @typedef {import("../../../core/binary/BinaryBuffer.js").BinaryBuffer} BinaryBuffer
6
+ */
7
+
8
+ /**
9
+ * @param {BinaryBuffer} buffer
10
+ * @returns {number[]} a count, then as many indices
11
+ */
12
+ function read_indices(buffer) {
13
+ const count = buffer.readUintVar();
14
+ const result = new Array(count);
15
+
16
+ for (let i = 0; i < count; i++) {
17
+ result[i] = buffer.readUint32();
18
+ }
19
+
20
+ return result;
21
+ }
22
+
23
+ /**
24
+ * A {@link Skin} on disk, as a loader's bundle holds it: joints and meshes are places in the bundle's nodes.
25
+ *
26
+ * <pre>
27
+ * UTF8 name
28
+ * UintVar joint count
29
+ * u32 x count joints, in the order per-vertex joint indices mean
30
+ * f32 x 16 each inverse_bind_matrices, column-major, one a joint
31
+ * UintVar mesh count
32
+ * u32 x count meshes, the nodes this skin deforms
33
+ * </pre>
34
+ *
35
+ * @extends BinaryClassSerializationAdapter<Skin>
36
+ *
37
+ * @author Alex Goldring
38
+ * @copyright Company Named Limited (c) 2026
39
+ */
40
+ export class SkinSerializationAdapter extends BinaryClassSerializationAdapter {
41
+ klass = Skin;
42
+ version = 0;
43
+
44
+ /**
45
+ * @param {BinaryBuffer} buffer
46
+ * @param {Skin} value
47
+ */
48
+ serialize(buffer, value) {
49
+ const joints = value.joints;
50
+ const joint_count = joints.length;
51
+ const meshes = value.meshes;
52
+
53
+ if (value.inverse_bind_matrices.length !== joint_count * 16) {
54
+ // not an assert: a record written with the wrong count of matrices reads as garbage from there on
55
+ throw new Error(`skin '${value.name}' has ${joint_count} joints and ${value.inverse_bind_matrices.length} inverse bind matrix elements, where ${joint_count * 16} are due`);
56
+ }
57
+
58
+ buffer.writeUTF8String(value.name);
59
+
60
+ buffer.writeUintVar(joint_count);
61
+ buffer.writeUint32Array(joints, 0, joint_count);
62
+ buffer.writeFloat32Array(value.inverse_bind_matrices, 0, joint_count * 16);
63
+
64
+ buffer.writeUintVar(meshes.length);
65
+ buffer.writeUint32Array(meshes, 0, meshes.length);
66
+ }
67
+
68
+ /**
69
+ * @param {BinaryBuffer} buffer
70
+ * @param {Skin} value
71
+ */
72
+ deserialize(buffer, value) {
73
+ value.name = buffer.readUTF8String();
74
+
75
+ const joints = read_indices(buffer);
76
+
77
+ const inverse_bind_matrices = new Float32Array(joints.length * 16);
78
+
79
+ buffer.readFloat32Array(inverse_bind_matrices, 0, inverse_bind_matrices.length);
80
+
81
+ value.joints = joints;
82
+ value.inverse_bind_matrices = inverse_bind_matrices;
83
+ value.meshes = read_indices(buffer);
84
+ }
85
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"GPUHairSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/GPUHairSystem.js"],"names":[],"mappings":"AAwIA;;;;GAIG;AACH,+BAFU,MAAM,CAEkB;AAElC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+B/B;IAED;;;;;OAKG;IACH,kBAHW,cAAc,QACd,MAAM,QAYhB;IAED;;;OAGG;IACH,sBAHW,cAAc,YACd,YAAY,QAUtB;IAED;;OAEG;IACH,gBAFW,cAAc,QA6CxB;IAED;;OAEG;IACH,eAUC;IAED;;;;;;OAMG;IACH,kBAFW,YAAY,QAsXtB;IAsHD;;;;;OAKG;IACH,mBAFW,YAAY,QAmGtB;IAED,gBAiBC;;CA+rBJ;oBAjqEY,OAAO,wCAAwC,EAAE,KAAK;2BACtD,OAAO,8BAA8B,EAAE,YAAY;8BACnD,OAAO,uBAAuB,EAAE,eAAe;4BAvFhC,gCAAgC;2BADjC,yBAAyB"}
1
+ {"version":3,"file":"GPUHairSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/GPUHairSystem.js"],"names":[],"mappings":"AAwIA;;;;GAIG;AACH,+BAFU,MAAM,CAEkB;AAElC;;;GAGG;AACH,wCAFU,MAAM,CAE6B;AAc7C;;GAEG;AACH;IACI,6CAA6C;IAC7C,SADW,MAAM,CACH;IAEd,kEAAkE;IAClE,SADW,MAAM,CACL;IAEZ,mDAAmD;IACnD,KADW,YAAY,CACW;IAElC,oDAAoD;IACpD,WADW,MAAM,CACD;IAEhB;;OAEG;IACH,YAFW,YAAY,QAOtB;IAED;;;OAGG;IACH,cAHW,YAAY,GACV,OAAO,CASnB;CACJ;AAED;;;GAGG;AACH;IACI,gCAAgC;IAChC,SADW,MAAM,CACL;IAEZ,gCAAgC;IAChC,mBADW,MAAM,CACM;IAEvB,+CAA+C;IAC/C,oBADW,MAAM,CACQ;IAEzB,gCAAgC;IAChC,kBADW,MAAM,CACK;IAEtB,qBAAqB;IACrB,UADW,MAAM,CACF;IAEf,4BAA4B;IAC5B,WADW,MAAM,CACH;IAEd;;OAEG;IACH,YAFW,oBAAoB,QAS9B;IAED;;;OAGG;IACH,cAHW,oBAAoB,GAClB,OAAO,CASnB;CACJ;AAiBD;;GAEG;AACH;IACI,yBAAyB;IAC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G;IAC5G,4BAEC;IAED,8DAA8D;IAC9D,6BAEC;IAED,uFAAuF;IACvF,2BAEC;IAED,sDAAsD;IACtD,wBAEC;IAED,4BAA4B;IAC5B,6BAEC;IAED,4DAA4D;IAC5D,0BAEC;IAED;;;;;OAKG;IACH,cAFW,MAAM,QAMhB;IAED;;;;;;;OAOG;IACH,sBAHW,cAAc,YACd,oBAAoB,GAAC,IAAI,QAwCnC;IAED;;;;;;;;;;;;OAYG;IACH,qBALW,cAAc,aACd,MAAM,YACN,OAAO,gCAAgC,EAAE,eAAe,GAAC,IAAI,gBAC7D,MAAM,QA2FhB;IAED;;;;;OAKG;IACH,eAFW,cAAc,QAaxB;IAED;;;;;;;OAOG;IACH,uBAJW,cAAc,SACd,WAAW,SACX,MAAM,QAYhB;IAED;;;;;;;OAOG;IACH,WALW,KAAK,QACL,MAAM,YACN,YAAY,GACV,cAAc,GAAC,IAAI,CA+B/B;IAED;;;;;OAKG;IACH,kBAHW,cAAc,QACd,MAAM,QAYhB;IAED;;;OAGG;IACH,sBAHW,cAAc,YACd,YAAY,QAUtB;IAED;;OAEG;IACH,gBAFW,cAAc,QA6CxB;IAED;;OAEG;IACH,eAUC;IAED;;;;;;OAMG;IACH,kBAFW,YAAY,QAsXtB;IA6HD;;;;;OAKG;IACH,mBAFW,YAAY,QAmGtB;IAED,gBAiBC;;CA+rBJ;oBA1qEY,OAAO,wCAAwC,EAAE,KAAK;2BACtD,OAAO,8BAA8B,EAAE,YAAY;8BACnD,OAAO,uBAAuB,EAAE,eAAe;4BAvFhC,gCAAgC;2BADjC,yBAAyB"}
@@ -533,10 +533,12 @@ export class GPUHairSystem {
533
533
  #view_u32 = new Uint32Array(this.#view_words);
534
534
 
535
535
  /**
536
- * A shadow view's rectangle, `HAIR_SHADOW_TARGET_STRUCT`, written a view at a time.
537
- * @type {Float32Array}
536
+ * A shadow view's rectangle and the frame's list capacity, `HAIR_SHADOW_TARGET_STRUCT`, written a view at a time.
537
+ * @type {ArrayBuffer}
538
538
  */
539
- #shadow_view_words = new Float32Array(HAIR_SHADOW_TARGET_STRUCT.size / 4);
539
+ #shadow_view_words = new ArrayBuffer(HAIR_SHADOW_TARGET_STRUCT.size);
540
+ #shadow_view_f32 = new Float32Array(this.#shadow_view_words);
541
+ #shadow_view_u32 = new Uint32Array(this.#shadow_view_words);
540
542
 
541
543
  /**
542
544
  * The frame's shadow views the strands draw into, `HAIR_SHADOW_VIEW_STRUCT` each; made with the first frame that
@@ -1421,12 +1423,17 @@ export class GPUHairSystem {
1421
1423
 
1422
1424
  const views = shadows.views;
1423
1425
  const view_words = this.#shadow_view_words;
1426
+ const view_f32 = this.#shadow_view_f32;
1427
+ const resolution_word = HAIR_SHADOW_TARGET_STRUCT.get("resolution").offset / 4;
1428
+
1429
+ this.#shadow_view_u32[HAIR_SHADOW_TARGET_STRUCT.get("list_capacity").offset / 4] = list_capacity;
1424
1430
 
1425
1431
  const data = {};
1426
1432
 
1427
1433
  const pass = graph.add("draw hair shadows", data, (data, resources, context) => {
1428
1434
  const encoder = context.encoder;
1429
1435
  const atlas = resources.get(data.atlas).obtainView();
1436
+ const hair_shadow_list = resources.get(data.shadow_list);
1430
1437
  const hair_list = resources.get(data.list);
1431
1438
  const hair_points = resources.get(data.points);
1432
1439
  const draw_args = resources.get(data.args);
@@ -1435,12 +1442,13 @@ export class GPUHairSystem {
1435
1442
  const view = views[v];
1436
1443
  const [x, y, width, height] = view.viewport;
1437
1444
 
1438
- view_words[0] = width;
1439
- view_words[1] = height;
1445
+ view_f32[resolution_word] = width;
1446
+ view_f32[resolution_word + 1] = height;
1440
1447
 
1441
1448
  const bindings = HAIR_SHADOW_RESOURCES.generateBindings({
1442
1449
  camera: view.camera_buffer,
1443
- hair_shadow_view: encoder.allocateTransientBufferAndLoad(view_words.buffer, GPUBufferUsage.UNIFORM),
1450
+ hair_shadow_view: encoder.allocateTransientBufferAndLoad(view_words, GPUBufferUsage.UNIFORM),
1451
+ hair_shadow_list,
1444
1452
  hair_list,
1445
1453
  hair_points,
1446
1454
  }, encoder);
@@ -1469,7 +1477,8 @@ export class GPUHairSystem {
1469
1477
  }
1470
1478
  });
1471
1479
 
1472
- data.list = pass.read(listed.hair_shadow_list);
1480
+ data.shadow_list = pass.read(listed.hair_shadow_list);
1481
+ data.list = pass.read(list);
1473
1482
  data.points = pass.read(points);
1474
1483
  data.args = pass.read(args);
1475
1484
  data.atlas = pass.write(shadows.atlas);
@@ -11,9 +11,11 @@
11
11
  * **A draw list entry** is a strand: its slot, with its point class above {@link HAIR_CLASS_SHIFT}. A strand of
12
12
  * class `c` has `2^c` segments. A class's region of the list holds first the strands of instances the view draws,
13
13
  * from its start, then those of instances only the shadow views draw, from its start plus the first's count. Where
14
- * the strands cast shadows, the list is followed, at its capacity, by two words an entry
15
- * ({@link HAIR_LIST_SHADOW_WORDS}): the widest half width any point of the strand is drawn at, then the farthest any
16
- * point of it is from its root, metres, f32 bits.
14
+ * the strands cast shadows, the list is followed, at its capacity, by three words an entry
15
+ * ({@link HAIR_LIST_SHADOW_WORDS}), f32 bits: the widest half width any point of the strand is drawn at; the farthest
16
+ * any point of it is from its root, metres; and its share, the number in [0, 1), stratified over its group's ranks,
17
+ * that decides whether a point of it narrower than a view's floor or a shadow view's texel is drawn at it. The share
18
+ * belongs to the strand, not to where the frame placed it, so a strand is drawn or not frame after frame.
17
19
  *
18
20
  * **An instance's density volume** is a box of voxels around its strands, cubes of one edge, in the frame's voxel
19
21
  * buffer (`u32`) from its LOD record's `voxel_base`: {@link HAIR_VOLUME_MIPS} levels one after another, x fastest,
@@ -1 +1 @@
1
- {"version":3,"file":"HAIR.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/HAIR.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;GAEG;AACH,8CAAwC;AAExC;;;GAGG;AACH,2BAFU,MAAM,CAEc;AAE9B;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAEpC;;;GAGG;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CAEqB;AAErC,oCAAqC;AACrC,oCAAqC;AACrC,oCAAqC;AACrC,sCAAuC;AACvC,6CAA8C;AAC9C,6CAA8C;AAE9C;;;GAGG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;GAGG;AACH,mCAFU,MAAM,CAEsB"}
@@ -11,9 +11,11 @@
11
11
  * **A draw list entry** is a strand: its slot, with its point class above {@link HAIR_CLASS_SHIFT}. A strand of
12
12
  * class `c` has `2^c` segments. A class's region of the list holds first the strands of instances the view draws,
13
13
  * from its start, then those of instances only the shadow views draw, from its start plus the first's count. Where
14
- * the strands cast shadows, the list is followed, at its capacity, by two words an entry
15
- * ({@link HAIR_LIST_SHADOW_WORDS}): the widest half width any point of the strand is drawn at, then the farthest any
16
- * point of it is from its root, metres, f32 bits.
14
+ * the strands cast shadows, the list is followed, at its capacity, by three words an entry
15
+ * ({@link HAIR_LIST_SHADOW_WORDS}), f32 bits: the widest half width any point of the strand is drawn at; the farthest
16
+ * any point of it is from its root, metres; and its share, the number in [0, 1), stratified over its group's ranks,
17
+ * that decides whether a point of it narrower than a view's floor or a shadow view's texel is drawn at it. The share
18
+ * belongs to the strand, not to where the frame placed it, so a strand is drawn or not frame after frame.
17
19
  *
18
20
  * **An instance's density volume** is a box of voxels around its strands, cubes of one edge, in the frame's voxel
19
21
  * buffer (`u32`) from its LOD record's `voxel_base`: {@link HAIR_VOLUME_MIPS} levels one after another, x fastest,
@@ -127,7 +129,7 @@ export const HAIR_COUNTER_SHADOW_CURSORS = 40;
127
129
  * Words an entry of the draw list carries past the list's capacity where the strands cast shadows.
128
130
  * @type {number}
129
131
  */
130
- export const HAIR_LIST_SHADOW_WORDS = 2;
132
+ export const HAIR_LIST_SHADOW_WORDS = 3;
131
133
 
132
134
  /**
133
135
  * Words of one indirect draw: vertex count, instance count, first vertex, first instance.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * A shadow view's rectangle as the hair draws into it.
2
+ * A shadow view's rectangle as the hair draws into it, and where the frame's draw list keeps its shadow words.
3
3
  * @type {WebGPUStruct}
4
4
  */
5
5
  export const HAIR_SHADOW_TARGET_STRUCT: WebGPUStruct;
6
6
  /**
7
- * The bindings of {@link HAIR_SHADOW_PIPELINE}: `camera` (the shadow view's), `hair_shadow_view`, `hair_list` (the
8
- * shadow views' lists) and `hair_points` (the frame's deformed points).
7
+ * The bindings of {@link HAIR_SHADOW_PIPELINE}: `camera` (the shadow view's), `hair_shadow_view`, `hair_shadow_list`
8
+ * (the shadow views' lists), `hair_list` (the frame's draw list) and `hair_points` (the frame's deformed points).
9
9
  *
10
10
  * @type {ShaderResourceSetDescriptor}
11
11
  */
@@ -14,14 +14,14 @@ export const HAIR_SHADOW_RESOURCES: ShaderResourceSetDescriptor;
14
14
  * Draws the frame's strands into a shadow view's depth with the rasterizer's bias (`DEPTH_STENCIL_STATE_SHADOW`), in
15
15
  * cascades as well: a strand has no surface normal for the cascade casters' vertex-stage push to read.
16
16
  *
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
- * it for the eye: a triangle strip a pair of vertices at each of its points, `2 (2^class + 1)` vertices, one draw a
19
- * point class (`shader_hair_shadow_draw_args`),
17
+ * An instance is an entry of the view's list (`shader_hair_shadow_list`), a strand, the place of its entry in the
18
+ * frame's draw list. It is drawn as `hair_id_draw.js` draws it for the eye: a triangle strip a pair of vertices at each
19
+ * of its points, `2 (2^class + 1)` vertices, one draw a point class (`shader_hair_shadow_draw_args`),
20
20
  * across the strand's tangent and the way to the light. Its width is the strand's own, as its point carries it, also
21
- * where the camera's view drew it at none. Under a texel, a point is drawn a texel wide by the strands whose
22
- * stratified share is under its width's fraction of the texel, and at none by the rest, so the covered area is the
23
- * strands' own at any texel size. A point nearer the light than the view's near plane is drawn on the plane. Both faces
24
- * are drawn.
21
+ * where the camera's view drew it at none. Under a texel, a point is drawn a texel wide by the strands whose share
22
+ * (their third shadow word, `HAIR.js`) is under its width's fraction of the texel, and at none by the rest, so the
23
+ * covered area is the strands' own at any texel size. A point nearer the light than the view's near plane is drawn on
24
+ * the plane. Both faces are drawn.
25
25
  *
26
26
  * @type {RenderPipelineDescriptor}
27
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"hair_shadow_draw.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/hair_shadow_draw.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wCAFU,YAAY,CAKQ;AA2E9B;;;;;GAKG;AACH,oCAFU,2BAA2B,CAEU;AAE/C;;;;;;;;;;;;;;GAcG;AACH,mCAFU,wBAAwB,CAQ/B;6BAlH0B,gCAAgC;4CAJjB,mDAAmD;yCAJtD,8DAA8D"}
1
+ {"version":3,"file":"hair_shadow_draw.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/hair_shadow_draw.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wCAFU,YAAY,CAOQ;AA6E9B;;;;;GAKG;AACH,oCAFU,2BAA2B,CAEU;AAE/C;;;;;;;;;;;;;;GAcG;AACH,mCAFU,wBAAwB,CAQ/B;6BAtH0B,gCAAgC;4CAJjB,mDAAmD;yCAJtD,8DAA8D"}
@@ -4,18 +4,20 @@ import { DEPTH_STENCIL_STATE_SHADOW } from "../rasterize/DEPTH_STENCIL_STATE_SHA
4
4
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
5
5
  import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
6
6
  import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
7
- import { vec2f, vec4u } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
7
+ import { u32, vec2f, vec4u } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
8
8
  import { WebGPUArray } from "../shader/type/WebGPUArray.js";
9
9
  import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
10
- import { HAIR_CLASS_SHIFT } from "./HAIR.js";
10
+ import { HAIR_CLASS_SHIFT, HAIR_LIST_SHADOW_WORDS } from "./HAIR.js";
11
11
 
12
12
  /**
13
- * A shadow view's rectangle as the hair draws into it.
13
+ * A shadow view's rectangle as the hair draws into it, and where the frame's draw list keeps its shadow words.
14
14
  * @type {WebGPUStruct}
15
15
  */
16
16
  export const HAIR_SHADOW_TARGET_STRUCT = WebGPUStruct.from({
17
17
  /** the view's rectangle in the atlas, texels */
18
18
  resolution: vec2f,
19
+ /** entries the frame's draw list holds: its shadow words follow them */
20
+ list_capacity: u32,
19
21
  }, "HairShadowTarget").pack();
20
22
 
21
23
  const resources = new ShaderResourceSetDescriptor();
@@ -23,6 +25,7 @@ const resources = new ShaderResourceSetDescriptor();
23
25
  resources.createGroup()
24
26
  .add(CAMERA_RESOURCE)
25
27
  .addUniform("hair_shadow_view", HAIR_SHADOW_TARGET_STRUCT)
28
+ .addStorageBuffer("hair_shadow_list", WebGPUArray.u32)
26
29
  .addStorageBuffer("hair_list", WebGPUArray.u32)
27
30
  .addStorageBuffer("hair_points", WebGPUArray.from(vec4u));
28
31
 
@@ -36,7 +39,8 @@ fn hair_point(slot: u32) -> vec4<f32> {
36
39
 
37
40
  @vertex
38
41
  fn vs_main(@builtin(vertex_index) vertex: u32, @builtin(instance_index) instance: u32) -> @builtin(position) vec4<f32> {
39
- let entry = hair_list[instance];
42
+ let at = hair_shadow_list[instance];
43
+ let entry = hair_list[at];
40
44
  let slot = entry & ${2 ** HAIR_CLASS_SHIFT - 1}u;
41
45
  let segments = 1u << (entry >> ${HAIR_CLASS_SHIFT}u);
42
46
 
@@ -73,10 +77,10 @@ fn vs_main(@builtin(vertex_index) vertex: u32, @builtin(instance_index) instance
73
77
  let way = select(vec2<f32>(1.0, 0.0), offset / max(real, 1e-12), real >= 1e-6);
74
78
 
75
79
  // a point narrower than a texel is drawn a texel wide by as many strands as its width is of the texel: by those
76
- // whose share of the texel, stratified over any run of strands, is under its width's; the depth covers then what
77
- // the strands cover, which the map's filter takes as the light they let through
78
- let strand = slot / (segments + 1u);
79
- let share = fract(f32(strand) * 0.618034 + 0.5);
80
+ // whose share, stratified over their group's ranks, is under its width's fraction of the texel; the depth covers
81
+ // then what the strands cover, which the map's filter takes as the light they let through. The share is the
82
+ // strand's own, its third shadow word, so the same strands are drawn wherever the frame placed their points
83
+ let share = bitcast<f32>(hair_list[hair_shadow_view.list_capacity + at * ${HAIR_LIST_SHADOW_WORDS}u + 2u]);
80
84
  let drawn = select(select(0.0, 0.5, real > share * 0.5), real, real >= 0.5);
81
85
 
82
86
  var position = clip + vec4<f32>(way * (drawn * side) / texels * clip.w, 0.0, 0.0);
@@ -92,8 +96,8 @@ fn vs_main(@builtin(vertex_index) vertex: u32, @builtin(instance_index) instance
92
96
  const descriptor = ShaderDescriptor.from({ label: "Hair Shadow", body, resources });
93
97
 
94
98
  /**
95
- * The bindings of {@link HAIR_SHADOW_PIPELINE}: `camera` (the shadow view's), `hair_shadow_view`, `hair_list` (the
96
- * shadow views' lists) and `hair_points` (the frame's deformed points).
99
+ * The bindings of {@link HAIR_SHADOW_PIPELINE}: `camera` (the shadow view's), `hair_shadow_view`, `hair_shadow_list`
100
+ * (the shadow views' lists), `hair_list` (the frame's draw list) and `hair_points` (the frame's deformed points).
97
101
  *
98
102
  * @type {ShaderResourceSetDescriptor}
99
103
  */
@@ -103,14 +107,14 @@ export const HAIR_SHADOW_RESOURCES = resources;
103
107
  * Draws the frame's strands into a shadow view's depth with the rasterizer's bias (`DEPTH_STENCIL_STATE_SHADOW`), in
104
108
  * cascades as well: a strand has no surface normal for the cascade casters' vertex-stage push to read.
105
109
  *
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
- * it for the eye: a triangle strip a pair of vertices at each of its points, `2 (2^class + 1)` vertices, one draw a
108
- * point class (`shader_hair_shadow_draw_args`),
110
+ * An instance is an entry of the view's list (`shader_hair_shadow_list`), a strand, the place of its entry in the
111
+ * frame's draw list. It is drawn as `hair_id_draw.js` draws it for the eye: a triangle strip a pair of vertices at each
112
+ * of its points, `2 (2^class + 1)` vertices, one draw a point class (`shader_hair_shadow_draw_args`),
109
113
  * across the strand's tangent and the way to the light. Its width is the strand's own, as its point carries it, also
110
- * where the camera's view drew it at none. Under a texel, a point is drawn a texel wide by the strands whose
111
- * stratified share is under its width's fraction of the texel, and at none by the rest, so the covered area is the
112
- * strands' own at any texel size. A point nearer the light than the view's near plane is drawn on the plane. Both faces
113
- * are drawn.
114
+ * where the camera's view drew it at none. Under a texel, a point is drawn a texel wide by the strands whose share
115
+ * (their third shadow word, `HAIR.js`) is under its width's fraction of the texel, and at none by the rest, so the
116
+ * covered area is the strands' own at any texel size. A point nearer the light than the view's near plane is drawn on
117
+ * the plane. Both faces are drawn.
114
118
  *
115
119
  * @type {RenderPipelineDescriptor}
116
120
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shader_hair_cull.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_cull.js"],"names":[],"mappings":"AAiCA,8CAWuB;AA0KvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,+BAFU,aAAa,CAMpB;6BA1O0B,gCAAgC;8BAL/B,4BAA4B"}
1
+ {"version":3,"file":"shader_hair_cull.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_cull.js"],"names":[],"mappings":"AAiCA,8CAWuB;AA8KvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,+BAFU,aAAa,CAMpB;6BA9O0B,gCAAgC;8BAL/B,4BAA4B"}
@@ -88,6 +88,7 @@ fn main(
88
88
  var entry = 0u;
89
89
  var widest = 0.0;
90
90
  var reach = 0.0;
91
+ var strand_share = 0.0;
91
92
 
92
93
  if (row < rows) {
93
94
  var point = thread;
@@ -176,13 +177,15 @@ fn main(
176
177
  hair_points[settings.point_capacity + slot + j] = vec4<u32>(bitcast<vec3<u32>>(before), row | (variation << ${HAIR_ROW_BITS}u));
177
178
 
178
179
  // the root's thread lists the strand, in its class's part for the view or for the shadow views alone,
179
- // with the widest it is drawn and how far it reaches from its root (the reach the level of detail's box
180
- // allows a strand: its group's longest guide and the farthest a point strays from one)
180
+ // with the widest it is drawn, how far it reaches from its root (the reach the level of detail's box
181
+ // allows a strand: its group's longest guide and the farthest a point strays from one) and its share,
182
+ // which a shadow view thins it by as the floor does here
181
183
  if (j == 0u) {
182
184
  key = select(${HAIR_COUNTER_CURSORS}u, ${HAIR_COUNTER_SHADOW_CURSORS}u, shadow_only) + lod.point_class;
183
185
  entry = slot | (lod.point_class << ${HAIR_CLASS_SHIFT}u);
184
186
  widest = 0.5 * instance.width_max * saturate(presence) / kept * lod.scale;
185
187
  reach = (instance.guide_length_max + instance.guide_reach) * lod.scale + widest;
188
+ strand_share = share;
186
189
  }
187
190
  }
188
191
  }
@@ -197,6 +200,7 @@ fn main(
197
200
 
198
201
  hair_list[at] = bitcast<u32>(widest);
199
202
  hair_list[at + 1u] = bitcast<u32>(reach);
203
+ hair_list[at + 2u] = bitcast<u32>(strand_share);
200
204
  }
201
205
  }
202
206
  }
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * **A shadow view's list** is laid out as the frame's draw list is (`HAIR.js`): view `v`'s from entry
5
5
  * `v × list capacity`, each class's region from the draw list's start of it, its strands from the region's start, as
6
- * many as the view's count of the class (`hair_shadow_counts`, `v × HAIR_CLASS_COUNT + class`).
6
+ * many as the view's count of the class (`hair_shadow_counts`, `v × HAIR_CLASS_COUNT + class`). An entry is where the
7
+ * strand's entry is in the frame's draw list, which holds its slot, its class and its shadow words.
7
8
  */
8
9
  export const HAIR_SHADOW_LIST_SETTINGS: WebGPUStruct;
9
10
  /**
@@ -22,11 +23,11 @@ export const shader_hair_shadow_list_command: ComputeShader;
22
23
  *
23
24
  * - the ball about its root as wide as its reach (its shadow words) is inside the view's planes, the near one aside;
24
25
  * - its widest point, at the finest the view's texels are within that ball, is drawn by the shadow draw: wider than
25
- * its stratified share of half a texel, the share and the test of `hair_shadow_draw.js`. Where the ball reaches
26
+ * its share (its third shadow word) of half a texel, the test of `hair_shadow_draw.js`. Where the ball reaches
26
27
  * the eye of a perspective view, its texels are not bounded, and the strand is drawn.
27
28
  *
28
- * A drawn strand is appended to its class's region of the view's list (`chunk_subgroup_keyed_append` on the view's
29
- * count of the class).
29
+ * A drawn strand is appended to its class's region of the view's list, as the place of its entry in the frame's draw
30
+ * list (`chunk_subgroup_keyed_append` on the view's count of the class).
30
31
  *
31
32
  * @type {ComputeShader}
32
33
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shader_hair_shadow_list.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_shadow_list.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AAEH,qDAK6B;AA6B7B;;;;;GAKG;AACH,8CAFU,aAAa,CAkBpB;AAcH;;;;;;;;;;;;;;;;GAgBG;AACH,sCAFU,aAAa,CA8EpB;AAWH;;;;;;GAMG;AACH,2CAFU,aAAa,CAyBpB;6BAjO0B,gCAAgC;8BAJ/B,4BAA4B"}
1
+ {"version":3,"file":"shader_hair_shadow_list.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_shadow_list.js"],"names":[],"mappings":"AA2BA;;;;;;;GAOG;AAEH,qDAK6B;AA6B7B;;;;;GAKG;AACH,8CAFU,aAAa,CAkBpB;AAcH;;;;;;;;;;;;;;;;GAgBG;AACH,sCAFU,aAAa,CA2EpB;AAWH;;;;;;GAMG;AACH,2CAFU,aAAa,CAyBpB;6BA/N0B,gCAAgC;8BAJ/B,4BAA4B"}