@woosh/meep-engine 3.75.0 → 3.76.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/package.json +1 -1
- package/src/engine/asset/GameAssetType.d.ts +1 -0
- package/src/engine/asset/GameAssetType.js +5 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts +33 -0
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/GroomAssetLoader.js +99 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts +47 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/Hair.js +61 -0
- package/src/engine/graphics/hair/Groom.d.ts +130 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -0
- package/src/engine/graphics/hair/Groom.js +193 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +24 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +77 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts +85 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_group.js +487 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts +29 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_generate_scalp.js +184 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts +15 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_rank_order.js +53 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts +12 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_root_spacing.js +120 -0
- package/src/engine/graphics3/HairSystem.d.ts +102 -0
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairSystem.js +456 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/assets/textures/hair_scattering.bin +0 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts +11 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts.map +1 -1
- package/src/shade/device/pipeline/PipelineEnquiry.js +13 -0
- package/src/shade/playground/hair/index.html +50 -0
- package/src/shade/playground/hair/main.d.ts +2 -0
- package/src/shade/playground/hair/main.d.ts.map +1 -0
- package/src/shade/playground/hair/main.js +274 -0
- package/src/shade/playground/screen_probes/README.md +54 -0
- package/src/shade/playground/screen_probes/index.html +271 -0
- package/src/shade/playground/screen_probes/main.d.ts +8 -0
- package/src/shade/playground/screen_probes/main.d.ts.map +1 -0
- package/src/shade/playground/screen_probes/main.js +527 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +54 -8
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts +6 -0
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts.map +1 -1
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.js +10 -0
- 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/deferred/chunk_read_gBuffer_material.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_read_gBuffer_material.js +3 -1
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts +23 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +111 -0
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +17 -6
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +26 -21
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts +12 -22
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.js +20 -100
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.js +6 -4
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts +15 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +47 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts +101 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts.map +1 -0
- package/src/shade/renderer/extension/ViewLighting.js +168 -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/brick4/gpu/draw/shader_brick4_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +15 -7
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +40 -9
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +23 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +26 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +6 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +13 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +23 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +2 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +29 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +102 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +8 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +27 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +11 -5
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +28 -10
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +36 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +149 -4
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js +3 -1
- package/src/shade/renderer/hair/GPUHairSystem.d.ts +159 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -0
- package/src/shade/renderer/hair/GPUHairSystem.js +1132 -0
- package/src/shade/renderer/hair/HAIR.d.ts +102 -0
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR.js +115 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts +17 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +71 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +11 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +48 -0
- package/src/shade/renderer/hair/HairFrame.d.ts +41 -0
- package/src/shade/renderer/hair/HairFrame.d.ts.map +1 -0
- package/src/shade/renderer/hair/HairFrame.js +76 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +42 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.js +170 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +30 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +131 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts +32 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.js +116 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts +40 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_strand.js +85 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts +31 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_volume.js +106 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts +24 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_id_draw.js +135 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts +53 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_lighting.js +270 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts +75 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_scattering_lut.js +271 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts +33 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_stamp.js +175 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts +21 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_classes.js +86 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +31 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_cull.js +194 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +33 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_lod.js +268 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts +28 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_volume.js +167 -0
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts +31 -0
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.js +36 -21
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +60 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.js +417 -0
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +4 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js +3 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts +4 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.js +9 -0
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts +16 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +47 -3
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.js +5 -3
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.js +6 -5
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.js +5 -2
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +5 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +4 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.js +5 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +7 -4
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +13 -8
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +18 -14
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts +3 -2
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.js +12 -4
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_compute_indirect_specular.js +1 -1
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.js +25 -0
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +2 -2
- package/src/shade/renderer/shader/compiler/ShaderSwitch.d.ts +1 -1
- package/src/shade/renderer/shader/compiler/ShaderSwitchSet.d.ts +1 -1
- package/src/shade/renderer/shader/resource/ShaderResourceDescriptor.d.ts +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +2 -2
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +2 -2
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { m4_multiply } from "../../../../core/geom/3d/mat4/m4_multiply.js";
|
|
3
|
+
import { Groom } from "../../../../engine/graphics/hair/Groom.js";
|
|
4
|
+
import { groom_build_group, groom_point_count_for } from "../../../../engine/graphics/hair/groom_build_group.js";
|
|
5
|
+
import { usd_compose_transform } from "../../../../format/scene/usd/usd_compose_transform.js";
|
|
6
|
+
import { SceneNode } from "../SceneNode.js";
|
|
7
|
+
import { load_usd } from "./load_usd.js";
|
|
8
|
+
import { read_attr, read_attr_interpolation, usd_stage_correction } from "./usd_build_scene.js";
|
|
9
|
+
import { UsdExtensionRegistry } from "./UsdExtensionRegistry.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Points a cubic span is sampled at before the curve is resampled by arc length.
|
|
13
|
+
* @type {number}
|
|
14
|
+
*/
|
|
15
|
+
const SAMPLES_PER_SPAN = 8;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The chord tolerance an import chooses a group's point count by when it is given none, metres: half a millimetre,
|
|
19
|
+
* half a pixel at 0.6 m in a 1080-pixel view of 60°, about the nearest a head is seen from.
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
export const USD_GROOM_DEFAULT_TOLERANCE = 0.0005;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The basis functions of one cubic span at `t`, into `w` (4 weights).
|
|
26
|
+
*
|
|
27
|
+
* @param {string} basis "bezier", "bspline" or "catmullRom"
|
|
28
|
+
* @param {number} t in [0, 1]
|
|
29
|
+
* @param {number[]} w
|
|
30
|
+
*/
|
|
31
|
+
function cubic_weights(basis, t, w) {
|
|
32
|
+
const t2 = t * t;
|
|
33
|
+
const t3 = t2 * t;
|
|
34
|
+
const u = 1 - t;
|
|
35
|
+
|
|
36
|
+
if (basis === "bspline") {
|
|
37
|
+
w[0] = u * u * u / 6;
|
|
38
|
+
w[1] = (3 * t3 - 6 * t2 + 4) / 6;
|
|
39
|
+
w[2] = (-3 * t3 + 3 * t2 + 3 * t + 1) / 6;
|
|
40
|
+
w[3] = t3 / 6;
|
|
41
|
+
} else if (basis === "catmullRom") {
|
|
42
|
+
w[0] = 0.5 * (-t3 + 2 * t2 - t);
|
|
43
|
+
w[1] = 0.5 * (3 * t3 - 5 * t2 + 2);
|
|
44
|
+
w[2] = 0.5 * (-3 * t3 + 4 * t2 + t);
|
|
45
|
+
w[3] = 0.5 * (t3 - t2);
|
|
46
|
+
} else {
|
|
47
|
+
w[0] = u * u * u;
|
|
48
|
+
w[1] = 3 * u * u * t;
|
|
49
|
+
w[2] = 3 * u * t2;
|
|
50
|
+
w[3] = t3;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The curves of a UsdGeomBasisCurves prim, in the prim's own space, as polylines: linear curves as authored, cubic ones
|
|
56
|
+
* sampled {@link SAMPLES_PER_SPAN} times a span through their basis (Bézier, B-spline or Catmull-Rom; "pinned" wraps
|
|
57
|
+
* extended so the curve reaches its end points). A periodic curve is read as a nonperiodic one; hair has ends.
|
|
58
|
+
*
|
|
59
|
+
* Widths follow their interpolation: per point ("vertex", the default), per span end ("varying"), per curve
|
|
60
|
+
* ("uniform") or one for all ("constant"). A curve of fewer than two points, or a cubic one of no span, is left out.
|
|
61
|
+
*
|
|
62
|
+
* @see https://openusd.org/release/api/class_usd_geom_basis_curves.html
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} specs_by_path
|
|
65
|
+
* @param {string} path the prim's
|
|
66
|
+
* @returns {import("../../../../engine/graphics/hair/groom_build_group.js").GroomCurves|null} null when the prim holds
|
|
67
|
+
* no points
|
|
68
|
+
*/
|
|
69
|
+
export function usd_read_basis_curves(specs_by_path, path) {
|
|
70
|
+
const points = read_attr(specs_by_path, path, "points");
|
|
71
|
+
const counts = read_attr(specs_by_path, path, "curveVertexCounts");
|
|
72
|
+
|
|
73
|
+
if (points === undefined || counts === undefined || points.length === 0) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const type = read_attr(specs_by_path, path, "type") ?? "cubic";
|
|
78
|
+
const basis = read_attr(specs_by_path, path, "basis") ?? "bezier";
|
|
79
|
+
const wrap = read_attr(specs_by_path, path, "wrap") ?? "nonperiodic";
|
|
80
|
+
const width_layout = usd_width_layout(specs_by_path, path, counts, type, basis, wrap);
|
|
81
|
+
const widths = width_layout.widths;
|
|
82
|
+
|
|
83
|
+
const out_positions = [];
|
|
84
|
+
const out_widths = [];
|
|
85
|
+
const out_counts = [];
|
|
86
|
+
|
|
87
|
+
const w = [0, 0, 0, 0];
|
|
88
|
+
|
|
89
|
+
let first = 0;
|
|
90
|
+
let varying_base = 0;
|
|
91
|
+
|
|
92
|
+
for (let c = 0; c < counts.length; c++) {
|
|
93
|
+
const n = counts[c];
|
|
94
|
+
const curve_first = first;
|
|
95
|
+
const curve_varying = varying_base;
|
|
96
|
+
|
|
97
|
+
first += n;
|
|
98
|
+
varying_base += usd_varying_count(type, basis, wrap, n);
|
|
99
|
+
|
|
100
|
+
// the curve's control points, with the phantom ends a pinned wrap adds
|
|
101
|
+
const control = [];
|
|
102
|
+
|
|
103
|
+
for (let i = 0; i < n; i++) {
|
|
104
|
+
const at = (curve_first + i) * 3;
|
|
105
|
+
|
|
106
|
+
control.push([points[at], points[at + 1], points[at + 2]]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const pinned = type === "cubic" && wrap === "pinned" && basis !== "bezier" && n >= 2;
|
|
110
|
+
|
|
111
|
+
if (pinned) {
|
|
112
|
+
const a = control[0], b = control[1];
|
|
113
|
+
const y = control[n - 1], z = control[n - 2];
|
|
114
|
+
|
|
115
|
+
control.unshift([2 * a[0] - b[0], 2 * a[1] - b[1], 2 * a[2] - b[2]]);
|
|
116
|
+
control.push([2 * y[0] - z[0], 2 * y[1] - z[1], 2 * y[2] - z[2]]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// the curve's width at s in [0, 1] along it: per point and per span end linear along its parameter
|
|
120
|
+
const width_of = s => {
|
|
121
|
+
if (widths === null) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const interpolation = width_layout.interpolation;
|
|
126
|
+
|
|
127
|
+
if (interpolation === "constant") {
|
|
128
|
+
return widths[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (interpolation === "uniform") {
|
|
132
|
+
return widths[c];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const per_curve = interpolation === "varying" ? usd_varying_count(type, basis, wrap, n) : n;
|
|
136
|
+
const base = interpolation === "varying" ? curve_varying : curve_first;
|
|
137
|
+
|
|
138
|
+
if (per_curve < 1) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const x = s * (per_curve - 1);
|
|
143
|
+
const lo = Math.min(Math.floor(x), per_curve - 1);
|
|
144
|
+
const hi = Math.min(lo + 1, per_curve - 1);
|
|
145
|
+
const t = x - lo;
|
|
146
|
+
|
|
147
|
+
return widths[base + lo] * (1 - t) + widths[base + hi] * t;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const before = out_positions.length;
|
|
151
|
+
|
|
152
|
+
if (type === "linear") {
|
|
153
|
+
if (n < 2) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
for (let i = 0; i < n; i++) {
|
|
158
|
+
out_positions.push(control[i][0], control[i][1], control[i][2]);
|
|
159
|
+
out_widths.push(width_of(i / (n - 1)));
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
const spans = cubic_span_count(type, basis, wrap, n);
|
|
163
|
+
|
|
164
|
+
if (spans < 1) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const step = basis === "bezier" ? 3 : 1;
|
|
169
|
+
|
|
170
|
+
for (let k = 0; k < spans; k++) {
|
|
171
|
+
for (let j = 0; j < SAMPLES_PER_SPAN + (k === spans - 1 ? 1 : 0); j++) {
|
|
172
|
+
const t = j / SAMPLES_PER_SPAN;
|
|
173
|
+
|
|
174
|
+
cubic_weights(basis, t, w);
|
|
175
|
+
|
|
176
|
+
let x = 0, y = 0, z = 0;
|
|
177
|
+
|
|
178
|
+
for (let q = 0; q < 4; q++) {
|
|
179
|
+
const p = control[k * step + q];
|
|
180
|
+
|
|
181
|
+
x += p[0] * w[q];
|
|
182
|
+
y += p[1] * w[q];
|
|
183
|
+
z += p[2] * w[q];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
out_positions.push(x, y, z);
|
|
187
|
+
out_widths.push(width_of((k + t) / spans));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
out_counts.push((out_positions.length - before) / 3);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (out_counts.length === 0) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const has_widths = out_widths.length > 0 && out_widths.every(v => v !== null);
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
positions: Float64Array.from(out_positions),
|
|
203
|
+
counts: Uint32Array.from(out_counts),
|
|
204
|
+
widths: has_widths ? Float64Array.from(out_widths) : null,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Values a curve of `n` points authors for a "varying" primvar: one a segment end, so a nonperiodic or pinned curve's
|
|
210
|
+
* segments plus one, a periodic curve's segments.
|
|
211
|
+
*
|
|
212
|
+
* @see https://openusd.org/release/api/class_usd_geom_basis_curves.html
|
|
213
|
+
*
|
|
214
|
+
* @param {string} type
|
|
215
|
+
* @param {string} basis
|
|
216
|
+
* @param {string} wrap
|
|
217
|
+
* @param {number} n
|
|
218
|
+
* @returns {number}
|
|
219
|
+
*/
|
|
220
|
+
function usd_varying_count(type, basis, wrap, n) {
|
|
221
|
+
let segments;
|
|
222
|
+
|
|
223
|
+
if (type !== "cubic") {
|
|
224
|
+
segments = wrap === "periodic" ? n : n - 1;
|
|
225
|
+
} else if (basis === "bezier") {
|
|
226
|
+
segments = wrap === "periodic" ? Math.floor(n / 3) : Math.floor((n - 1) / 3);
|
|
227
|
+
} else if (wrap === "periodic") {
|
|
228
|
+
segments = n;
|
|
229
|
+
} else {
|
|
230
|
+
segments = wrap === "pinned" ? n - 1 : n - 3;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return Math.max(0, wrap === "periodic" ? segments : segments + 1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A prim's widths, and how they are laid out over its curves. Widths whose count matches none of the interpolations
|
|
238
|
+
* the prim could mean are left out (the curves take the default width); one value with no interpolation authored is
|
|
239
|
+
* one for all.
|
|
240
|
+
*
|
|
241
|
+
* @param {Object} specs_by_path
|
|
242
|
+
* @param {string} path
|
|
243
|
+
* @param {ArrayLike<number>} counts
|
|
244
|
+
* @param {string} type
|
|
245
|
+
* @param {string} basis
|
|
246
|
+
* @param {string} wrap
|
|
247
|
+
* @returns {{widths: ArrayLike<number>|null, interpolation: string}}
|
|
248
|
+
*/
|
|
249
|
+
function usd_width_layout(specs_by_path, path, counts, type, basis, wrap) {
|
|
250
|
+
const widths = read_attr(specs_by_path, path, "widths");
|
|
251
|
+
let interpolation = read_attr_interpolation(specs_by_path, path, "widths");
|
|
252
|
+
|
|
253
|
+
if (widths === undefined || widths.length === 0) {
|
|
254
|
+
return { widths: null, interpolation };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (widths.length === 1) {
|
|
258
|
+
return { widths, interpolation: "constant" };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let expected = 1;
|
|
262
|
+
|
|
263
|
+
if (interpolation === "uniform") {
|
|
264
|
+
expected = counts.length;
|
|
265
|
+
} else if (interpolation === "varying") {
|
|
266
|
+
expected = 0;
|
|
267
|
+
|
|
268
|
+
for (let c = 0; c < counts.length; c++) {
|
|
269
|
+
expected += usd_varying_count(type, basis, wrap, counts[c]);
|
|
270
|
+
}
|
|
271
|
+
} else if (interpolation !== "constant") {
|
|
272
|
+
interpolation = "vertex";
|
|
273
|
+
expected = 0;
|
|
274
|
+
|
|
275
|
+
for (let c = 0; c < counts.length; c++) {
|
|
276
|
+
expected += counts[c];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return widths.length === expected ? { widths, interpolation } : { widths: null, interpolation };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Spans of one cubic curve of `n` control points.
|
|
285
|
+
*
|
|
286
|
+
* @param {string} type
|
|
287
|
+
* @param {string} basis
|
|
288
|
+
* @param {string} wrap
|
|
289
|
+
* @param {number} n
|
|
290
|
+
* @returns {number}
|
|
291
|
+
*/
|
|
292
|
+
function cubic_span_count(type, basis, wrap, n) {
|
|
293
|
+
if (type !== "cubic") {
|
|
294
|
+
return n - 1;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (basis === "bezier") {
|
|
298
|
+
return Math.floor((n - 1) / 3);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// a pinned curve has a phantom point at either end
|
|
302
|
+
return wrap === "pinned" ? n - 1 : n - 3;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* A USD loader extension (`UsdExtensionRegistry`) that takes every BasisCurves prim of a stage as a group of strand
|
|
307
|
+
* hair: its curves carried by the prim's transform and its ancestors' into the stage's space, corrected to Y up and
|
|
308
|
+
* 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`). Widths are scaled with the space.
|
|
310
|
+
*
|
|
311
|
+
* Each prim answers with a node that draws nothing, so the scene's hierarchy keeps its place. The groups gather in
|
|
312
|
+
* {@link groom}, in the order the stage's prims are visited.
|
|
313
|
+
*
|
|
314
|
+
* @param {Object} [options]
|
|
315
|
+
* @param {number} [options.tolerance] metres
|
|
316
|
+
* @param {number} [options.width] metres, for curves that author no widths
|
|
317
|
+
* @returns {{name: string, groom: Groom, processPrim: function(string, Object, Object): (SceneNode|null)}}
|
|
318
|
+
*/
|
|
319
|
+
export function create_usd_groom_extension({ tolerance = USD_GROOM_DEFAULT_TOLERANCE, width = 70e-6 } = {}) {
|
|
320
|
+
assert.greaterThan(tolerance, 0, 'tolerance');
|
|
321
|
+
|
|
322
|
+
const groom = new Groom();
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
name: "groom",
|
|
326
|
+
groom,
|
|
327
|
+
processPrim(path, fields, context) {
|
|
328
|
+
if (fields.typeName !== "BasisCurves") {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const specs_by_path = context.specs_by_path;
|
|
333
|
+
const local = usd_compose_transform(fields, specs_by_path, path);
|
|
334
|
+
|
|
335
|
+
const curves = usd_read_basis_curves(specs_by_path, path);
|
|
336
|
+
|
|
337
|
+
if (curves !== null) {
|
|
338
|
+
// the stage's correction, then every ancestor's transform down to the prim's own
|
|
339
|
+
const root = specs_by_path["/"];
|
|
340
|
+
const world = usd_stage_correction(root !== undefined ? root.fields : {});
|
|
341
|
+
const segments = path.split("/").filter(s => s.length > 0);
|
|
342
|
+
|
|
343
|
+
let ancestor = "";
|
|
344
|
+
|
|
345
|
+
for (let i = 0; i < segments.length; i++) {
|
|
346
|
+
ancestor += "/" + segments[i];
|
|
347
|
+
|
|
348
|
+
const spec = specs_by_path[ancestor];
|
|
349
|
+
const m = i === segments.length - 1 ? local : usd_compose_transform(spec !== undefined ? spec.fields : {}, specs_by_path, ancestor);
|
|
350
|
+
|
|
351
|
+
m4_multiply(world, world, m);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
transform_curves(curves, world);
|
|
355
|
+
|
|
356
|
+
groom.add(groom_build_group(curves, {
|
|
357
|
+
name: segments[segments.length - 1],
|
|
358
|
+
point_count: groom_point_count_for(curves, tolerance),
|
|
359
|
+
width,
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return SceneNode.from({ name: path.split("/").pop(), matrix: local });
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Carry curves through a matrix: their points, and their widths by the most the matrix stretches.
|
|
370
|
+
*
|
|
371
|
+
* @param {import("../../../../engine/graphics/hair/groom_build_group.js").GroomCurves} curves
|
|
372
|
+
* @param {ArrayLike<number>} m 4x4, column-major
|
|
373
|
+
*/
|
|
374
|
+
function transform_curves(curves, m) {
|
|
375
|
+
const p = curves.positions;
|
|
376
|
+
|
|
377
|
+
for (let i = 0; i < p.length; i += 3) {
|
|
378
|
+
const x = p[i], y = p[i + 1], z = p[i + 2];
|
|
379
|
+
|
|
380
|
+
p[i] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
381
|
+
p[i + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
382
|
+
p[i + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (curves.widths !== null) {
|
|
386
|
+
const scale = Math.max(
|
|
387
|
+
Math.hypot(m[0], m[1], m[2]),
|
|
388
|
+
Math.hypot(m[4], m[5], m[6]),
|
|
389
|
+
Math.hypot(m[8], m[9], m[10]),
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
for (let i = 0; i < curves.widths.length; i++) {
|
|
393
|
+
curves.widths[i] *= scale;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Every BasisCurves prim of a USD file as one {@link Groom}, a group a prim (see {@link create_usd_groom_extension}).
|
|
400
|
+
*
|
|
401
|
+
* @param {ArrayBuffer} buffer a USD file: text, or a package whose root layer is text
|
|
402
|
+
* @param {Object} [options]
|
|
403
|
+
* @param {number} [options.tolerance] metres
|
|
404
|
+
* @param {string} [options.fileName] what the file is called, for telling its format apart when its bytes do not
|
|
405
|
+
* @returns {Promise<Groom>} with no group when the file holds no curves
|
|
406
|
+
*/
|
|
407
|
+
export async function load_groom_usd(buffer, { tolerance = USD_GROOM_DEFAULT_TOLERANCE, fileName } = {}) {
|
|
408
|
+
const registry = new UsdExtensionRegistry();
|
|
409
|
+
const extension = create_usd_groom_extension({ tolerance });
|
|
410
|
+
|
|
411
|
+
registry.register(extension.name, extension);
|
|
412
|
+
|
|
413
|
+
await load_usd(buffer, { extensions: registry, fileName });
|
|
414
|
+
|
|
415
|
+
return extension.groom;
|
|
416
|
+
}
|
|
417
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_sample_material_data.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_sample_material_data.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,0CAFU,SAAS,CAkGlB;AAED;;;;;;GAMG;AACH,yCAFU,SAAS,CA2IlB;0BA9PyB,oCAAoC"}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "../../shader/chunk/geometry/triangle/chunk_interpolate_attribute_4f32.js";
|
|
23
23
|
import { TRIANGLE_VERTICES_STRUCT } from "../../shader/chunk/geometry/triangle/TRIANGLE_VERTICES_STRUCT.js";
|
|
24
24
|
import { chunk_dielectric_specular_color } from "../../shader/chunk/material/chunk_dielectric_specular_color.js";
|
|
25
|
+
import { chunk_metalness_to_specular_F90 } from "../../shader/chunk/material/chunk_metalness_to_specular_F90.js";
|
|
25
26
|
import { chunk_v3_matrix4_project } from "../../shader/chunk/geometry/vec3/chunk_v3_matrix4_project.js";
|
|
26
27
|
import { chunk_random_vec3 } from "../../shader/chunk/random/chunk_random_vec3.js";
|
|
27
28
|
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
@@ -91,7 +92,8 @@ fn sample_material_alpha(
|
|
|
91
92
|
let f_metalness = material.metallic_factor; // ORM texture not sampled in alpha path; metallic_factor is enough for typical glass (metalness = 0)
|
|
92
93
|
let specular_f0 = dielectric_specular_color(material.ior_factor, f_metalness, albedo);
|
|
93
94
|
let nov = saturate(abs(dot(world_face_normal, ray_direction)));
|
|
94
|
-
let
|
|
95
|
+
let specular_f90 = metalness_to_specular_F90(f_metalness, albedo);
|
|
96
|
+
let f_view = F_Schlick(specular_f0, specular_f90, nov);
|
|
95
97
|
let f_scalar = max(f_view.r, max(f_view.g, f_view.b));
|
|
96
98
|
// Glass coverage tracks the view-Fresnel reflection coefficient.
|
|
97
99
|
// No per-channel transmission tint in the material today — when one
|
|
@@ -127,6 +129,7 @@ fn sample_material_alpha(
|
|
|
127
129
|
chunk_interpolate_attribute_3f32,
|
|
128
130
|
chunk_interpolate_attribute_2f32,
|
|
129
131
|
chunk_dielectric_specular_color,
|
|
132
|
+
chunk_metalness_to_specular_F90,
|
|
130
133
|
chunk_albedo_unpremultiply,
|
|
131
134
|
chunk_F_Schlick,
|
|
132
135
|
]
|
package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_shading_closure_from_material_data.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_shading_closure_from_material_data.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js"],"names":[],"mappings":"AAYA,iEA8CC;0BAjDyB,oCAAoC"}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
import { TRIANGLE_VERTICES_STRUCT } from "../../shader/chunk/geometry/triangle/TRIANGLE_VERTICES_STRUCT.js";
|
|
5
5
|
import { chunk_v3_matrix4_project } from "../../shader/chunk/geometry/vec3/chunk_v3_matrix4_project.js";
|
|
6
6
|
import { chunk_dielectric_specular_color } from "../../shader/chunk/material/chunk_dielectric_specular_color.js";
|
|
7
|
+
import { chunk_metalness_to_specular_F90 } from "../../shader/chunk/material/chunk_metalness_to_specular_F90.js";
|
|
7
8
|
import { GEOMETRIC_SHADING_INFO_STRUCT } from "../../shader/chunk/material/GEOMETRIC_SHADING_INFO_STRUCT.js";
|
|
8
9
|
import { MATERIAL_SHADING_INFO_STRUCT } from "../../shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js";
|
|
9
10
|
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
@@ -32,7 +33,7 @@ fn shading_closure_from_material_data(
|
|
|
32
33
|
out_material.emissive = material_data.emissive;
|
|
33
34
|
|
|
34
35
|
out_material.specularF0 = dielectric_specular_color(material_data.ior, material_data.metalness, material_data.albedo);
|
|
35
|
-
out_material.specularF90 =
|
|
36
|
+
out_material.specularF90 = metalness_to_specular_F90(material_data.metalness, material_data.albedo);
|
|
36
37
|
|
|
37
38
|
out_geometry.shading_normal = material_data.normal_shading;
|
|
38
39
|
out_geometry.geometric_normal = material_data.normal_geometric;
|
|
@@ -53,5 +54,6 @@ fn shading_closure_from_material_data(
|
|
|
53
54
|
chunk_interpolate_attribute_3f32,
|
|
54
55
|
chunk_v3_matrix4_project,
|
|
55
56
|
chunk_dielectric_specular_color,
|
|
57
|
+
chunk_metalness_to_specular_F90,
|
|
56
58
|
]
|
|
57
59
|
)
|
|
@@ -51,7 +51,7 @@ export class NSS {
|
|
|
51
51
|
* @returns {number}
|
|
52
52
|
*/
|
|
53
53
|
static recommended_jitter_sequence_size(upscale_ratio: number): number;
|
|
54
|
-
static "__#
|
|
54
|
+
static "__#222@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
|
|
55
55
|
/**
|
|
56
56
|
* @param {GraphicsContext} graphics
|
|
57
57
|
*/
|
|
@@ -54,6 +54,8 @@ export class SSR {
|
|
|
54
54
|
* while Brick4 runs. A source not given is the resolve's default, for a variant that does not read it
|
|
55
55
|
* @param {number} [options.input_indirect_diffuse] the deferred pass's indirect diffuse, irradiance with AO in,
|
|
56
56
|
* while the probe clipmap runs: its bounce at a hit reads the hit's texel. Recorded before this pass
|
|
57
|
+
* @param {number} [options.input_screen_probe_specular] the screen probes' rough specular
|
|
58
|
+
* (`GPUScreenProbeGI#specular_handle`), while they run: where the trace finds nothing, the fallback
|
|
57
59
|
* @param {import("../../global_illumination/probe_clipmap/GPUProbeClipmapGI.js").GPUProbeClipmapGI} options.probes
|
|
58
60
|
* the renderer's probe clipmap GI, bound in every mode: a clipmap of no cascade while it has no probes
|
|
59
61
|
* @param {import("../../view/GPUViewContext.js").GPUViewContext} [options.view_ctx]
|
|
@@ -61,7 +63,7 @@ export class SSR {
|
|
|
61
63
|
* @param {number} [options.mip] Higher mip = lower resolution trace
|
|
62
64
|
* @returns {{final:number, trace:number, reflections:number, denoised:number, denoised_1:number, denoise_tiles:number}}
|
|
63
65
|
*/
|
|
64
|
-
graph_pass({ graph, input_depth, input_depth_previous, view_ctx, jitter, input_hzb, input_scene_color, input_pbr, input_normal, input_velocity, input_occlusion, input_albedo, resolution, camera_current, camera_previous, input_environment, shader_switches, brick4, input_indirect_diffuse, probes, mip, }: {
|
|
66
|
+
graph_pass({ graph, input_depth, input_depth_previous, view_ctx, jitter, input_hzb, input_scene_color, input_pbr, input_normal, input_velocity, input_occlusion, input_albedo, resolution, camera_current, camera_previous, input_environment, shader_switches, brick4, input_indirect_diffuse, input_screen_probe_specular, probes, mip, }: {
|
|
65
67
|
graph: import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
|
|
66
68
|
input_depth: number;
|
|
67
69
|
input_depth_previous?: number;
|
|
@@ -79,6 +81,7 @@ export class SSR {
|
|
|
79
81
|
shader_switches?: ShaderSwitchSet;
|
|
80
82
|
brick4?: import("../../global_illumination/brick4/Brick4LightMap.js").Brick4LightMap;
|
|
81
83
|
input_indirect_diffuse?: number;
|
|
84
|
+
input_screen_probe_specular?: number;
|
|
82
85
|
probes: import("../../global_illumination/probe_clipmap/GPUProbeClipmapGI.js").GPUProbeClipmapGI;
|
|
83
86
|
view_ctx?: import("../../view/GPUViewContext.js").GPUViewContext;
|
|
84
87
|
jitter?: ArrayLike<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SSR.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/ssr/SSR.js"],"names":[],"mappings":"AAiBA;IA6EI;;;OAGG;IACH,sBAFW,OAAO,0BAA0B,EAAE,eAAe,EAkB5D;IA1ED,oBAAgB;IAWhB,2CAMC;IAZD;;;;OAIG;IACH,sCAAqE;IAoCrE,kCAMC;IAZD;;;;OAIG;IACH,6BAAmD;IAxBnD,8CAOC;IATD,iGAAiG;IACjG,yCAA2E;IAY3E,qCAMC;IARD,qCAAqC;IACrC,gCAA2D;IA6C3D;;;;OAIG;IACH,UAHW,MAAM,KACN,MAAM,QAUhB;IAED
|
|
1
|
+
{"version":3,"file":"SSR.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/ssr/SSR.js"],"names":[],"mappings":"AAiBA;IA6EI;;;OAGG;IACH,sBAFW,OAAO,0BAA0B,EAAE,eAAe,EAkB5D;IA1ED,oBAAgB;IAWhB,2CAMC;IAZD;;;;OAIG;IACH,sCAAqE;IAoCrE,kCAMC;IAZD;;;;OAIG;IACH,6BAAmD;IAxBnD,8CAOC;IATD,iGAAiG;IACjG,yCAA2E;IAY3E,qCAMC;IARD,qCAAqC;IACrC,gCAA2D;IA6C3D;;;;OAIG;IACH,UAHW,MAAM,KACN,MAAM,QAUhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH;QA7BsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;QACjE,WAAW,EAA3B,MAAM;QACW,oBAAoB,GAArC,MAAM;QACU,SAAS,EAAzB,MAAM;QACU,iBAAiB,EAAjC,MAAM;QACU,YAAY,EAA5B,MAAM;QACU,SAAS,EAAzB,MAAM;QACU,YAAY,EAA5B,MAAM;QACU,cAAc,EAA9B,MAAM;QACU,eAAe,EAA/B,MAAM;QACU,iBAAiB,EAAjC,MAAM;QACqB,UAAU,EAArC,UAAU,MAAM,CAAC;QACD,cAAc,EAA9B,MAAM;QACU,eAAe,EAA/B,MAAM;QACoB,eAAe,GAAzC,eAAe;QAEuE,MAAM,GAA5F,OAAO,oDAAoD,EAAE,cAAc;QAE1D,sBAAsB,GAAvC,MAAM;QAEW,2BAA2B,GAA5C,MAAM;QAE4F,MAAM,EAAxG,OAAO,8DAA8D,EAAE,iBAAiB;QAExB,QAAQ,GAAxE,OAAO,8BAA8B,EAAE,cAAc;QACzB,MAAM,GAAlC,UAAU,MAAM,CAAC;QACA,GAAG,GAApB,MAAM;QACJ;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,WAAW,EAAC,MAAM,CAAC;QAAC,QAAQ,EAAC,MAAM,CAAC;QAAC,UAAU,EAAC,MAAM,CAAC;QAAC,aAAa,EAAC,MAAM,CAAA;KAAC,CA+QtH;;CACJ;gCAjb+B,0CAA0C"}
|
|
@@ -152,6 +152,8 @@ export class SSR {
|
|
|
152
152
|
* while Brick4 runs. A source not given is the resolve's default, for a variant that does not read it
|
|
153
153
|
* @param {number} [options.input_indirect_diffuse] the deferred pass's indirect diffuse, irradiance with AO in,
|
|
154
154
|
* while the probe clipmap runs: its bounce at a hit reads the hit's texel. Recorded before this pass
|
|
155
|
+
* @param {number} [options.input_screen_probe_specular] the screen probes' rough specular
|
|
156
|
+
* (`GPUScreenProbeGI#specular_handle`), while they run: where the trace finds nothing, the fallback
|
|
155
157
|
* @param {import("../../global_illumination/probe_clipmap/GPUProbeClipmapGI.js").GPUProbeClipmapGI} options.probes
|
|
156
158
|
* the renderer's probe clipmap GI, bound in every mode: a clipmap of no cascade while it has no probes
|
|
157
159
|
* @param {import("../../view/GPUViewContext.js").GPUViewContext} [options.view_ctx]
|
|
@@ -179,6 +181,7 @@ export class SSR {
|
|
|
179
181
|
shader_switches = ShaderSwitchSet.EMPTY,
|
|
180
182
|
brick4,
|
|
181
183
|
input_indirect_diffuse,
|
|
184
|
+
input_screen_probe_specular,
|
|
182
185
|
probes,
|
|
183
186
|
mip = 0,
|
|
184
187
|
}) {
|
|
@@ -289,6 +292,12 @@ export class SSR {
|
|
|
289
292
|
resolve_inputs.tIndirectDiffuse = input_indirect_diffuse;
|
|
290
293
|
}
|
|
291
294
|
|
|
295
|
+
if (input_screen_probe_specular !== undefined) {
|
|
296
|
+
assert.isNonNegativeInteger(input_screen_probe_specular, 'input_screen_probe_specular');
|
|
297
|
+
|
|
298
|
+
resolve_inputs.tScreenProbeSpecular = input_screen_probe_specular;
|
|
299
|
+
}
|
|
300
|
+
|
|
292
301
|
// the probes in every mode, having no default: no cascade but while the probe clipmap runs
|
|
293
302
|
probes.write_sampling_bindings(resolve_inputs);
|
|
294
303
|
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screen probes' rough specular, as `GPUScreenProbeGI#specular_handle` holds it: their radiance along each pixel's
|
|
3
|
+
* specular lobe, and in alpha the share of the pixel's specular the world-space probes keep. Black by default,
|
|
4
|
+
* for the modes that hand the resolve none.
|
|
5
|
+
* @type {ShaderResourceDescriptor}
|
|
6
|
+
*/
|
|
7
|
+
export const SSR_SCREEN_PROBE_SPECULAR_RESOURCE: ShaderResourceDescriptor;
|
|
1
8
|
/**
|
|
2
9
|
* {@link chunk_ssr_sample_radiance} from the environment map. Reads `tEnvironment`.
|
|
3
10
|
* @type {CodeChunk}
|
|
@@ -17,10 +24,17 @@ export const chunk_ssr_sample_radiance_brick4: CodeChunk;
|
|
|
17
24
|
* @type {CodeChunk}
|
|
18
25
|
*/
|
|
19
26
|
export const chunk_ssr_sample_radiance_probe_clipmap: CodeChunk;
|
|
27
|
+
/**
|
|
28
|
+
* {@link chunk_ssr_sample_radiance} from the screen probes: their rough specular at the pixel and the world-space
|
|
29
|
+
* probes' radiance as {@link chunk_ssr_sample_radiance_probe_clipmap} takes it, each by its share; the world probes'
|
|
30
|
+
* not picked where their share is none. Reads `tScreenProbeSpecular` and what the probe clipmap's reads.
|
|
31
|
+
* @type {CodeChunk}
|
|
32
|
+
*/
|
|
33
|
+
export const chunk_ssr_sample_radiance_screen_probes: CodeChunk;
|
|
20
34
|
/**
|
|
21
35
|
* What SSR's resolve falls back to where the trace found nothing on screen, by the renderer's indirect
|
|
22
36
|
* lighting mode ({@link INDIRECT_LIGHTING}). The probe clipmap falls back to its probes' specular, and to
|
|
23
|
-
* the environment map where they find nothing.
|
|
37
|
+
* the environment map where they find nothing; the screen probes to their rough specular and the world probes' share.
|
|
24
38
|
*
|
|
25
39
|
* ```wgsl
|
|
26
40
|
* fn ssr_sample_radiance(position_ws, normal_ws, view_direction_ws, roughness, coord: vec2u) -> vec3f
|
|
@@ -29,6 +43,7 @@ export const chunk_ssr_sample_radiance_probe_clipmap: CodeChunk;
|
|
|
29
43
|
* @type {CodeChunkChoice}
|
|
30
44
|
*/
|
|
31
45
|
export const chunk_ssr_sample_radiance: CodeChunkChoice;
|
|
46
|
+
import { ShaderResourceDescriptor } from "../../../shader/resource/ShaderResourceDescriptor.js";
|
|
32
47
|
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
33
48
|
import { CodeChunkChoice } from "../../../shader/compiler/CodeChunkChoice.js";
|
|
34
49
|
//# sourceMappingURL=chunk_ssr_sample_radiance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_ssr_sample_radiance.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_ssr_sample_radiance.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,iDAFU,wBAAwB,CAQhC;AAEF;;;GAGG;AACH,4CAFU,SAAS,CAUc;AAEjC;;;;GAIG;AACH,+CAFU,SAAS,CAUoB;AAEvC;;;;;;GAMG;AACH,sDAFU,SAAS,CAiB2E;AAE9F;;;;;GAKG;AACH,sDAFU,SAAS,CAqB2E;AAI9F;;;;;;;;;;GAUG;AACH,wCAFU,eAAe,CAEwD;yCA9GxC,sDAAsD;0BAFrE,uCAAuC;gCACjC,6CAA6C"}
|
|
@@ -8,6 +8,22 @@ import { ShadeIndirectLightingMode } from "../../../ShadeIndirectLightingMode.js
|
|
|
8
8
|
import { chunk_stbn_sample_vec2 } from "../../../shader/chunk/noise/chunk_stbn_sample_vec2.js";
|
|
9
9
|
import { CodeChunk } from "../../../shader/compiler/CodeChunk.js";
|
|
10
10
|
import { CodeChunkChoice } from "../../../shader/compiler/CodeChunkChoice.js";
|
|
11
|
+
import { ShaderResourceDescriptor } from "../../../shader/resource/ShaderResourceDescriptor.js";
|
|
12
|
+
import { BLACK_PIXEL_TEXTURE } from "../../../texture/util/BLACK_PIXEL_TEXTURE.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The screen probes' rough specular, as `GPUScreenProbeGI#specular_handle` holds it: their radiance along each pixel's
|
|
16
|
+
* specular lobe, and in alpha the share of the pixel's specular the world-space probes keep. Black by default,
|
|
17
|
+
* for the modes that hand the resolve none.
|
|
18
|
+
* @type {ShaderResourceDescriptor}
|
|
19
|
+
*/
|
|
20
|
+
export const SSR_SCREEN_PROBE_SPECULAR_RESOURCE = ShaderResourceDescriptor.texture(
|
|
21
|
+
"tScreenProbeSpecular",
|
|
22
|
+
"unfilterable-float",
|
|
23
|
+
"2d",
|
|
24
|
+
false,
|
|
25
|
+
BLACK_PIXEL_TEXTURE
|
|
26
|
+
);
|
|
11
27
|
|
|
12
28
|
/**
|
|
13
29
|
* {@link chunk_ssr_sample_radiance} from the environment map. Reads `tEnvironment`.
|
|
@@ -62,10 +78,39 @@ fn ssr_sample_radiance(
|
|
|
62
78
|
}
|
|
63
79
|
`, [chunk_probe_clipmap_sample_radiance, chunk_stbn_sample_vec2, chunk_get_ibl_radiance]);
|
|
64
80
|
|
|
81
|
+
/**
|
|
82
|
+
* {@link chunk_ssr_sample_radiance} from the screen probes: their rough specular at the pixel and the world-space
|
|
83
|
+
* probes' radiance as {@link chunk_ssr_sample_radiance_probe_clipmap} takes it, each by its share; the world probes'
|
|
84
|
+
* not picked where their share is none. Reads `tScreenProbeSpecular` and what the probe clipmap's reads.
|
|
85
|
+
* @type {CodeChunk}
|
|
86
|
+
*/
|
|
87
|
+
export const chunk_ssr_sample_radiance_screen_probes = CodeChunk.from(
|
|
88
|
+
//language=WGSL
|
|
89
|
+
`
|
|
90
|
+
fn ssr_sample_radiance(
|
|
91
|
+
position_ws: vec3f, normal_ws: vec3f, view_direction_ws: vec3f, roughness: f32, coord: vec2u,
|
|
92
|
+
) -> vec3f {
|
|
93
|
+
let rough = textureLoad(tScreenProbeSpecular, coord, 0);
|
|
94
|
+
|
|
95
|
+
var radiance = rough.rgb * (1.0 - rough.a);
|
|
96
|
+
|
|
97
|
+
if (rough.a > 0.0) {
|
|
98
|
+
let noise = stbn_sample_vec2(vec3u(coord, settings.frame_index));
|
|
99
|
+
let probes = probe_clipmap_sample_radiance(position_ws, normal_ws, view_direction_ws, roughness, noise);
|
|
100
|
+
|
|
101
|
+
radiance += rough.a * select(get_ibl_radiance(view_direction_ws, normal_ws, roughness), probes.radiance, probes.found);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return radiance;
|
|
105
|
+
}
|
|
106
|
+
`, [chunk_probe_clipmap_sample_radiance, chunk_stbn_sample_vec2, chunk_get_ibl_radiance]);
|
|
107
|
+
|
|
108
|
+
chunk_ssr_sample_radiance_screen_probes.requireResource(SSR_SCREEN_PROBE_SPECULAR_RESOURCE);
|
|
109
|
+
|
|
65
110
|
/**
|
|
66
111
|
* What SSR's resolve falls back to where the trace found nothing on screen, by the renderer's indirect
|
|
67
112
|
* lighting mode ({@link INDIRECT_LIGHTING}). The probe clipmap falls back to its probes' specular, and to
|
|
68
|
-
* the environment map where they find nothing.
|
|
113
|
+
* the environment map where they find nothing; the screen probes to their rough specular and the world probes' share.
|
|
69
114
|
*
|
|
70
115
|
* ```wgsl
|
|
71
116
|
* fn ssr_sample_radiance(position_ws, normal_ws, view_direction_ws, roughness, coord: vec2u) -> vec3f
|
|
@@ -78,5 +123,4 @@ export const chunk_ssr_sample_radiance = CodeChunkChoice.from(INDIRECT_LIGHTING)
|
|
|
78
123
|
chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.IBL, chunk_ssr_sample_radiance_ibl);
|
|
79
124
|
chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.Brick4, chunk_ssr_sample_radiance_brick4);
|
|
80
125
|
chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.ProbeClipmap, chunk_ssr_sample_radiance_probe_clipmap);
|
|
81
|
-
|
|
82
|
-
chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.ScreenProbes, chunk_ssr_sample_radiance_probe_clipmap);
|
|
126
|
+
chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.ScreenProbes, chunk_ssr_sample_radiance_screen_probes);
|