@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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { RenderPipelineDescriptor } from "../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
|
|
2
|
+
import { CAMERA_RESOURCE } from "../camera/CAMERA_RESOURCE.js";
|
|
3
|
+
import { DEPTH_STENCIL_STATE_SHADOW } from "../rasterize/DEPTH_STENCIL_STATE_SHADOW.js";
|
|
4
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
5
|
+
import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
|
|
6
|
+
import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
|
|
7
|
+
import { vec2f, vec4u } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
8
|
+
import { WebGPUArray } from "../shader/type/WebGPUArray.js";
|
|
9
|
+
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
10
|
+
import { HAIR_CLASS_SHIFT } from "./HAIR.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A shadow view's rectangle as the hair draws into it.
|
|
14
|
+
* @type {WebGPUStruct}
|
|
15
|
+
*/
|
|
16
|
+
export const HAIR_SHADOW_TARGET_STRUCT = WebGPUStruct.from({
|
|
17
|
+
/** the view's rectangle in the atlas, texels */
|
|
18
|
+
resolution: vec2f,
|
|
19
|
+
}, "HairShadowTarget").pack();
|
|
20
|
+
|
|
21
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
22
|
+
|
|
23
|
+
resources.createGroup()
|
|
24
|
+
.add(CAMERA_RESOURCE)
|
|
25
|
+
.addUniform("hair_shadow_view", HAIR_SHADOW_TARGET_STRUCT)
|
|
26
|
+
.addStorageBuffer("hair_list", WebGPUArray.u32)
|
|
27
|
+
.addStorageBuffer("hair_points", WebGPUArray.from(vec4u));
|
|
28
|
+
|
|
29
|
+
const body = CodeChunk.from(
|
|
30
|
+
//language=WGSL
|
|
31
|
+
`
|
|
32
|
+
// a deformed point as it is now: x, y, z, then half its drawn width, negative where the view drew it at none
|
|
33
|
+
fn hair_point(slot: u32) -> vec4<f32> {
|
|
34
|
+
return bitcast<vec4<f32>>(hair_points[slot]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@vertex
|
|
38
|
+
fn vs_main(@builtin(vertex_index) vertex: u32, @builtin(instance_index) instance: u32) -> @builtin(position) vec4<f32> {
|
|
39
|
+
let entry = hair_list[instance];
|
|
40
|
+
let slot = entry & ${2 ** HAIR_CLASS_SHIFT - 1}u;
|
|
41
|
+
let segments = 1u << (entry >> ${HAIR_CLASS_SHIFT}u);
|
|
42
|
+
|
|
43
|
+
// a pair of vertices a point, one either side of it
|
|
44
|
+
let j = min(vertex >> 1u, segments);
|
|
45
|
+
let side = f32(vertex & 1u) * 2.0 - 1.0;
|
|
46
|
+
|
|
47
|
+
let point = hair_point(slot + j);
|
|
48
|
+
let before = hair_point(slot + max(j, 1u) - 1u).xyz;
|
|
49
|
+
let after = hair_point(slot + min(j + 1u, segments)).xyz;
|
|
50
|
+
|
|
51
|
+
// across the strand and across the way to the light: along a directional view's axis, its projection being
|
|
52
|
+
// orthographic, or to a spot light's eye
|
|
53
|
+
let orthographic = camera.projection_matrix[3][3] == 1.0;
|
|
54
|
+
let toward = select(camera.transform[3].xyz - point.xyz, camera.view_matrix_inverse[2].xyz, orthographic);
|
|
55
|
+
let raw = cross(after - before, toward);
|
|
56
|
+
let raw_length = length(raw);
|
|
57
|
+
|
|
58
|
+
// a strand seen end on is a dot: any way across will do
|
|
59
|
+
let across = select(camera.transform[0].xyz, raw / raw_length, raw_length > 1e-20);
|
|
60
|
+
|
|
61
|
+
// the strand's own width, whether or not the view drew it
|
|
62
|
+
let half_width = abs(point.w);
|
|
63
|
+
|
|
64
|
+
let clip = camera.view_projection_matrix * vec4<f32>(point.xyz, 1.0);
|
|
65
|
+
let edge = camera.view_projection_matrix * vec4<f32>(point.xyz + across * half_width, 1.0);
|
|
66
|
+
|
|
67
|
+
// texels a unit of normalised device coordinates spans
|
|
68
|
+
let texels = 0.5 * hair_shadow_view.resolution;
|
|
69
|
+
|
|
70
|
+
// half the strand's width in the map, texels, and the way it runs
|
|
71
|
+
let offset = (edge.xy / max(abs(edge.w), 1e-6) - clip.xy / max(abs(clip.w), 1e-6)) * texels;
|
|
72
|
+
let real = length(offset);
|
|
73
|
+
let way = select(vec2<f32>(1.0, 0.0), offset / max(real, 1e-12), real >= 1e-6);
|
|
74
|
+
|
|
75
|
+
// 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
|
+
let drawn = select(select(0.0, 0.5, real > share * 0.5), real, real >= 0.5);
|
|
81
|
+
|
|
82
|
+
var position = clip + vec4<f32>(way * (drawn * side) / texels * clip.w, 0.0, 0.0);
|
|
83
|
+
|
|
84
|
+
// a view's near plane is fitted to the scene's meshes and the strands reach past them: a point nearer the light
|
|
85
|
+
// than the plane is held on it, reversed depth's 1, and shadows everything behind it as it would have
|
|
86
|
+
position.z = min(position.z, position.w);
|
|
87
|
+
|
|
88
|
+
return position;
|
|
89
|
+
}
|
|
90
|
+
`);
|
|
91
|
+
|
|
92
|
+
const descriptor = ShaderDescriptor.from({ label: "Hair Shadow", body, resources });
|
|
93
|
+
|
|
94
|
+
/**
|
|
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).
|
|
97
|
+
*
|
|
98
|
+
* @type {ShaderResourceSetDescriptor}
|
|
99
|
+
*/
|
|
100
|
+
export const HAIR_SHADOW_RESOURCES = resources;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Draws the frame's strands into a shadow view's depth, as the scene's casters are drawn
|
|
104
|
+
* (`DEPTH_STENCIL_STATE_SHADOW`).
|
|
105
|
+
*
|
|
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`),
|
|
109
|
+
* 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
|
+
*
|
|
115
|
+
* @type {RenderPipelineDescriptor}
|
|
116
|
+
*/
|
|
117
|
+
export const HAIR_SHADOW_PIPELINE = RenderPipelineDescriptor.from({
|
|
118
|
+
label: "Hair Shadow",
|
|
119
|
+
layout: resources.generatePipelineLayout(GPUShaderStage.VERTEX),
|
|
120
|
+
vertex: { module: { code: descriptor.source }, entryPoint: "vs_main" },
|
|
121
|
+
depthStencil: DEPTH_STENCIL_STATE_SHADOW,
|
|
122
|
+
primitive: { topology: "triangle-strip", cullMode: "none" },
|
|
123
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lays the frame's draw list out by point class, once the level of detail has added every instance's prefix to its
|
|
3
3
|
* class's: a thread a class, writing where its region starts, the classes' prefixes summed in class order, as its
|
|
4
|
-
* region's start and as its append cursor
|
|
4
|
+
* region's start and as its append cursor, and its start plus the strands of the instances the view draws as the
|
|
5
|
+
* cursor of those only the shadow views draw. A region holds every strand its class can be asked for. One workgroup.
|
|
5
6
|
*
|
|
6
7
|
* @type {ComputeShader}
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_hair_classes.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_classes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_hair_classes.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_classes.js"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,kCAFU,aAAa,CAqBpB;AAEH,mDAG2B;AAU3B;;;;;;;GAOG;AACH,oCAFU,aAAa,CAqBpB;8BAxF2B,4BAA4B;6BAI7B,gCAAgC"}
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
HAIR_CLASS_COUNT,
|
|
9
9
|
HAIR_COUNTER_BASES,
|
|
10
10
|
HAIR_COUNTER_CURSORS,
|
|
11
|
+
HAIR_COUNTER_SHADOW_CURSORS,
|
|
12
|
+
HAIR_COUNTER_SHADOW_STRANDS,
|
|
11
13
|
HAIR_DRAW_ARGS_WORDS
|
|
12
14
|
} from "./HAIR.js";
|
|
13
15
|
|
|
@@ -19,7 +21,8 @@ regions_resources.createGroup()
|
|
|
19
21
|
/**
|
|
20
22
|
* Lays the frame's draw list out by point class, once the level of detail has added every instance's prefix to its
|
|
21
23
|
* class's: a thread a class, writing where its region starts, the classes' prefixes summed in class order, as its
|
|
22
|
-
* region's start and as its append cursor
|
|
24
|
+
* region's start and as its append cursor, and its start plus the strands of the instances the view draws as the
|
|
25
|
+
* cursor of those only the shadow views draw. A region holds every strand its class can be asked for. One workgroup.
|
|
23
26
|
*
|
|
24
27
|
* @type {ComputeShader}
|
|
25
28
|
*/
|
|
@@ -34,11 +37,12 @@ fn main(@builtin(local_invocation_index) point_class: u32) {
|
|
|
34
37
|
var start = 0u;
|
|
35
38
|
|
|
36
39
|
for (var c = 0u; c < point_class; c++) {
|
|
37
|
-
start += atomicLoad(&hair_counters[c]);
|
|
40
|
+
start += atomicLoad(&hair_counters[c]) + atomicLoad(&hair_counters[${HAIR_COUNTER_SHADOW_STRANDS}u + c]);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
atomicStore(&hair_counters[${HAIR_COUNTER_BASES}u + point_class], start);
|
|
41
44
|
atomicStore(&hair_counters[${HAIR_COUNTER_CURSORS}u + point_class], start);
|
|
45
|
+
atomicStore(&hair_counters[${HAIR_COUNTER_SHADOW_CURSORS}u + point_class], start + atomicLoad(&hair_counters[point_class]));
|
|
42
46
|
}
|
|
43
47
|
`),
|
|
44
48
|
});
|
|
@@ -10,7 +10,8 @@ export const HAIR_CULL_SETTINGS: WebGPUStruct;
|
|
|
10
10
|
* vanishes at once.
|
|
11
11
|
*
|
|
12
12
|
* The point, every `2^level`-th of the strand's rest points, is carried by its entity's world matrix as it is and as
|
|
13
|
-
* it was a frame ago into its place in `hair_points` (`HAIR.js`)
|
|
13
|
+
* it was a frame ago into its place in `hair_points` (`HAIR.js`); a simulated group's, by its strand's guide
|
|
14
|
+
* (`hair_guided_point`), its nodes and frames now and a frame ago. No point is drawn narrower than the view's pixel
|
|
14
15
|
* floor, so one narrower than it would be drawn wider than it is: a point of width `w` under the floor `p` at its
|
|
15
16
|
* own depth is drawn, at `p`, only by the strands whose share of the floor (a number in [0, 1) stratified over
|
|
16
17
|
* ranks) is under `w / p`, and at no width by the rest (a negative width). The drawn area is then the strands' own
|
|
@@ -21,7 +22,12 @@ export const HAIR_CULL_SETTINGS: WebGPUStruct;
|
|
|
21
22
|
* The volume was cleared by `shader_hair_volume_clear`.
|
|
22
23
|
*
|
|
23
24
|
* The thread of a kept strand's root appends it to its class's region of `hair_list` (`chunk_subgroup_keyed_append`
|
|
24
|
-
* on the class's cursor
|
|
25
|
+
* on the class's cursor, or on its cursor for the shadow views' own strands) as its slot and class, and where the
|
|
26
|
+
* strands cast shadows, its shadow words past the list's capacity (`HAIR.js`). An entry the list cannot hold is
|
|
27
|
+
* dropped; the cursor still counts it.
|
|
28
|
+
*
|
|
29
|
+
* An instance only the shadow views draw (its LOD record's `fixed_pixel` not negative) is thinned at that texel, to
|
|
30
|
+
* a texel's width, in place of its roots' pixels at their depth.
|
|
25
31
|
*
|
|
26
32
|
* @type {ComputeShader}
|
|
27
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_hair_cull.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_cull.js"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -16,8 +16,18 @@ import { WebGPUArray } from "../shader/type/WebGPUArray.js";
|
|
|
16
16
|
import { WebGPUBufferType } from "../shader/type/WebGPUBufferType.js";
|
|
17
17
|
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
18
18
|
import { chunk_hair_lod, chunk_hair_rest_point, HAIR_GROOMS_RESOURCE } from "./chunk_hair_strand.js";
|
|
19
|
+
import { chunk_hair_guided_point, HAIR_GUIDE_STATE_RESOURCE } from "./chunk_hair_guide.js";
|
|
19
20
|
import { chunk_hair_volume_layout } from "./chunk_hair_volume.js";
|
|
20
|
-
import {
|
|
21
|
+
import { HAIR_STATE_NONE } from "./HAIR_SIMULATION.js";
|
|
22
|
+
import {
|
|
23
|
+
HAIR_CLASS_SHIFT,
|
|
24
|
+
HAIR_COUNTER_CURSORS,
|
|
25
|
+
HAIR_COUNTER_SHADOW_CURSORS,
|
|
26
|
+
HAIR_LIST_SHADOW_WORDS,
|
|
27
|
+
HAIR_ROW_BITS,
|
|
28
|
+
HAIR_VOLUME_FIXED_ONE,
|
|
29
|
+
HAIR_VOLUME_LAY_STEP_LIMIT
|
|
30
|
+
} from "./HAIR.js";
|
|
21
31
|
import { HAIR_INSTANCE_DESCRIPTOR } from "./HAIR_DATABASE_SPEC.js";
|
|
22
32
|
import { HAIR_LOD_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
|
|
23
33
|
|
|
@@ -30,6 +40,8 @@ export const HAIR_CULL_SETTINGS = WebGPUStruct.from({
|
|
|
30
40
|
point_capacity: u32,
|
|
31
41
|
/** entries the frame's draw list holds */
|
|
32
42
|
list_capacity: u32,
|
|
43
|
+
/** 1 where the strands cast shadows: each entry's shadow words are written past the list's capacity */
|
|
44
|
+
casts_shadows: u32,
|
|
33
45
|
}, "HairCullSettings");
|
|
34
46
|
|
|
35
47
|
const resources = new ShaderResourceSetDescriptor();
|
|
@@ -46,11 +58,21 @@ resources.createGroup()
|
|
|
46
58
|
.addStorageBuffer("hair_counters", WebGPUArray.from(atomic_u32), true)
|
|
47
59
|
.addStorageBuffer("hair_points", WebGPUArray.from(vec4u), true)
|
|
48
60
|
.addStorageBuffer("hair_list", WebGPUArray.u32, true)
|
|
49
|
-
.addStorageBuffer("hair_volume", WebGPUArray.from(atomic_u32), true)
|
|
61
|
+
.addStorageBuffer("hair_volume", WebGPUArray.from(atomic_u32), true)
|
|
62
|
+
.add(HAIR_GUIDE_STATE_RESOURCE);
|
|
50
63
|
|
|
51
64
|
const body = CodeChunk.from(
|
|
52
65
|
//language=WGSL
|
|
53
66
|
`
|
|
67
|
+
// a point of a strand as it is now, carried by its guide when its group is simulated and by its entity otherwise
|
|
68
|
+
fn hair_cull_point(instance: ${HAIR_INSTANCE_DESCRIPTOR.type.wgsl_ref}, m: mat4x4<f32>, strand: u32, point: u32) -> vec3<f32> {
|
|
69
|
+
if (hair_state_live(instance)) {
|
|
70
|
+
return hair_guided_point(instance, strand, point, m, m[3].xyz, false);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (hair_strand_frame(instance, strand, m, false) * vec4<f32>(hair_rest_point(instance, strand, point).xyz, 1.0)).xyz;
|
|
74
|
+
}
|
|
75
|
+
|
|
54
76
|
@compute @workgroup_size(${COMPUTE_SHADER_DEFAULT_GROUP_SIZE})
|
|
55
77
|
fn main(
|
|
56
78
|
@builtin(workgroup_id) workgroup_id: vec3<u32>,
|
|
@@ -64,6 +86,8 @@ fn main(
|
|
|
64
86
|
|
|
65
87
|
var key = ${SUBGROUP_KEYED_APPEND_NONE}u;
|
|
66
88
|
var entry = 0u;
|
|
89
|
+
var widest = 0.0;
|
|
90
|
+
var reach = 0.0;
|
|
67
91
|
|
|
68
92
|
if (row < rows) {
|
|
69
93
|
var point = thread;
|
|
@@ -82,10 +106,14 @@ fn main(
|
|
|
82
106
|
|
|
83
107
|
let m = node.global;
|
|
84
108
|
|
|
85
|
-
// the strand's own share kept, at its root's depth: never more than the prefix's, the root being no nearer
|
|
86
|
-
|
|
109
|
+
// the strand's own share kept, at its root's depth: never more than the prefix's, the root being no nearer; an
|
|
110
|
+
// instance only the shadow views draw is thinned at one texel to a texel's width
|
|
111
|
+
let shadow_only = lod.fixed_pixel >= 0.0;
|
|
112
|
+
let floor_pixels = select(settings.pixel_floor, 1.0, shadow_only);
|
|
113
|
+
let root = (hair_strand_frame(instance, strand, m, false) * vec4<f32>(hair_rest_point(instance, strand, 0u).xyz, 1.0)).xyz;
|
|
87
114
|
let depth = max(hair_view_depth(root), camera.clip_near_far.x);
|
|
88
|
-
let
|
|
115
|
+
let root_pixel = select(hair_pixel_size(depth, settings.resolution.y), lod.fixed_pixel, shadow_only);
|
|
116
|
+
let kept = hair_kept_fraction(instance.width_mean * lod.scale, root_pixel, floor_pixels);
|
|
89
117
|
|
|
90
118
|
// the strand at the boundary fades by its width, so the kept strands' widths always sum to the group's
|
|
91
119
|
let presence = kept * f32(instance.strand_count) - f32(strand);
|
|
@@ -95,18 +123,27 @@ fn main(
|
|
|
95
123
|
|
|
96
124
|
let rest = hair_rest_point(instance, strand, j << lod.level);
|
|
97
125
|
|
|
98
|
-
let now = (m
|
|
99
|
-
|
|
126
|
+
let now = hair_cull_point(instance, m, strand, j << lod.level);
|
|
127
|
+
|
|
128
|
+
var before: vec3<f32>;
|
|
129
|
+
|
|
130
|
+
if (hair_state_live(instance)) {
|
|
131
|
+
// the guide's nodes and frames a frame ago, from this frame's anchor, carried by the entity's frame then
|
|
132
|
+
before = hair_guided_point(instance, strand, j << lod.level, node.prev_global, m[3].xyz, true);
|
|
133
|
+
} else {
|
|
134
|
+
before = (hair_strand_frame(instance, strand, node.prev_global, true) * vec4<f32>(rest.xyz, 1.0)).xyz;
|
|
135
|
+
}
|
|
100
136
|
|
|
101
137
|
var half_width = rest.w * saturate(presence) / kept * lod.scale * 0.5;
|
|
102
138
|
|
|
103
139
|
// the segment to the next point, into the density volume: the strands it adds, (pi / 4) w L / h^2 along a
|
|
104
|
-
// voxel's edge, laid at steps of no more than two thirds of a voxel,
|
|
140
|
+
// voxel's edge, laid at steps of no more than two thirds of a voxel, however long the segment: a straight
|
|
141
|
+
// strand is drawn as one segment, and a capped number of steps would leave voxels along it empty
|
|
105
142
|
if (lod.voxel_size > 0.0 && j < segments) {
|
|
106
|
-
let next = (
|
|
143
|
+
let next = hair_cull_point(instance, m, strand, (j + 1u) << lod.level);
|
|
107
144
|
let along = next - now;
|
|
108
145
|
let length_ = length(along);
|
|
109
|
-
let steps = clamp(u32(ceil(length_ * 1.5 / lod.voxel_size)), 1u,
|
|
146
|
+
let steps = clamp(u32(ceil(length_ * 1.5 / lod.voxel_size)), 1u, ${HAIR_VOLUME_LAY_STEP_LIMIT}u);
|
|
110
147
|
|
|
111
148
|
let h = lod.voxel_size;
|
|
112
149
|
let deposit = 0.7853982 * (2.0 * half_width) * (length_ / f32(steps)) / (h * h);
|
|
@@ -124,11 +161,13 @@ fn main(
|
|
|
124
161
|
// a point narrower than the floor is drawn at the floor by as many strands as its width is of the floor:
|
|
125
162
|
// by those whose share of the floor, stratified over any run of ranks, is under its width's
|
|
126
163
|
let share = fract(f32(strand) * 0.618034 + 0.5);
|
|
127
|
-
let
|
|
164
|
+
let point_pixel = select(hair_pixel_size(max(hair_view_depth(now), camera.clip_near_far.x), settings.resolution.y), lod.fixed_pixel, shadow_only);
|
|
165
|
+
let floor_half = 0.5 * floor_pixels * point_pixel;
|
|
128
166
|
|
|
129
167
|
if (half_width < share * floor_half) {
|
|
130
|
-
// drawn at no width, the floor not applied
|
|
131
|
-
|
|
168
|
+
// drawn at no width, the floor not applied: negative, holding the width for a view whose floor is
|
|
169
|
+
// finer, and negative even at no width
|
|
170
|
+
half_width = min(-half_width, -1.17549435e-38);
|
|
132
171
|
}
|
|
133
172
|
|
|
134
173
|
let variation = hair_grooms[instance.strands + strand] & 0xFFu;
|
|
@@ -136,10 +175,14 @@ fn main(
|
|
|
136
175
|
hair_points[slot + j] = vec4<u32>(bitcast<vec3<u32>>(now), bitcast<u32>(half_width));
|
|
137
176
|
hair_points[settings.point_capacity + slot + j] = vec4<u32>(bitcast<vec3<u32>>(before), row | (variation << ${HAIR_ROW_BITS}u));
|
|
138
177
|
|
|
139
|
-
// the root's thread lists the strand
|
|
178
|
+
// 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)
|
|
140
181
|
if (j == 0u) {
|
|
141
|
-
key = ${HAIR_COUNTER_CURSORS}u + lod.point_class;
|
|
182
|
+
key = select(${HAIR_COUNTER_CURSORS}u, ${HAIR_COUNTER_SHADOW_CURSORS}u, shadow_only) + lod.point_class;
|
|
142
183
|
entry = slot | (lod.point_class << ${HAIR_CLASS_SHIFT}u);
|
|
184
|
+
widest = 0.5 * instance.width_max * saturate(presence) / kept * lod.scale;
|
|
185
|
+
reach = (instance.guide_length_max + instance.guide_reach) * lod.scale + widest;
|
|
143
186
|
}
|
|
144
187
|
}
|
|
145
188
|
}
|
|
@@ -148,6 +191,13 @@ fn main(
|
|
|
148
191
|
|
|
149
192
|
if (place < settings.list_capacity) {
|
|
150
193
|
hair_list[place] = entry;
|
|
194
|
+
|
|
195
|
+
if (settings.casts_shadows != 0u && key != ${SUBGROUP_KEYED_APPEND_NONE}u) {
|
|
196
|
+
let at = settings.list_capacity + place * ${HAIR_LIST_SHADOW_WORDS}u;
|
|
197
|
+
|
|
198
|
+
hair_list[at] = bitcast<u32>(widest);
|
|
199
|
+
hair_list[at + 1u] = bitcast<u32>(reach);
|
|
200
|
+
}
|
|
151
201
|
}
|
|
152
202
|
}
|
|
153
203
|
`, [
|
|
@@ -159,6 +209,7 @@ fn main(
|
|
|
159
209
|
chunk_hair_rest_point,
|
|
160
210
|
chunk_hair_lod,
|
|
161
211
|
chunk_hair_volume_layout,
|
|
212
|
+
chunk_hair_guided_point,
|
|
162
213
|
]);
|
|
163
214
|
|
|
164
215
|
/**
|
|
@@ -172,7 +223,8 @@ fn main(
|
|
|
172
223
|
* vanishes at once.
|
|
173
224
|
*
|
|
174
225
|
* The point, every `2^level`-th of the strand's rest points, is carried by its entity's world matrix as it is and as
|
|
175
|
-
* it was a frame ago into its place in `hair_points` (`HAIR.js`)
|
|
226
|
+
* it was a frame ago into its place in `hair_points` (`HAIR.js`); a simulated group's, by its strand's guide
|
|
227
|
+
* (`hair_guided_point`), its nodes and frames now and a frame ago. No point is drawn narrower than the view's pixel
|
|
176
228
|
* floor, so one narrower than it would be drawn wider than it is: a point of width `w` under the floor `p` at its
|
|
177
229
|
* own depth is drawn, at `p`, only by the strands whose share of the floor (a number in [0, 1) stratified over
|
|
178
230
|
* ranks) is under `w / p`, and at no width by the rest (a negative width). The drawn area is then the strands' own
|
|
@@ -183,7 +235,12 @@ fn main(
|
|
|
183
235
|
* The volume was cleared by `shader_hair_volume_clear`.
|
|
184
236
|
*
|
|
185
237
|
* The thread of a kept strand's root appends it to its class's region of `hair_list` (`chunk_subgroup_keyed_append`
|
|
186
|
-
* on the class's cursor
|
|
238
|
+
* on the class's cursor, or on its cursor for the shadow views' own strands) as its slot and class, and where the
|
|
239
|
+
* strands cast shadows, its shadow words past the list's capacity (`HAIR.js`). An entry the list cannot hold is
|
|
240
|
+
* dropped; the cursor still counts it.
|
|
241
|
+
*
|
|
242
|
+
* An instance only the shadow views draw (its LOD record's `fixed_pixel` not negative) is thinned at that texel, to
|
|
243
|
+
* a texel's width, in place of its roots' pixels at their depth.
|
|
187
244
|
*
|
|
188
245
|
* @type {ComputeShader}
|
|
189
246
|
*/
|
|
@@ -7,7 +7,12 @@ export const HAIR_LOD_SETTINGS: WebGPUStruct;
|
|
|
7
7
|
/**
|
|
8
8
|
* Each instance's level of detail for the frame, a thread a row of the instance table through its page iterator:
|
|
9
9
|
*
|
|
10
|
-
* - its group's box, in the world, against the view's frustum
|
|
10
|
+
* - its group's box, in the world, against the view's frustum. A simulated group's box is its guides' bounds as the
|
|
11
|
+
* solver gathered them (`hair_guide_bounds`), widened by its reach and its widest strand. An instance outside the
|
|
12
|
+
* frustum is drawn only by the shadow views (`hair_shadow_views`, the first `settings.shadow_view_count`) its box
|
|
13
|
+
* reaches into, their near planes aside, and by no view where it reaches none. It is then thinned at the finest of
|
|
14
|
+
* their texels to a texel's width (`fixed_pixel`), its strands are counted apart from the view's
|
|
15
|
+
* (`HAIR_COUNTER_SHADOW_STRANDS`), and it has no rectangle and no volume;
|
|
11
16
|
* - its screen rectangle: the box widened by the widest a kept strand is drawn (its widest point over its share kept
|
|
12
17
|
* at the box's far side), projected, and widened again by the pixel floor; or the whole view when the box reaches
|
|
13
18
|
* behind the eye;
|
|
@@ -19,8 +24,9 @@ export const HAIR_LOD_SETTINGS: WebGPUStruct;
|
|
|
19
24
|
* spacing (the roots' over the root of the share kept) and the box's longest side over
|
|
20
25
|
* `HAIR_VOLUME_DIMENSION_LIMIT`, every level reserved from the frame's voxels.
|
|
21
26
|
*
|
|
22
|
-
* Writes the row's points, `prefix × (2^class + 1)`, into `hair_counts`, the list the cull's scan sums; its
|
|
23
|
-
*
|
|
27
|
+
* Writes the row's points, `prefix × (2^class + 1)`, into `hair_counts`, the list the cull's scan sums; its voxels
|
|
28
|
+
* of level 1 and of level 2 into `hair_mip_1_counts` and `hair_mip_2_counts`, the lists the mip passes' scans sum;
|
|
29
|
+
* and its record into `hair_lod`. Rows it does
|
|
24
30
|
* not visit keep what the buffers were cleared to. `hair_counters` is zero on entry. Points past
|
|
25
31
|
* `settings.point_capacity` are refused: the instance draws nothing this frame, and the count it asked for stays
|
|
26
32
|
* in the counters for its owner to read.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader_hair_lod.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_lod.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shader_hair_lod.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_lod.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,sCAFU,MAAM,CAE0B;AAI1C,6CAesB;AA0RtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8BAFU,aAAa,CAMpB;6BA9V0B,gCAAgC;8BAL/B,4BAA4B"}
|