@woosh/meep-engine 3.76.0 → 3.77.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.
- package/editor/particles/effect/ParticleReferenceSimulation.d.ts +11 -0
- package/editor/particles/effect/ParticleReferenceSimulation.d.ts.map +1 -1
- package/editor/particles/effect/ParticleReferenceSimulation.js +14 -0
- package/editor/view/particles/effect/ParticleGraphEditorView.js +1 -1
- package/package.json +1 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/GroomAssetLoader.js +16 -2
- package/src/engine/graphics/ecs/hair/Hair.d.ts +7 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -1
- package/src/engine/graphics/ecs/hair/Hair.js +9 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.d.ts +63 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.js +82 -0
- package/src/engine/graphics/hair/Groom.d.ts +45 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
- package/src/engine/graphics/hair/Groom.js +56 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +27 -1
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +105 -32
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts +8 -0
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.js +31 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +85 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.js +216 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts +7 -2
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
- package/src/engine/graphics/hair/groom_build_group.js +11 -2
- package/src/engine/graphics/hair/groom_build_guides.d.ts +43 -0
- package/src/engine/graphics/hair/groom_build_guides.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_guides.js +267 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts +6 -4
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -1
- package/src/engine/graphics/hair/groom_root_spacing.js +199 -66
- package/src/engine/graphics3/HairColliderSystem.d.ts +59 -0
- package/src/engine/graphics3/HairColliderSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairColliderSystem.js +270 -0
- package/src/engine/graphics3/HairSystem.d.ts +21 -4
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -1
- package/src/engine/graphics3/HairSystem.js +270 -4
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/assets/textures/hair_scattering.bin +0 -0
- package/src/shade/playground/hair/main.js +27 -4
- package/src/shade/playground/hair_skinned/index.html +192 -0
- package/src/shade/playground/hair_skinned/main.d.ts +7 -0
- package/src/shade/playground/hair_skinned/main.d.ts.map +1 -0
- package/src/shade/playground/hair_skinned/main.js +481 -0
- package/src/shade/playground/hair_skinned/skinned_hair.d.ts +49 -0
- package/src/shade/playground/hair_skinned/skinned_hair.d.ts.map +1 -0
- package/src/shade/playground/hair_skinned/skinned_hair.js +362 -0
- package/src/shade/playground/sparks/README.md +36 -0
- package/src/shade/playground/sparks/index.html +145 -0
- package/src/shade/playground/sparks/main.d.ts +7 -0
- package/src/shade/playground/sparks/main.d.ts.map +1 -0
- package/src/shade/playground/sparks/main.js +312 -0
- package/src/shade/playground/sparks/sparks_effect.d.ts +72 -0
- package/src/shade/playground/sparks/sparks_effect.d.ts.map +1 -0
- package/src/shade/playground/sparks/sparks_effect.js +180 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +18 -3
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts +3 -2
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.js +74 -3
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +13 -3
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +16 -5
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +8 -8
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +2 -2
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +4 -2
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +7 -3
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +1 -1
- package/src/shade/renderer/extension/ShadowAtlas.d.ts +75 -0
- package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -0
- package/src/shade/renderer/extension/ShadowAtlas.js +133 -0
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +37 -7
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +132 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +3 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +6 -2
- package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts +0 -18
- package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/sharc/sharc_constants.js +1 -21
- package/src/shade/renderer/hair/GPUHairSystem.d.ts +121 -2
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
- package/src/shade/renderer/hair/GPUHairSystem.js +1187 -56
- package/src/shade/renderer/hair/HAIR.d.ts +22 -3
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR.js +25 -4
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +33 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +4 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +24 -2
- package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +139 -0
- package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_SIMULATION.js +160 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +9 -2
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +40 -13
- package/src/shade/renderer/hair/chunk_hair_guide.d.ts +59 -0
- package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_guide.js +179 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts +4 -3
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_volume.js +21 -12
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_lighting.js +16 -7
- package/src/shade/renderer/hair/hair_scattering_lut.js +13 -13
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts +32 -0
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_shadow_draw.js +123 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts +2 -1
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_classes.js +6 -2
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +8 -2
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_cull.js +74 -17
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +9 -3
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_lod.js +125 -31
- package/src/shade/renderer/hair/shader_hair_roots.d.ts +36 -0
- package/src/shade/renderer/hair/shader_hair_roots.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_roots.js +261 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +44 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.js +240 -0
- package/src/shade/renderer/hair/shader_hair_simulate.d.ts +55 -0
- package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_simulate.js +563 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts +3 -3
- package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_volume.js +4 -17
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +8 -3
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_groom_extension.js +58 -5
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts +8 -0
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.js +28 -0
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +22 -0
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +4 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts +32 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.js +80 -0
- package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_parameters.js +1 -0
- package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_presentation.js +12 -0
- package/src/shade/renderer/particles/graph_particles.d.ts +5 -1
- package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles.js +18 -3
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts +25 -0
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/InstructionStream.js +25 -0
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +9 -0
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/ParticleVMISA.js +20 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts +9 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts.map +1 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.js +29 -0
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +2 -1
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +27 -5
- package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +1 -1
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +5 -0
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +7 -0
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/EmitterRegistry.js +10 -0
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +5 -0
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ParticleEmitter.js +5 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +8 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ProgramHeap.js +25 -0
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit.js +9 -3
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +4 -2
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +2 -2
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +10 -4
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +4 -2
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +14 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.js +34 -1
- package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/chunk_particle_vm.js +10 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts +39 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts.map +1 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.js +90 -0
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts +4 -1
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +14 -2
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.js +9 -3
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.js +4 -2
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -4
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +26 -16
- package/src/shade/renderer/scene/GPUSceneContext.d.ts +7 -0
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +18 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts +20 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.js +134 -0
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts +15 -0
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +69 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts +10 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts.map +1 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.js +22 -0
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
2
|
import { m4_multiply } from "../../../../core/geom/3d/mat4/m4_multiply.js";
|
|
3
3
|
import { Groom } from "../../../../engine/graphics/hair/Groom.js";
|
|
4
|
+
import { GROOM_GUIDE_DEFAULT_TOLERANCE } from "../../../../engine/graphics/hair/groom_build_guides.js";
|
|
4
5
|
import { groom_build_group, groom_point_count_for } from "../../../../engine/graphics/hair/groom_build_group.js";
|
|
5
6
|
import { usd_compose_transform } from "../../../../format/scene/usd/usd_compose_transform.js";
|
|
6
7
|
import { SceneNode } from "../SceneNode.js";
|
|
@@ -166,6 +167,24 @@ export function usd_read_basis_curves(specs_by_path, path) {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
const step = basis === "bezier" ? 3 : 1;
|
|
170
|
+
const interpolation = widths === null ? null : width_layout.interpolation;
|
|
171
|
+
const varying_count = interpolation === "varying" ? usd_varying_count(type, basis, wrap, n) : 0;
|
|
172
|
+
|
|
173
|
+
// a vertex width is a control value, weighted by the basis as the positions are, with the phantom ends a
|
|
174
|
+
// pinned wrap adds made the same way
|
|
175
|
+
const control_width = q => {
|
|
176
|
+
const i = pinned ? q - 1 : q;
|
|
177
|
+
|
|
178
|
+
if (i < 0) {
|
|
179
|
+
return 2 * widths[curve_first] - widths[curve_first + 1];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (i >= n) {
|
|
183
|
+
return 2 * widths[curve_first + n - 1] - widths[curve_first + n - 2];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return widths[curve_first + i];
|
|
187
|
+
};
|
|
169
188
|
|
|
170
189
|
for (let k = 0; k < spans; k++) {
|
|
171
190
|
for (let j = 0; j < SAMPLES_PER_SPAN + (k === spans - 1 ? 1 : 0); j++) {
|
|
@@ -184,7 +203,29 @@ export function usd_read_basis_curves(specs_by_path, path) {
|
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
out_positions.push(x, y, z);
|
|
187
|
-
|
|
206
|
+
|
|
207
|
+
if (interpolation === "vertex") {
|
|
208
|
+
let width = 0;
|
|
209
|
+
|
|
210
|
+
for (let q = 0; q < 4; q++) {
|
|
211
|
+
width += control_width(k * step + q) * w[q];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
out_widths.push(width);
|
|
215
|
+
} else if (interpolation === "varying") {
|
|
216
|
+
// a span is a segment of USD's, its ends the segment's values: the last of a periodic curve
|
|
217
|
+
// meets the first
|
|
218
|
+
if (varying_count < 1) {
|
|
219
|
+
out_widths.push(null);
|
|
220
|
+
} else {
|
|
221
|
+
const lo = Math.min(k, varying_count - 1);
|
|
222
|
+
const hi = wrap === "periodic" ? (k + 1) % varying_count : Math.min(k + 1, varying_count - 1);
|
|
223
|
+
|
|
224
|
+
out_widths.push(widths[curve_varying + lo] * (1 - t) + widths[curve_varying + hi] * t);
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
out_widths.push(width_of((k + t) / spans));
|
|
228
|
+
}
|
|
188
229
|
}
|
|
189
230
|
}
|
|
190
231
|
}
|
|
@@ -306,7 +347,8 @@ function cubic_span_count(type, basis, wrap, n) {
|
|
|
306
347
|
* A USD loader extension (`UsdExtensionRegistry`) that takes every BasisCurves prim of a stage as a group of strand
|
|
307
348
|
* hair: its curves carried by the prim's transform and its ancestors' into the stage's space, corrected to Y up and
|
|
308
349
|
* metres as the scene's meshes are, and resampled at the fewest points, `2^k + 1`, that keep them within `tolerance`
|
|
309
|
-
* of themselves (`groom_point_count_for`)
|
|
350
|
+
* of themselves (`groom_point_count_for`), with guides that hold their strands within `guide_tolerance`
|
|
351
|
+
* (`groom_build_guides`). Widths are scaled with the space.
|
|
310
352
|
*
|
|
311
353
|
* Each prim answers with a node that draws nothing, so the scene's hierarchy keeps its place. The groups gather in
|
|
312
354
|
* {@link groom}, in the order the stage's prims are visited.
|
|
@@ -314,9 +356,14 @@ function cubic_span_count(type, basis, wrap, n) {
|
|
|
314
356
|
* @param {Object} [options]
|
|
315
357
|
* @param {number} [options.tolerance] metres
|
|
316
358
|
* @param {number} [options.width] metres, for curves that author no widths
|
|
359
|
+
* @param {number} [options.guide_tolerance] metres
|
|
317
360
|
* @returns {{name: string, groom: Groom, processPrim: function(string, Object, Object): (SceneNode|null)}}
|
|
318
361
|
*/
|
|
319
|
-
export function create_usd_groom_extension({
|
|
362
|
+
export function create_usd_groom_extension({
|
|
363
|
+
tolerance = USD_GROOM_DEFAULT_TOLERANCE,
|
|
364
|
+
width = 70e-6,
|
|
365
|
+
guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE
|
|
366
|
+
} = {}) {
|
|
320
367
|
assert.greaterThan(tolerance, 0, 'tolerance');
|
|
321
368
|
|
|
322
369
|
const groom = new Groom();
|
|
@@ -357,6 +404,7 @@ export function create_usd_groom_extension({ tolerance = USD_GROOM_DEFAULT_TOLER
|
|
|
357
404
|
name: segments[segments.length - 1],
|
|
358
405
|
point_count: groom_point_count_for(curves, tolerance),
|
|
359
406
|
width,
|
|
407
|
+
guide_tolerance,
|
|
360
408
|
}));
|
|
361
409
|
}
|
|
362
410
|
|
|
@@ -401,12 +449,17 @@ function transform_curves(curves, m) {
|
|
|
401
449
|
* @param {ArrayBuffer} buffer a USD file: text, or a package whose root layer is text
|
|
402
450
|
* @param {Object} [options]
|
|
403
451
|
* @param {number} [options.tolerance] metres
|
|
452
|
+
* @param {number} [options.guide_tolerance] metres
|
|
404
453
|
* @param {string} [options.fileName] what the file is called, for telling its format apart when its bytes do not
|
|
405
454
|
* @returns {Promise<Groom>} with no group when the file holds no curves
|
|
406
455
|
*/
|
|
407
|
-
export async function load_groom_usd(buffer, {
|
|
456
|
+
export async function load_groom_usd(buffer, {
|
|
457
|
+
tolerance = USD_GROOM_DEFAULT_TOLERANCE,
|
|
458
|
+
guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE,
|
|
459
|
+
fileName
|
|
460
|
+
} = {}) {
|
|
408
461
|
const registry = new UsdExtensionRegistry();
|
|
409
|
-
const extension = create_usd_groom_extension({ tolerance });
|
|
462
|
+
const extension = create_usd_groom_extension({ tolerance, guide_tolerance });
|
|
410
463
|
|
|
411
464
|
registry.register(extension.name, extension);
|
|
412
465
|
|
|
@@ -352,6 +352,14 @@ export class GPUParticleSystem {
|
|
|
352
352
|
extinction: number;
|
|
353
353
|
emission: number;
|
|
354
354
|
};
|
|
355
|
+
/**
|
|
356
|
+
* Let go of the scene's distance field for a frame this system is not run, so that nothing builds it for an
|
|
357
|
+
* effect that is not running. The next {@link execute} takes it again if a registered effect still reads it.
|
|
358
|
+
*
|
|
359
|
+
* @param {import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph|null} [graph] the
|
|
360
|
+
* graph being recorded, when called in the middle of a frame — the field is then given back after it
|
|
361
|
+
*/
|
|
362
|
+
release_scene_field(graph?: import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph | null): void;
|
|
355
363
|
/**
|
|
356
364
|
* Register an emitter at a `transforms` row, and if it asks, warm it up before its first frame.
|
|
357
365
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GPUParticleSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/GPUParticleSystem.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH;IA2MI;;;;;;OAMG;IACH,sBANW,MAAM,iBACN,OAAO,6BAA6B,EAAE,eAAe;QAEpC,QAAQ,GAAzB,MAAM;QACW,sBAAsB,GAAvC,MAAM;OAqBhB;IAnOD;;;OAGG;IACH,UAFU,MAAM,CAEP;IAET;;;;OAIG;IACH,eAFU,OAAO,6BAA6B,EAAE,eAAe,CAEjD;IA6Bd;;OAEG;IACH,UAFU,eAAe,CAEhB;IAET;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,qBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,sBAAM;IAEN,yBAAyB;IACzB,0BAAc;IAEd;;;;;;;;;;;OAWG;IACH,SAFU,MAAM,CAEH;IAwJb;;;;;OAKG;IACH,4BAIC;IAlBD;;;OAGG;IACH,uBAEC;IAcD;;;OAGG;IACH,kCAEC;IAED;;;OAGG;IACH,yEAEC;IAED;;;;;OAKG;IACH,sFAEC;IAED;;;;;;;;;;;;OAYG;IACH,eAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,eAHW,OAAO,8BAA8B,EAAE,eAAe,SACtD,MAAM,QAwBhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH;QAPkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;QAC/D,MAAM,EAArB,MAAM;QACS,cAAc,EAA7B,MAAM;QAES,EAAE,EAAjB,MAAM;QACJ,OAAO,sBAAsB,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"GPUParticleSystem.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/GPUParticleSystem.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH;IA2MI;;;;;;OAMG;IACH,sBANW,MAAM,iBACN,OAAO,6BAA6B,EAAE,eAAe;QAEpC,QAAQ,GAAzB,MAAM;QACW,sBAAsB,GAAvC,MAAM;OAqBhB;IAnOD;;;OAGG;IACH,UAFU,MAAM,CAEP;IAET;;;;OAIG;IACH,eAFU,OAAO,6BAA6B,EAAE,eAAe,CAEjD;IA6Bd;;OAEG;IACH,UAFU,eAAe,CAEhB;IAET;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,qBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,sBAAM;IAEN,yBAAyB;IACzB,0BAAc;IAEd;;;;;;;;;;;OAWG;IACH,SAFU,MAAM,CAEH;IAwJb;;;;;OAKG;IACH,4BAIC;IAlBD;;;OAGG;IACH,uBAEC;IAcD;;;OAGG;IACH,kCAEC;IAED;;;OAGG;IACH,yEAEC;IAED;;;;;OAKG;IACH,sFAEC;IAED;;;;;;;;;;;;OAYG;IACH,eAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,eAHW,OAAO,8BAA8B,EAAE,eAAe,SACtD,MAAM,QAwBhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH;QAPkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;QAC/D,MAAM,EAArB,MAAM;QACS,cAAc,EAA7B,MAAM;QAES,EAAE,EAAjB,MAAM;QACJ,OAAO,sBAAsB,EAAE,yBAAyB,CAwFpE;IAiBD;;;;;;;;;OASG;IACH;QANgG,KAAK,EAA1F,OAAO,2DAA2D,EAAE,UAAU;QACjE,MAAM,EAAnB,MAAM;QACkB,kBAAkB,EAA1C,UAAU,MAAM,CAAC;QACJ,SAAS,EAAtB,MAAM;QACJ,MAAM,CAalB;IAED;;;;;;;;;;OAUG;IACH;QAPgG,KAAK,EAA1F,OAAO,2DAA2D,EAAE,UAAU;QACjE,MAAM,EAAnB,MAAM;QACO,IAAI,EAAjB,MAAM;QACO,aAAa,EAA1B,MAAM;QACsD,MAAM,EAAlE;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC;QACnD;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAkBjE;IAED;;;;;;;;;;;;;;;;OAgBG;IACH;QAbgG,KAAK,EAA1F,OAAO,2DAA2D,EAAE,UAAU;QACrB,QAAQ,EAAjE,OAAO,2BAA2B,EAAE,cAAc;QACrC,MAAM,EAAnB,MAAM;QACO,aAAa,EAA1B,MAAM;QACO,IAAI,EAAjB,MAAM;QACO,QAAQ,EAArB,MAAM;QACO,eAAe,EAA5B,MAAM;QACO,oBAAoB,EAAjC,MAAM;QAC2C,sBAAsB,EAAvE;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAC;QAEgC,YAAY,EAAtF;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAC;QACjE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAwB/E;IAED;;;;;;OAMG;IACH,4BAHW,OAAO,2DAA2D,EAAE,UAAU,GAAC,IAAI,QAK7F;IAED;;;;;;;;;OASG;IACH,qBAHW,OAAO,8BAA8B,EAAE,eAAe,iBACtD,MAAM,QAehB;IAED;;;;OAIG;IACH,wBAFW,OAAO,8BAA8B,EAAE,eAAe,QAMhE;IAED;;;;;OAKG;IACH,2BAHW,OAAO,8BAA8B,EAAE,eAAe,iBACtD,MAAM,QAMhB;IA6pBD;;;;;;;OAOG;IACH;YAFoB,MAAM,GAAE,MAAM;MAgBjC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,cAFa,QAAQ,mBAAmB,CAAC,CA8BxC;IAED,gBA6BC;;CACJ;;;;;;;;WAv9Ca,MAAM;;;;UACN,MAAM;;;;kBACN,MAAM;;;;;cACN,MAAM;;;;;gBAEN,MAAM;;;;;oBAEN,MAAM;;gCAnDY,8BAA8B"}
|
|
@@ -575,6 +575,18 @@ export class GPUParticleSystem {
|
|
|
575
575
|
|
|
576
576
|
const buffers = this.buffers;
|
|
577
577
|
|
|
578
|
+
// The scene's distance field is held while a registered effect reads it, and given back when the last
|
|
579
|
+
// one goes. The renderer builds it for its holders before this runs, so the first frame of a hold binds
|
|
580
|
+
// a clipmap of no cascade, as does a frame recorded with no renderer building it; and a hold let go of
|
|
581
|
+
// here is let go of in the middle of this graph, which may hold the build already.
|
|
582
|
+
const scene_sdf = this.scene_context.brick_clipmap;
|
|
583
|
+
|
|
584
|
+
if (this.registry.scene_sdf_reader_count > 0) {
|
|
585
|
+
scene_sdf.acquire(this);
|
|
586
|
+
} else {
|
|
587
|
+
scene_sdf.release(this, graph);
|
|
588
|
+
}
|
|
589
|
+
|
|
578
590
|
this.#swap_alive_list(frame.rebucket);
|
|
579
591
|
|
|
580
592
|
// The table's database owns and grows its own buffer; it is re-read every frame for that
|
|
@@ -588,6 +600,9 @@ export class GPUParticleSystem {
|
|
|
588
600
|
// The scene's wind, which every VM pass binds for `SAMPLE_WIND`. The scene context always
|
|
589
601
|
// has one; nothing here knows or asks what produces it.
|
|
590
602
|
wind: this.scene_context.wind,
|
|
603
|
+
// The scene's distance field, which every VM pass binds for `SAMPLE_SCENE_DISTANCE` and
|
|
604
|
+
// `SAMPLE_SCENE_SDF`, held or not: one that nothing has built reads as no field.
|
|
605
|
+
scene_sdf,
|
|
591
606
|
gpu: buffers,
|
|
592
607
|
emitters,
|
|
593
608
|
capacity: this.#pool_capacity,
|
|
@@ -726,6 +741,17 @@ export class GPUParticleSystem {
|
|
|
726
741
|
});
|
|
727
742
|
}
|
|
728
743
|
|
|
744
|
+
/**
|
|
745
|
+
* Let go of the scene's distance field for a frame this system is not run, so that nothing builds it for an
|
|
746
|
+
* effect that is not running. The next {@link execute} takes it again if a registered effect still reads it.
|
|
747
|
+
*
|
|
748
|
+
* @param {import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph|null} [graph] the
|
|
749
|
+
* graph being recorded, when called in the middle of a frame — the field is then given back after it
|
|
750
|
+
*/
|
|
751
|
+
release_scene_field(graph = null) {
|
|
752
|
+
this.scene_context.brick_clipmap.release(this, graph);
|
|
753
|
+
}
|
|
754
|
+
|
|
729
755
|
/**
|
|
730
756
|
* Register an emitter at a `transforms` row, and if it asks, warm it up before its first frame.
|
|
731
757
|
*
|
|
@@ -1524,6 +1550,8 @@ export class GPUParticleSystem {
|
|
|
1524
1550
|
this.registry.remove(emitter);
|
|
1525
1551
|
}
|
|
1526
1552
|
|
|
1553
|
+
this.scene_context.brick_clipmap.release(this);
|
|
1554
|
+
|
|
1527
1555
|
// Before the loop below, and not in it: the alive lists are the allocator's and go back to
|
|
1528
1556
|
// it. Destroying one would leave the pool holding a handle it will hand to the next caller.
|
|
1529
1557
|
this.#release_alive_lists();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParticleNodeRegistry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/ParticleNodeRegistry.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ParticleNodeRegistry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/ParticleNodeRegistry.js"],"names":[],"mappings":"AAovBA;;;;;;;GAOG;AACH,8CAFa,uBAAuB,EAAE,CAIrC;AAED;;;;;GAKG;AACH,oDAJW,MAAM,GACJ,uBAAuB,CAWnC;AA5uBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;GASG;AACH,kCAFU,QAAQ,CAE2C;AAE7D;;;GAGG;AACH,wCAFU,MAAM,CAE+B;AAE/C;;GAEG;AACH,qCAFU,YAAY,CAEmC;wCAjEjB,8BAA8B;yBAd7C,oDAAoD;6BAFhD,wDAAwD"}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
PARTICLE_TYPE_COLOR,
|
|
26
26
|
PARTICLE_TYPE_F32,
|
|
27
27
|
PARTICLE_TYPE_VEC3,
|
|
28
|
+
PARTICLE_TYPE_VEC4,
|
|
28
29
|
particle_semantic_type,
|
|
29
30
|
particle_value_type,
|
|
30
31
|
particle_value_type_or_null,
|
|
@@ -732,6 +733,27 @@ define("globalField", [], (s, c) => {
|
|
|
732
733
|
}),
|
|
733
734
|
});
|
|
734
735
|
|
|
736
|
+
// --- the scene, continued ---
|
|
737
|
+
// Appended after the fields, for the reason the scene's wind was: an id is a position in this file.
|
|
738
|
+
//
|
|
739
|
+
// The scene's signed distance at a world position, metres, out of the solid positive: `SAMPLE_SCENE_DISTANCE`,
|
|
740
|
+
// which reads the field the host binds — on the GPU the scene's brick clipmap, no field (the largest finite f32)
|
|
741
|
+
// where nothing has built one. Three lanes of position in whatever arrives, like `cross`, and one out.
|
|
742
|
+
define("sceneDistance", ["position"], (s, c) => s.emit(VM_OP.SAMPLE_SCENE_DISTANCE, c.out, c.in("position"), 0, 0, c.width), {
|
|
743
|
+
infer_types: () => ({ output: PARTICLE_TYPE_F32, inputs: { position: PARTICLE_TYPE_VEC3 } }),
|
|
744
|
+
operation_width: () => 3,
|
|
745
|
+
result_width: () => 1,
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
// The same distance in `x` and the field's unit normal out of the solid in `yzw`: `SAMPLE_SCENE_SDF`, one read of
|
|
749
|
+
// the field for both. The normal is zero where the field gives none. The instruction runs at four lanes and reads
|
|
750
|
+
// the three-lane position through `.xyzz`, so nothing past the position is read.
|
|
751
|
+
define("sceneSdf", ["position"], (s, c) => s.emit(VM_OP.SAMPLE_SCENE_SDF, c.out, vm_register(c.in("position"), pack_swizzle(0, 1, 2, 2)), 0, 0, c.width), {
|
|
752
|
+
infer_types: () => ({ output: PARTICLE_TYPE_VEC4, inputs: { position: PARTICLE_TYPE_VEC3 } }),
|
|
753
|
+
operation_width: () => 4,
|
|
754
|
+
input_widths: () => ({ position: 3 }),
|
|
755
|
+
});
|
|
756
|
+
|
|
735
757
|
/**
|
|
736
758
|
* Every node type in the library, in declaration order.
|
|
737
759
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle_builtin_groups.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/particles/graph/groups/particle_builtin_groups.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"particle_builtin_groups.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/particles/graph/groups/particle_builtin_groups.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;GAQG;AACH,sCAFU,OAAO,yBAAyB,EAAE,iBAAiB,EAAE,CAoC7D"}
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
PARTICLE_GROUP_PSRDNOISE_3,
|
|
22
22
|
PARTICLE_GROUP_SRDNOISE_3,
|
|
23
23
|
} from "./particle_groups_psrdnoise.js";
|
|
24
|
+
import { PARTICLE_GROUP_COLLIDE } from "./particle_groups_scene.js";
|
|
24
25
|
import {
|
|
25
26
|
PARTICLE_GROUP_CEIL,
|
|
26
27
|
PARTICLE_GROUP_DECOMPOSE,
|
|
@@ -86,6 +87,9 @@ export const PARTICLE_BUILTIN_GROUPS = [
|
|
|
86
87
|
PARTICLE_GROUP_QUAT_INTEGRATE,
|
|
87
88
|
PARTICLE_GROUP_SAMPLE_ROTATION,
|
|
88
89
|
PARTICLE_GROUP_EMITTER_ROTATION,
|
|
90
|
+
|
|
91
|
+
// the scene, appended for the same reason
|
|
92
|
+
PARTICLE_GROUP_COLLIDE,
|
|
89
93
|
];
|
|
90
94
|
|
|
91
95
|
for (const group of PARTICLE_BUILTIN_GROUPS) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A particle, taken as a sphere of `radius`, against the scene's surfaces: pushed out of one it has sunk into, and
|
|
3
|
+
* its velocity answered with an impulse.
|
|
4
|
+
*
|
|
5
|
+
* Wired after the position has moved for the step, with the velocity it moved by: the field is read once, at the
|
|
6
|
+
* moved position (`sceneSdf`). A particle is in contact where the surface is nearer than its radius and the field
|
|
7
|
+
* gives a normal there.
|
|
8
|
+
*
|
|
9
|
+
* In contact:
|
|
10
|
+
* - **position** moves out along the normal by how far the sphere has sunk, `radius - distance`;
|
|
11
|
+
* - **velocity** loses what carried it into the surface and gets `restitution` of that back, an impulse
|
|
12
|
+
* `j = (1 + restitution) · max(-v·n, 0)` along the normal; and then friction, Coulomb's: the velocity along the
|
|
13
|
+
* surface falls by `friction · j`, and no further than to rest. A particle leaving the surface takes no impulse
|
|
14
|
+
* and so no friction; one resting on it under gravity takes, each step, the impulse that cancels the step's
|
|
15
|
+
* fall, which is kinetic friction's deceleration of `friction · g`, whatever the step's length;
|
|
16
|
+
* - **contact** is 1, and 0 otherwise.
|
|
17
|
+
*
|
|
18
|
+
* Out of contact both come out as they went in, and so does a particle where the field gives no normal: in the
|
|
19
|
+
* open past the field's band, inside a solid past its shell, or with no field at all. A particle that moves further
|
|
20
|
+
* in one step than its radius and the solid's shell together can pass through without touching.
|
|
21
|
+
*
|
|
22
|
+
* `restitution` and `friction` are finite and not negative: the contact gates the impulse by a product, so an
|
|
23
|
+
* infinite coefficient reads as `NaN` wherever the impulse is zero.
|
|
24
|
+
*
|
|
25
|
+
* Restitution answers every impact, the one a resting particle takes each step as well: under gravity `g` and a
|
|
26
|
+
* step `dt` such a particle leaves the surface each step at `restitution · g · dt / (1 + restitution)`, and is at
|
|
27
|
+
* rest only with no restitution. Friction still brings its slide to rest.
|
|
28
|
+
*
|
|
29
|
+
* @type {import("../ParticleNodeGroup.js").ParticleNodeGroup}
|
|
30
|
+
*/
|
|
31
|
+
export const PARTICLE_GROUP_COLLIDE: import("../ParticleNodeGroup.js").ParticleNodeGroup;
|
|
32
|
+
//# sourceMappingURL=particle_groups_scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"particle_groups_scene.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/particles/graph/groups/particle_groups_scene.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qCAFU,OAAO,yBAAyB,EAAE,iBAAiB,CAgDxD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ParticleGroupBuilder } from "../ParticleGroupBuilder.js";
|
|
2
|
+
import { PARTICLE_TYPE_F32, PARTICLE_TYPE_VEC3 } from "../ParticleValueType.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A particle, taken as a sphere of `radius`, against the scene's surfaces: pushed out of one it has sunk into, and
|
|
6
|
+
* its velocity answered with an impulse.
|
|
7
|
+
*
|
|
8
|
+
* Wired after the position has moved for the step, with the velocity it moved by: the field is read once, at the
|
|
9
|
+
* moved position (`sceneSdf`). A particle is in contact where the surface is nearer than its radius and the field
|
|
10
|
+
* gives a normal there.
|
|
11
|
+
*
|
|
12
|
+
* In contact:
|
|
13
|
+
* - **position** moves out along the normal by how far the sphere has sunk, `radius - distance`;
|
|
14
|
+
* - **velocity** loses what carried it into the surface and gets `restitution` of that back, an impulse
|
|
15
|
+
* `j = (1 + restitution) · max(-v·n, 0)` along the normal; and then friction, Coulomb's: the velocity along the
|
|
16
|
+
* surface falls by `friction · j`, and no further than to rest. A particle leaving the surface takes no impulse
|
|
17
|
+
* and so no friction; one resting on it under gravity takes, each step, the impulse that cancels the step's
|
|
18
|
+
* fall, which is kinetic friction's deceleration of `friction · g`, whatever the step's length;
|
|
19
|
+
* - **contact** is 1, and 0 otherwise.
|
|
20
|
+
*
|
|
21
|
+
* Out of contact both come out as they went in, and so does a particle where the field gives no normal: in the
|
|
22
|
+
* open past the field's band, inside a solid past its shell, or with no field at all. A particle that moves further
|
|
23
|
+
* in one step than its radius and the solid's shell together can pass through without touching.
|
|
24
|
+
*
|
|
25
|
+
* `restitution` and `friction` are finite and not negative: the contact gates the impulse by a product, so an
|
|
26
|
+
* infinite coefficient reads as `NaN` wherever the impulse is zero.
|
|
27
|
+
*
|
|
28
|
+
* Restitution answers every impact, the one a resting particle takes each step as well: under gravity `g` and a
|
|
29
|
+
* step `dt` such a particle leaves the surface each step at `restitution · g · dt / (1 + restitution)`, and is at
|
|
30
|
+
* rest only with no restitution. Friction still brings its slide to rest.
|
|
31
|
+
*
|
|
32
|
+
* @type {import("../ParticleNodeGroup.js").ParticleNodeGroup}
|
|
33
|
+
*/
|
|
34
|
+
export const PARTICLE_GROUP_COLLIDE = (() => {
|
|
35
|
+
const g = new ParticleGroupBuilder({
|
|
36
|
+
name: "collide",
|
|
37
|
+
label: "Collide With Scene",
|
|
38
|
+
icon: "M3 20h18 M6 6l5 11 5-8 M14 9h2v2",
|
|
39
|
+
help: "push a particle out of the scene's surfaces and bounce its velocity, with restitution and friction",
|
|
40
|
+
inputs: [
|
|
41
|
+
{ name: "position", type: PARTICLE_TYPE_VEC3 },
|
|
42
|
+
{ name: "velocity", type: PARTICLE_TYPE_VEC3 },
|
|
43
|
+
{ name: "radius", type: PARTICLE_TYPE_F32 },
|
|
44
|
+
{ name: "restitution", type: PARTICLE_TYPE_F32 },
|
|
45
|
+
{ name: "friction", type: PARTICLE_TYPE_F32 },
|
|
46
|
+
],
|
|
47
|
+
outputs: [
|
|
48
|
+
{ name: "position", type: PARTICLE_TYPE_VEC3 },
|
|
49
|
+
{ name: "velocity", type: PARTICLE_TYPE_VEC3 },
|
|
50
|
+
{ name: "contact", type: PARTICLE_TYPE_F32 },
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const field = g.sceneSdf(g.in.position);
|
|
55
|
+
const distance = g.x(field);
|
|
56
|
+
const normal = g.swz(field, "yzw");
|
|
57
|
+
|
|
58
|
+
// nearer than the radius, where the field gives a unit normal: 1 or 0, and the 0.5 only splits one from zero
|
|
59
|
+
const contact = g.mul(g.step(distance, g.in.radius), g.step(0.5, g.dot(normal, normal)));
|
|
60
|
+
|
|
61
|
+
// zero clear of the surface; and where the field gives no normal there is nothing to push along
|
|
62
|
+
const depth = g.max(g.sub(g.in.radius, distance), 0);
|
|
63
|
+
|
|
64
|
+
g.out("position", g.add(g.in.position, g.scale(normal, depth)));
|
|
65
|
+
|
|
66
|
+
// the normal impulse: what carried the particle in, and restitution of it back; gated by the contact, because the
|
|
67
|
+
// field gives a normal near a surface the particle has not reached
|
|
68
|
+
const approach = g.max(g.neg(g.dot(g.in.velocity, normal)), 0);
|
|
69
|
+
const impulse = g.mul(g.mul(g.add(1, g.in.restitution), approach), contact);
|
|
70
|
+
const bounced = g.add(g.in.velocity, g.scale(normal, impulse));
|
|
71
|
+
|
|
72
|
+
// Coulomb friction: the velocity along the surface falls by friction times the impulse, at most to rest
|
|
73
|
+
const along = g.sub(bounced, g.scale(normal, g.dot(bounced, normal)));
|
|
74
|
+
const slowed = g.min(g.length(along), g.mul(g.in.friction, impulse));
|
|
75
|
+
|
|
76
|
+
g.out("velocity", g.sub(bounced, g.scale(g.normalize(along), slowed)));
|
|
77
|
+
g.out("contact", contact);
|
|
78
|
+
|
|
79
|
+
return g.build();
|
|
80
|
+
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle_node_parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/particle_node_parameters.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"particle_node_parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/particle_node_parameters.js"],"names":[],"mappings":"AAmNA;;;;;;;;;;;;;;;;;GAiBG;AACH,sDAHW,MAAM,GACJ,MAAM,CAIlB;AAwBD;;;;;;GAMG;AACH,+CAJW,MAAM,GACJ,qBAAqB,EAAE,CAcnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,uDAVW,MAAM;IAEyD,MAAM,GAArE,OAAO,6BAA6B,EAAE,cAAc;IAEgB,cAAc,GAAlF,OAAO,6BAA6B,EAAE,cAAc,GAAC,IAAI;IAEW,aAAa,GAAjF,OAAO,6BAA6B,EAAE,cAAc,GAAC,IAAI;IAEvD,MAAM,CA6BlB;AAED;;;;GAIG;AACH,2CAFa,MAAM;IAAC,WAAW,EAAE,OAAO,8BAA8B,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,qBAAqB,EAAE,CAAA;CAAC,CAAC,CAOrI;;;;sCAtTS,MAAM;AApBhB;;;;;;;;;;;;;;;;GAgBG;AAEH;;;GAGG;AACH;IACI,0FAA0F;;IAE1F,kFAAkF;;IAElF,uFAAuF;;IAEvF,kEAAkE;;IAElE,oDAAoD;;IAEpD,2EAA2E;;IAE3E,kEAAkE;;IAElE;;;OAGG;;IAEH;;;OAGG;;GAEJ;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;GASG;AACH,gDAFU,MAAM,EAAE,CAaf;AAEH;;;;;GAKG;AACH;QAFiB,MAAM,GAAE,MAAM;EAI7B;AAEF;;;;;GAKG;AACH;QAFiB,MAAM,GAAE,qBAAqB,EAAE;EAmG7C;;;;;;;;UAtJW,MAAM;;;;UACN,MAAM;;;;;;;;;;;;YAKC,MAAM;;;;;;;;YACb,OAAO;;;;kBAIP,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle_node_presentation.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/particle_node_presentation.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"particle_node_presentation.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/graph/particle_node_presentation.js"],"names":[],"mappings":"AA+VA;;;;;;;GAOG;AACH,iDAHW,MAAM,GACJ;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAIvD;AA/TD;;;;;;;;GAQG;AACH;QAFiB,MAAM,GAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC;EA4SjE"}
|
|
@@ -335,6 +335,18 @@ export const PARTICLE_NODE_PRESENTATION = Object.freeze({
|
|
|
335
335
|
icon: "M3 8h11a3 3 0 1 0-3-3 M3 12h15a3 3 0 1 1-3 3 M3 16h7",
|
|
336
336
|
help: "the scene's wind at a world position, in metres per second — still air where nothing makes any",
|
|
337
337
|
},
|
|
338
|
+
sceneDistance: {
|
|
339
|
+
// a point, a surface, and the gap between them
|
|
340
|
+
label: "Scene Distance",
|
|
341
|
+
icon: "M3 20h18 M12 6v11 M10 15l2 2 2-2 M12 4a1.5 1.5 0 1 0 0.01 0",
|
|
342
|
+
help: "how far a world position is from the scene's nearest surface, in metres — negative inside a solid",
|
|
343
|
+
},
|
|
344
|
+
sceneSdf: {
|
|
345
|
+
// a surface with its normal standing on it
|
|
346
|
+
label: "Scene Distance and Normal",
|
|
347
|
+
icon: "M3 20h18 M12 20V8 M9 11l3-3 3 3 M17 14a1.5 1.5 0 1 0 0.01 0",
|
|
348
|
+
help: "the scene's distance at a world position in x, and the surface's normal there in yzw — zero where there is none",
|
|
349
|
+
},
|
|
338
350
|
});
|
|
339
351
|
|
|
340
352
|
/**
|
|
@@ -87,6 +87,9 @@
|
|
|
87
87
|
* @param {number} params.scene_database graph handle of the scene database — the emitters' nodes
|
|
88
88
|
* @param {import("../wind/GPUSceneWind.js").GPUSceneWind} params.wind the scene's published wind field,
|
|
89
89
|
* which every pass that runs the VM binds for `SAMPLE_WIND` — still air when nothing produces wind
|
|
90
|
+
* @param {import("../global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js").GPUSceneBrickClipmap} params.scene_sdf
|
|
91
|
+
* the scene's brick clipmap, which every pass that runs the VM binds for `SAMPLE_SCENE_DISTANCE` and
|
|
92
|
+
* `SAMPLE_SCENE_SDF` — a clipmap of no cascade, which reads as no field, while nothing has built it
|
|
90
93
|
* @param {object} params.gpu the persistent buffers, see {@link GPUParticleSystem}. `gpu.alive_read`
|
|
91
94
|
* is the exception: it is the previous frame's alive list and is present only when
|
|
92
95
|
* `frame.rebucket` says this frame reads one
|
|
@@ -117,11 +120,12 @@
|
|
|
117
120
|
* zero workgroups while nothing is bound, and the bind pass is not recorded then
|
|
118
121
|
* @returns {ParticleSimulationHandles}
|
|
119
122
|
*/
|
|
120
|
-
export function graph_particles_simulate({ graph, camera, scene_database, wind, gpu, emitters, capacity, bucket_count, wide_registers, frame, field_bindings, }: {
|
|
123
|
+
export function graph_particles_simulate({ graph, camera, scene_database, wind, scene_sdf, gpu, emitters, capacity, bucket_count, wide_registers, frame, field_bindings, }: {
|
|
121
124
|
graph: import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
|
|
122
125
|
camera: number;
|
|
123
126
|
scene_database: number;
|
|
124
127
|
wind: import("../wind/GPUSceneWind.js").GPUSceneWind;
|
|
128
|
+
scene_sdf: import("../global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js").GPUSceneBrickClipmap;
|
|
125
129
|
gpu: object;
|
|
126
130
|
emitters: {
|
|
127
131
|
capacity: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_particles.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/graph_particles.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH;;;;;;;GAOG;AAEH
|
|
1
|
+
{"version":3,"file":"graph_particles.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/graph_particles.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH;IAtCkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IAC/D,MAAM,EAArB,MAAM;IACS,cAAc,EAA7B,MAAM;IACiD,IAAI,EAA3D,OAAO,yBAAyB,EAAE,YAAY;IAE4D,SAAS,EAAnH,OAAO,oEAAoE,EAAE,oBAAoB;IAGlF,GAAG,EAAlB,MAAM;IAGS,QAAQ;QACC,QAAQ,EAAhC,MAAM;QAEkB,WAAW,EAAnC,MAAM;;IACS,QAAQ,EAAvB,MAAM;IACS,YAAY,EAA3B,MAAM;IAEU,cAAc,EAA9B,OAAO;IAGQ,KAAK;QACC,EAAE,EAAvB,MAAM;QACe,IAAI,EAAzB,MAAM;QACe,KAAK,EAA1B,MAAM;QACiB,QAAQ,GAA/B,OAAO;QACc,WAAW,EAAhC,MAAM;QACe,mBAAmB,EAAxC,MAAM;QACe,YAAY,EAAjC,MAAM;QAGe,eAAe,EAApC,MAAM;QAC6D,eAAe,EAAlF,OAAO,6BAA6B,EAAE,cAAc;;IAErB,cAAc,GAA7C;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC;IAEnB,yBAAyB,CAsWrC;;;;;UArZa,MAAM;;;;WACN,MAAM;;;;eACN,MAAM;;;;;sBACN,MAAM"}
|
|
@@ -138,6 +138,9 @@ const NO_FIELD_BINDINGS = Object.freeze({ group_count: 0 });
|
|
|
138
138
|
* @param {number} params.scene_database graph handle of the scene database — the emitters' nodes
|
|
139
139
|
* @param {import("../wind/GPUSceneWind.js").GPUSceneWind} params.wind the scene's published wind field,
|
|
140
140
|
* which every pass that runs the VM binds for `SAMPLE_WIND` — still air when nothing produces wind
|
|
141
|
+
* @param {import("../global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js").GPUSceneBrickClipmap} params.scene_sdf
|
|
142
|
+
* the scene's brick clipmap, which every pass that runs the VM binds for `SAMPLE_SCENE_DISTANCE` and
|
|
143
|
+
* `SAMPLE_SCENE_SDF` — a clipmap of no cascade, which reads as no field, while nothing has built it
|
|
141
144
|
* @param {object} params.gpu the persistent buffers, see {@link GPUParticleSystem}. `gpu.alive_read`
|
|
142
145
|
* is the exception: it is the previous frame's alive list and is present only when
|
|
143
146
|
* `frame.rebucket` says this frame reads one
|
|
@@ -173,6 +176,7 @@ export function graph_particles_simulate({
|
|
|
173
176
|
camera,
|
|
174
177
|
scene_database,
|
|
175
178
|
wind,
|
|
179
|
+
scene_sdf,
|
|
176
180
|
gpu,
|
|
177
181
|
emitters,
|
|
178
182
|
capacity,
|
|
@@ -185,6 +189,7 @@ export function graph_particles_simulate({
|
|
|
185
189
|
assert.isNonNegativeInteger(camera, "camera");
|
|
186
190
|
assert.isNonNegativeInteger(scene_database, "scene_database");
|
|
187
191
|
assert.defined(wind, "wind");
|
|
192
|
+
assert.defined(scene_sdf, "scene_sdf");
|
|
188
193
|
assert.isPositiveInteger(capacity, "capacity");
|
|
189
194
|
|
|
190
195
|
// Renamed by the bind pass when it writes the field section, so it is threaded like every other
|
|
@@ -360,11 +365,16 @@ export function graph_particles_simulate({
|
|
|
360
365
|
program: gr_program,
|
|
361
366
|
spawn_prefix,
|
|
362
367
|
pool, alive_out: alive_write, dead, counters,
|
|
363
|
-
settings: {
|
|
368
|
+
settings: {
|
|
369
|
+
u_dt: frame.dt, u_time: frame.time, u_frame: frame.index, u_capacity: capacity,
|
|
370
|
+
u_brick_cascade_count: scene_sdf.cascade_count, u_brick_atlas_shift: scene_sdf.atlas_shift,
|
|
371
|
+
},
|
|
364
372
|
};
|
|
365
373
|
|
|
366
|
-
// Taken this frame rather than held: a producer that grows the field replaces its atlas
|
|
374
|
+
// Taken this frame rather than held: a producer that grows the field replaces its atlas, and
|
|
375
|
+
// the clipmap's atlas is replaced when it grows.
|
|
367
376
|
wind.bind(bindings);
|
|
377
|
+
scene_sdf.write_bindings(bindings);
|
|
368
378
|
|
|
369
379
|
const out = wide_registers
|
|
370
380
|
? graph_compute_pass({
|
|
@@ -401,10 +411,14 @@ export function graph_particles_simulate({
|
|
|
401
411
|
emitter_database,
|
|
402
412
|
program: gr_program,
|
|
403
413
|
pool, sim_list: gr_sim_list, alive_out: alive_write, dead, counters,
|
|
404
|
-
settings: {
|
|
414
|
+
settings: {
|
|
415
|
+
u_dt: frame.dt, u_time: frame.time, u_frame: frame.index,
|
|
416
|
+
u_brick_cascade_count: scene_sdf.cascade_count, u_brick_atlas_shift: scene_sdf.atlas_shift,
|
|
417
|
+
},
|
|
405
418
|
};
|
|
406
419
|
|
|
407
420
|
wind.bind(bindings);
|
|
421
|
+
scene_sdf.write_bindings(bindings);
|
|
408
422
|
|
|
409
423
|
const out = wide_registers
|
|
410
424
|
? graph_compute_pass({
|
|
@@ -437,6 +451,7 @@ export function graph_particles_simulate({
|
|
|
437
451
|
graph,
|
|
438
452
|
scene_database,
|
|
439
453
|
wind,
|
|
454
|
+
scene_sdf,
|
|
440
455
|
emitter_database,
|
|
441
456
|
program: gr_program,
|
|
442
457
|
pool, alive_out: alive_write, dead, counters,
|
|
@@ -124,6 +124,31 @@ export class InstructionStream {
|
|
|
124
124
|
* @returns {InstructionStream}
|
|
125
125
|
*/
|
|
126
126
|
random(dst: number, width?: number): InstructionStream;
|
|
127
|
+
/**
|
|
128
|
+
* The scene's signed distance at a world position, metres, out of the solid positive: three lanes of
|
|
129
|
+
* `position` in, one lane out.
|
|
130
|
+
*
|
|
131
|
+
* @param {number} dst
|
|
132
|
+
* @param {number|{kind: number, word: number}} position a register operand word or a literal
|
|
133
|
+
* @param {number} [width] 3, or 4 to read a fourth lane that has no effect
|
|
134
|
+
* @returns {InstructionStream}
|
|
135
|
+
*/
|
|
136
|
+
sampleSceneDistance(dst: number, position: number | {
|
|
137
|
+
kind: number;
|
|
138
|
+
word: number;
|
|
139
|
+
}, width?: number): InstructionStream;
|
|
140
|
+
/**
|
|
141
|
+
* The scene's signed distance and unit normal at a world position: four lanes of `position` read, the fourth
|
|
142
|
+
* with no effect, and four lanes out — the distance, then the normal.
|
|
143
|
+
*
|
|
144
|
+
* @param {number} dst
|
|
145
|
+
* @param {number|{kind: number, word: number}} position a register operand word or a literal
|
|
146
|
+
* @returns {InstructionStream}
|
|
147
|
+
*/
|
|
148
|
+
sampleSceneSdf(dst: number, position: number | {
|
|
149
|
+
kind: number;
|
|
150
|
+
word: number;
|
|
151
|
+
}): InstructionStream;
|
|
127
152
|
/**
|
|
128
153
|
* The scene's wind at a world position, m/s: three lanes of `position` in, three lanes out — four
|
|
129
154
|
* with a zero `w` if asked for.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructionStream.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/isa/InstructionStream.js"],"names":[],"mappings":"AAkCA;;;;;;GAMG;AACH;IACI,yCAAyC;IACzC,cADW,MAAM,EAAE,EAAE,CACH;IAClB,iEAAiE;IACjE,gBADW,MAAM,CACE;IAsBnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SARW,MAAM,QACN,MAAM,OACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,OACnC,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,OACnC,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,UACnC,MAAM,GACJ,iBAAiB,CA6D7B;IAED;;;;;;OAMG;IACH,iBAHW,UAAU,MAAM,CAAC,GACf,iBAAiB,CAS7B;IAID;;;;;OAKG;IACH,SALW,MAAM,OACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,eALW,MAAM,OACN,MAAM,SACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;OAKG;IACH,eALW,MAAM,kBACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;;OASG;IACH,uBANW,MAAM,eACN,MAAM,mBACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAK7B;IAED;;;;;;;;OAQG;IACH,2BALW,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,eACnC,MAAM,mBACN,MAAM,GACJ,iBAAiB,CAK7B;IAED;;;;;;OAMG;IACH,iBANW,MAAM,cACN,MAAM,UAEN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;OAGG;IACH,gBAHW,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GACjC,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,YAJW,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,gBALW,MAAM,YACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,UACnC,MAAM,GACJ,iBAAiB,CAI7B;IAED;;OAEG;IACH,QAFa,iBAAiB,CAI7B;IAED;;OAEG;IACH,gCAEC;IAED;;OAEG;IACH,WAFa,WAAW,CAWvB;;CACJ"}
|
|
1
|
+
{"version":3,"file":"InstructionStream.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/isa/InstructionStream.js"],"names":[],"mappings":"AAkCA;;;;;;GAMG;AACH;IACI,yCAAyC;IACzC,cADW,MAAM,EAAE,EAAE,CACH;IAClB,iEAAiE;IACjE,gBADW,MAAM,CACE;IAsBnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SARW,MAAM,QACN,MAAM,OACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,OACnC,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,OACnC,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,UACnC,MAAM,GACJ,iBAAiB,CA6D7B;IAED;;;;;;OAMG;IACH,iBAHW,UAAU,MAAM,CAAC,GACf,iBAAiB,CAS7B;IAID;;;;;OAKG;IACH,SALW,MAAM,OACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,eALW,MAAM,OACN,MAAM,SACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;OAKG;IACH,eALW,MAAM,kBACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;;OASG;IACH,uBANW,MAAM,eACN,MAAM,mBACN,MAAM,UACN,MAAM,GACJ,iBAAiB,CAK7B;IAED;;;;;;;;OAQG;IACH,2BALW,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,eACnC,MAAM,mBACN,MAAM,GACJ,iBAAiB,CAK7B;IAED;;;;;;OAMG;IACH,iBANW,MAAM,cACN,MAAM,UAEN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;OAGG;IACH,gBAHW,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GACjC,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,YAJW,MAAM,UACN,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,yBALW,MAAM,YACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,UACnC,MAAM,GACJ,iBAAiB,CAI7B;IAED;;;;;;;OAOG;IACH,oBAJW,MAAM,YACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GACjC,iBAAiB,CAI7B;IAED;;;;;;;;OAQG;IACH,gBALW,MAAM,YACN,MAAM,GAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,UACnC,MAAM,GACJ,iBAAiB,CAI7B;IAED;;OAEG;IACH,QAFa,iBAAiB,CAI7B;IAED;;OAEG;IACH,gCAEC;IAED;;OAEG;IACH,WAFa,WAAW,CAWvB;;CACJ"}
|
|
@@ -260,6 +260,31 @@ export class InstructionStream {
|
|
|
260
260
|
return this.emit(VM_OP.RANDOM, dst, 0, 0, 0, width);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
/**
|
|
264
|
+
* The scene's signed distance at a world position, metres, out of the solid positive: three lanes of
|
|
265
|
+
* `position` in, one lane out.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} dst
|
|
268
|
+
* @param {number|{kind: number, word: number}} position a register operand word or a literal
|
|
269
|
+
* @param {number} [width] 3, or 4 to read a fourth lane that has no effect
|
|
270
|
+
* @returns {InstructionStream}
|
|
271
|
+
*/
|
|
272
|
+
sampleSceneDistance(dst, position, width = undefined) {
|
|
273
|
+
return this.emit(VM_OP.SAMPLE_SCENE_DISTANCE, dst, position, 0, 0, width);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The scene's signed distance and unit normal at a world position: four lanes of `position` read, the fourth
|
|
278
|
+
* with no effect, and four lanes out — the distance, then the normal.
|
|
279
|
+
*
|
|
280
|
+
* @param {number} dst
|
|
281
|
+
* @param {number|{kind: number, word: number}} position a register operand word or a literal
|
|
282
|
+
* @returns {InstructionStream}
|
|
283
|
+
*/
|
|
284
|
+
sampleSceneSdf(dst, position) {
|
|
285
|
+
return this.emit(VM_OP.SAMPLE_SCENE_SDF, dst, position, 0, 0, 4);
|
|
286
|
+
}
|
|
287
|
+
|
|
263
288
|
/**
|
|
264
289
|
* The scene's wind at a world position, m/s: three lanes of `position` in, three lanes out — four
|
|
265
290
|
* with a zero `w` if asked for.
|
|
@@ -425,7 +425,16 @@ export namespace VM_OP {
|
|
|
425
425
|
let SELECT: number;
|
|
426
426
|
let RANDOM: number;
|
|
427
427
|
let SAMPLE_WIND: number;
|
|
428
|
+
let SAMPLE_SCENE_DISTANCE: number;
|
|
429
|
+
let SAMPLE_SCENE_SDF: number;
|
|
428
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* The distance `SAMPLE_SCENE_DISTANCE` and `SAMPLE_SCENE_SDF` answer where the host has no field to read: the
|
|
433
|
+
* largest finite `f32`, farther than any surface the field could report, and finite, so arithmetic over it stays
|
|
434
|
+
* defined on a device that does not keep infinities.
|
|
435
|
+
* @type {number}
|
|
436
|
+
*/
|
|
437
|
+
export const VM_SCENE_DISTANCE_ABSENT: number;
|
|
429
438
|
/**
|
|
430
439
|
* How an opcode reads the instruction's width field — the lane count it operates on.
|
|
431
440
|
*/
|