@woosh/meep-engine 2.109.6 → 2.109.8
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/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +203 -174
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +203 -174
- package/editor/tools/v2/TransformControls.js +39 -33
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +8 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
- package/src/core/geom/3d/Ray3.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
- package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
- package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
- package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
- package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_distance.js +5 -5
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
- package/src/core/model/node-graph/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/DataType.js +16 -10
- package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
- package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
- package/src/core/model/node-graph/ParametricDataType.js +63 -0
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
- package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
- package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/AssetLoader.js +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
- package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
- package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
- package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
- package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +59 -37
- package/src/engine/graphics/sh3/gi/material/common.glsl +484 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +51 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +26 -9
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +11 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -61
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +8 -6
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +149 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +161 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
- package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +41 -8
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
- package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
- package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
- package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
- package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
- package/src/view/View.d.ts.map +1 -1
- package/src/view/View.js +2 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
- package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
- /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
- /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
- /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {PathTracedScene} scene
|
|
6
|
+
* @param {number[]|Vector3} position
|
|
7
|
+
* @param {number} position_offset
|
|
8
|
+
* @param {number} resolution
|
|
9
|
+
* @param {number} max_depth
|
|
10
|
+
*/
|
|
11
|
+
export function bake_octahedral_depth_map(result: number[], result_offset: number, scene: PathTracedScene, position: number[] | Vector3, position_offset: number, resolution: number, max_depth: number): void;
|
|
12
|
+
//# sourceMappingURL=bake_octahedral_depth_map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QAuChB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { array_copy } from "../../../../../../core/collection/array/array_copy.js";
|
|
2
|
+
import {
|
|
3
|
+
decode_octahedron_to_unit
|
|
4
|
+
} from "../../../../../../core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js";
|
|
5
|
+
import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
6
|
+
|
|
7
|
+
const scratch_ray = new Ray3();
|
|
8
|
+
|
|
9
|
+
const ray_hit = [];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {number[]} result
|
|
14
|
+
* @param {number} result_offset
|
|
15
|
+
* @param {PathTracedScene} scene
|
|
16
|
+
* @param {number[]|Vector3} position
|
|
17
|
+
* @param {number} position_offset
|
|
18
|
+
* @param {number} resolution
|
|
19
|
+
* @param {number} max_depth
|
|
20
|
+
*/
|
|
21
|
+
export function bake_octahedral_depth_map(
|
|
22
|
+
result, result_offset,
|
|
23
|
+
scene,
|
|
24
|
+
position, position_offset,
|
|
25
|
+
resolution,
|
|
26
|
+
max_depth
|
|
27
|
+
) {
|
|
28
|
+
|
|
29
|
+
scratch_ray.tMax = max_depth;
|
|
30
|
+
array_copy(position, position_offset, scratch_ray, 0, 3);
|
|
31
|
+
|
|
32
|
+
const ray_direction = scratch_ray.direction;
|
|
33
|
+
|
|
34
|
+
for (let oct_x = 0; oct_x < resolution; oct_x++) {
|
|
35
|
+
for (let oct_y = 0; oct_y < resolution; oct_y++) {
|
|
36
|
+
|
|
37
|
+
const u = (oct_x) / (resolution - 1);
|
|
38
|
+
const v = (oct_y) / (resolution - 1);
|
|
39
|
+
|
|
40
|
+
decode_octahedron_to_unit(
|
|
41
|
+
ray_direction, 0,
|
|
42
|
+
u * 2 - 1, v * 2 - 1
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
let distance = scene.trace(ray_hit, scratch_ray);
|
|
46
|
+
|
|
47
|
+
if (distance < 0) {
|
|
48
|
+
// no hit
|
|
49
|
+
distance = max_depth;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const pixel_index = oct_y * resolution + oct_x;
|
|
53
|
+
|
|
54
|
+
result[result_offset + pixel_index] = distance;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class OctahedralDepthVisualizationMaterial extends ShaderMaterial {
|
|
2
|
+
constructor();
|
|
3
|
+
set scale(arg: any);
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {THREE.DataTexture} v
|
|
7
|
+
*/
|
|
8
|
+
set texture(arg: import("three").DataTexture);
|
|
9
|
+
}
|
|
10
|
+
import { ShaderMaterial } from "three";
|
|
11
|
+
//# sourceMappingURL=OctahedralDepthVisualizationMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OctahedralDepthVisualizationMaterial.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js"],"names":[],"mappings":"AAIA;IAGI,cAmBC;IAED,oBAGC;IAED;;;OAGG;IACH,8CAKC;CAEJ;+BA5C8B,OAAO"}
|
package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ShaderMaterial } from "three";
|
|
2
|
+
import shader_fg from './visualize.frag.glsl';
|
|
3
|
+
import shader_vx from './visualize.vert.glsl';
|
|
4
|
+
|
|
5
|
+
export class OctahedralDepthVisualizationMaterial extends ShaderMaterial {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
super({
|
|
12
|
+
fragmentShader: shader_fg,
|
|
13
|
+
vertexShader: shader_vx,
|
|
14
|
+
lights: false,
|
|
15
|
+
uniforms: {
|
|
16
|
+
uResolution: {
|
|
17
|
+
value: 1
|
|
18
|
+
},
|
|
19
|
+
fScale: { value: 1 },
|
|
20
|
+
tDepth: {
|
|
21
|
+
value: null
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set scale(v) {
|
|
30
|
+
this.uniforms.fScale.value = 1 / v;
|
|
31
|
+
this.uniformsNeedUpdate = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {THREE.DataTexture} v
|
|
37
|
+
*/
|
|
38
|
+
set texture(v) {
|
|
39
|
+
this.uniforms.tDepth.value = v;
|
|
40
|
+
this.uniforms.uResolution.value = v.image.width;
|
|
41
|
+
|
|
42
|
+
this.uniformsNeedUpdate = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
vec3 inverseTransformDirection(in vec3 normal, in mat4 matrix) {
|
|
2
|
+
// matrix is assumed to be orthogonal
|
|
3
|
+
return normalize((vec4(normal, 0.0) * matrix).xyz);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
vec3 OctaSphereEnc(vec2 coord)
|
|
7
|
+
{
|
|
8
|
+
coord = (coord - 0.5) * 2.0;
|
|
9
|
+
vec3 position = vec3(coord.x, 0.0, coord.y);
|
|
10
|
+
vec2 absolute = abs(position.xz);
|
|
11
|
+
position.y = 1.0 - absolute.x - absolute.y;
|
|
12
|
+
|
|
13
|
+
if (position.y < 0.0)
|
|
14
|
+
{
|
|
15
|
+
position.xz = sign(position.xz) * vec2(1.0 - absolute.y, 1.0 - absolute.x);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return position;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
vec3 sign_not_zero(vec3 x) {
|
|
22
|
+
return vec3(
|
|
23
|
+
x.x >= 0.0 ? 1.0 : -1.0,
|
|
24
|
+
x.y >= 0.0 ? 1.0 : -1.0,
|
|
25
|
+
x.z >= 0.0 ? 1.0 : -1.0
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vec2 VecToSphereOct(vec3 direction)
|
|
30
|
+
{
|
|
31
|
+
vec3 octant = sign_not_zero(direction);
|
|
32
|
+
|
|
33
|
+
// |x| + |y| + |z| = 1
|
|
34
|
+
float sum = dot(direction, octant);
|
|
35
|
+
vec3 octahedron = direction / sum;
|
|
36
|
+
|
|
37
|
+
if (direction.z < 0.0)
|
|
38
|
+
{
|
|
39
|
+
vec3 absolute = abs(octahedron);
|
|
40
|
+
|
|
41
|
+
octahedron.xy = octant.xy * vec2(1.0f - absolute.y, 1.0f - absolute.x);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return octahedron.xy;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
vec4 TriangleInterpolate(vec2 uv) {
|
|
49
|
+
uv = fract(uv);
|
|
50
|
+
|
|
51
|
+
vec2 omuv = vec2(1.0, 1.0) - uv.xy;
|
|
52
|
+
|
|
53
|
+
vec4 res = vec4(0, 0, 0, 0);
|
|
54
|
+
//frame 0
|
|
55
|
+
res.x = min(omuv.x, omuv.y);
|
|
56
|
+
//frame 1
|
|
57
|
+
res.y = abs(dot(uv, vec2(1.0, -1.0)));
|
|
58
|
+
//frame 2
|
|
59
|
+
res.z = min(uv.x, uv.y);
|
|
60
|
+
//mask
|
|
61
|
+
res.w = clamp(ceil(uv.x - uv.y), 0.0, 1.0);
|
|
62
|
+
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
vec4 quadBlendWieghts(vec2 coords)
|
|
67
|
+
{
|
|
68
|
+
vec4 res;
|
|
69
|
+
/* 0 0 0
|
|
70
|
+
0 0 0
|
|
71
|
+
1 0 0 */
|
|
72
|
+
res.x = min(1.0f - coords.x, 1.0f - coords.y);
|
|
73
|
+
/* 1 0 0
|
|
74
|
+
0 0 0
|
|
75
|
+
0 0 1 */
|
|
76
|
+
res.y = abs(coords.x - coords.y);
|
|
77
|
+
/* 0 0 1
|
|
78
|
+
0 0 0
|
|
79
|
+
0 0 0 */
|
|
80
|
+
res.z = min(coords.x, coords.y);
|
|
81
|
+
/* 0 0 0
|
|
82
|
+
0 0 1
|
|
83
|
+
0 1 1 */
|
|
84
|
+
res.w = ceil(coords.x - coords.y);
|
|
85
|
+
//res.xyz /= (res.x + res.y + res.z);
|
|
86
|
+
return res;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
90
|
+
|
|
91
|
+
float samp0 = textureLod(tex, uv0, 0.0).r;
|
|
92
|
+
float samp1 = textureLod(tex, uv1, 0.0).r;
|
|
93
|
+
float samp2 = textureLod(tex, uv2, 0.0).r;
|
|
94
|
+
|
|
95
|
+
return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
uniform sampler2D tDepth; // octahedron-encoded texture
|
|
102
|
+
uniform float fScale; // depth visualisation space
|
|
103
|
+
uniform float uResolution; // texture resulution
|
|
104
|
+
varying vec3 vNormal;
|
|
105
|
+
|
|
106
|
+
void main() {
|
|
107
|
+
vec3 normal = normalize(vNormal);
|
|
108
|
+
vec3 worldNormal = normalize(inverseTransformDirection(normal, viewMatrix));
|
|
109
|
+
|
|
110
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(worldNormal) * 0.5 + 0.5, 0.0, 1.0);
|
|
111
|
+
vec2 grid = octahedral_uv * vec2(uResolution - 1.0);
|
|
112
|
+
|
|
113
|
+
vec2 gridFrac = fract(grid);
|
|
114
|
+
vec2 gridFloor = floor(grid);
|
|
115
|
+
|
|
116
|
+
vec4 weights = quadBlendWieghts(gridFrac);
|
|
117
|
+
|
|
118
|
+
//3 nearest frames
|
|
119
|
+
vec2 frame0 = gridFloor;
|
|
120
|
+
vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);
|
|
121
|
+
vec2 frame2 = gridFloor + vec2(1.0, 1.0);
|
|
122
|
+
|
|
123
|
+
float value = SampleBlended(tDepth, (frame0+0.5) / uResolution, (frame1+0.5) / uResolution, (frame2+0.5) / uResolution, weights) * fScale;
|
|
124
|
+
|
|
125
|
+
gl_FragColor = vec4(vec3(value), 1.0);
|
|
126
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class VLPDepthMapVisualisation {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {LightProbeVolume} lpv
|
|
5
|
+
* @returns {VLPDepthMapVisualisation}
|
|
6
|
+
*/
|
|
7
|
+
static from(lpv: LightProbeVolume): VLPDepthMapVisualisation;
|
|
8
|
+
set volume(arg: any);
|
|
9
|
+
build(): Entity;
|
|
10
|
+
#private;
|
|
11
|
+
}
|
|
12
|
+
import Entity from "../../../../../../ecs/Entity.js";
|
|
13
|
+
//# sourceMappingURL=VLPDepthMapVisualisation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VLPDepthMapVisualisation.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js"],"names":[],"mappings":"AA6EA;IAYI;;;;OAIG;IACH,oCAFa,wBAAwB,CAQpC;IAfD,qBAEC;IAeD,gBA4CC;;CAEJ;mBAzIkB,iCAAiC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box3,
|
|
3
|
+
InstancedBufferAttribute,
|
|
4
|
+
InstancedBufferGeometry,
|
|
5
|
+
OctahedronBufferGeometry,
|
|
6
|
+
ShaderMaterial,
|
|
7
|
+
Sphere
|
|
8
|
+
} from "three";
|
|
9
|
+
import { BinaryDataType } from "../../../../../../../core/binary/type/BinaryDataType.js";
|
|
10
|
+
import { AABB3 } from "../../../../../../../core/geom/3d/aabb/AABB3.js";
|
|
11
|
+
import { aabb3_from_v3_array } from "../../../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
|
|
12
|
+
import Entity from "../../../../../../ecs/Entity.js";
|
|
13
|
+
import { Transform } from "../../../../../../ecs/transform/Transform.js";
|
|
14
|
+
import { ShadedGeometry } from "../../../../../ecs/mesh-v2/ShadedGeometry.js";
|
|
15
|
+
import { ShadedGeometryFlags } from "../../../../../ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
16
|
+
import { AttributeSpec } from "../../../../../geometry/AttributeSpec.js";
|
|
17
|
+
import { geometry_copy } from "../../../../../geometry/instancing/geometry_copy.js";
|
|
18
|
+
import { AttributeDataTexture } from "../../../../../texture/AttributeDataTexture.js";
|
|
19
|
+
import { makeOctahedralDepthAtlas } from "../../../../gi/material/makeOctahedralDepthAtlas.js";
|
|
20
|
+
import { octahedral_depth_to_atlas, vector_buffer_to_attribute_texture } from "../../../probe_volume_to_textures.js";
|
|
21
|
+
import fragment from './visualise.frag.glsl'
|
|
22
|
+
import vertex from './visualise.vert.glsl'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {LightProbeVolume} lpv
|
|
27
|
+
*/
|
|
28
|
+
function makeMaterial(lpv) {
|
|
29
|
+
const depth_atlas = makeOctahedralDepthAtlas();
|
|
30
|
+
const positions = new AttributeDataTexture(
|
|
31
|
+
AttributeSpec.fromJSON({
|
|
32
|
+
name: "positions",
|
|
33
|
+
type: BinaryDataType.Float32,
|
|
34
|
+
itemSize: 3,
|
|
35
|
+
normalized: false
|
|
36
|
+
}),
|
|
37
|
+
256, 1
|
|
38
|
+
);
|
|
39
|
+
vector_buffer_to_attribute_texture(positions, lpv.points, lpv.count, 3);
|
|
40
|
+
octahedral_depth_to_atlas(lpv, depth_atlas.image.data, depth_atlas.image.width);
|
|
41
|
+
|
|
42
|
+
const material = new ShaderMaterial({
|
|
43
|
+
fragmentShader: [fragment].join('\n'),
|
|
44
|
+
vertexShader: vertex,
|
|
45
|
+
lights: false,
|
|
46
|
+
uniforms: {
|
|
47
|
+
lpv_t_probe_positions: {
|
|
48
|
+
value: positions.texture
|
|
49
|
+
},
|
|
50
|
+
lpv_t_probe_depth: {
|
|
51
|
+
value: depth_atlas
|
|
52
|
+
},
|
|
53
|
+
lpv_u_probe_depth_resolution:{
|
|
54
|
+
value: lpv.depth_map_resolution
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return material;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {THREE.BufferGeometry} geometry
|
|
65
|
+
* @param {AABB3} bounds
|
|
66
|
+
*/
|
|
67
|
+
function buffer_geometry_set_bounds_by_aabb3(geometry, bounds) {
|
|
68
|
+
geometry.boundingBox = new Box3()
|
|
69
|
+
geometry.boundingSphere = new Sphere()
|
|
70
|
+
|
|
71
|
+
geometry.boundingBox.min.set(bounds.x0, bounds.y0, bounds.z0);
|
|
72
|
+
geometry.boundingBox.max.set(bounds.x1, bounds.y1, bounds.z1);
|
|
73
|
+
|
|
74
|
+
bounds.getCenter(geometry.boundingSphere.center);
|
|
75
|
+
geometry.boundingSphere.radius = Math.hypot(bounds.getHalfExtentsX(), bounds.getHalfExtentsY(), bounds.getHalfExtentsZ());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class VLPDepthMapVisualisation {
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @type {LightProbeVolume}
|
|
82
|
+
*/
|
|
83
|
+
#volume
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
set volume(lpv) {
|
|
87
|
+
this.#volume = lpv;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {LightProbeVolume} lpv
|
|
93
|
+
* @returns {VLPDepthMapVisualisation}
|
|
94
|
+
*/
|
|
95
|
+
static from(lpv) {
|
|
96
|
+
const r = new VLPDepthMapVisualisation();
|
|
97
|
+
|
|
98
|
+
r.volume = lpv;
|
|
99
|
+
|
|
100
|
+
return r;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
build() {
|
|
104
|
+
|
|
105
|
+
const geometry = new InstancedBufferGeometry();
|
|
106
|
+
|
|
107
|
+
const volume = this.#volume;
|
|
108
|
+
|
|
109
|
+
geometry.instanceCount = volume.count;
|
|
110
|
+
|
|
111
|
+
geometry_copy(geometry, new OctahedronBufferGeometry(0.4, 4));
|
|
112
|
+
|
|
113
|
+
const positions_attribute = new InstancedBufferAttribute(new Float32Array(volume.points), 3);
|
|
114
|
+
geometry.setAttribute("instancePosition", positions_attribute);
|
|
115
|
+
|
|
116
|
+
const bounds = new AABB3();
|
|
117
|
+
|
|
118
|
+
aabb3_from_v3_array(bounds, volume.points, volume.points.length);
|
|
119
|
+
|
|
120
|
+
const instance_bounds = new AABB3();
|
|
121
|
+
|
|
122
|
+
const geo_position_data = geometry.getAttribute('position').array;
|
|
123
|
+
aabb3_from_v3_array(instance_bounds, geo_position_data, geo_position_data.length);
|
|
124
|
+
|
|
125
|
+
// extend by bounds of a single instance
|
|
126
|
+
bounds.x0 += instance_bounds.x0;
|
|
127
|
+
bounds.y0 += instance_bounds.y0;
|
|
128
|
+
bounds.z0 += instance_bounds.z0;
|
|
129
|
+
|
|
130
|
+
bounds.x1 += instance_bounds.x1;
|
|
131
|
+
bounds.y1 += instance_bounds.y1;
|
|
132
|
+
bounds.z1 += instance_bounds.z1;
|
|
133
|
+
|
|
134
|
+
buffer_geometry_set_bounds_by_aabb3(geometry, bounds);
|
|
135
|
+
|
|
136
|
+
const sg = ShadedGeometry.from(geometry, makeMaterial(volume));
|
|
137
|
+
|
|
138
|
+
sg.setFlag(ShadedGeometryFlags.DrawMethodLocked);
|
|
139
|
+
|
|
140
|
+
const entity = new Entity();
|
|
141
|
+
|
|
142
|
+
entity.add(new Transform());
|
|
143
|
+
entity.add(sg);
|
|
144
|
+
|
|
145
|
+
return entity;
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
vec3 inverseTransformDirection(in vec3 normal, in mat4 matrix) {
|
|
4
|
+
// matrix is assumed to be orthogonal
|
|
5
|
+
return normalize((vec4(normal, 0.0) * matrix).xyz);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
precision highp usampler2D;
|
|
10
|
+
precision highp usampler3D;
|
|
11
|
+
|
|
12
|
+
uniform sampler2D lpv_t_probe_positions;
|
|
13
|
+
uniform sampler2D lpv_t_probe_depth;
|
|
14
|
+
|
|
15
|
+
uniform uint lpv_u_probe_depth_resolution;
|
|
16
|
+
|
|
17
|
+
#define SEARCH_STEP_LIMIT 64u
|
|
18
|
+
#define INVALID_TET 1073741823u
|
|
19
|
+
|
|
20
|
+
ivec2 lpv_index_to_256_coordinate(uint index) {
|
|
21
|
+
|
|
22
|
+
uint pixel_x = index % 256u;
|
|
23
|
+
uint pixel_y = index / 256u;
|
|
24
|
+
|
|
25
|
+
return ivec2(int(pixel_x), int(pixel_y));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
vec3 sign_not_zero(vec3 x) {
|
|
29
|
+
return vec3(
|
|
30
|
+
x.x >= 0.0 ? 1.0 : -1.0,
|
|
31
|
+
x.y >= 0.0 ? 1.0 : -1.0,
|
|
32
|
+
x.z >= 0.0 ? 1.0 : -1.0
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
vec4 quadBlendWieghts(vec2 coords)
|
|
37
|
+
{
|
|
38
|
+
vec4 res;
|
|
39
|
+
/* 0 0 0
|
|
40
|
+
0 0 0
|
|
41
|
+
1 0 0 */
|
|
42
|
+
res.x = min(1.0f - coords.x, 1.0f - coords.y);
|
|
43
|
+
/* 1 0 0
|
|
44
|
+
0 0 0
|
|
45
|
+
0 0 1 */
|
|
46
|
+
res.y = abs(coords.x - coords.y);
|
|
47
|
+
/* 0 0 1
|
|
48
|
+
0 0 0
|
|
49
|
+
0 0 0 */
|
|
50
|
+
res.z = min(coords.x, coords.y);
|
|
51
|
+
/* 0 0 0
|
|
52
|
+
0 0 1
|
|
53
|
+
0 1 1 */
|
|
54
|
+
res.w = ceil(coords.x - coords.y);
|
|
55
|
+
//res.xyz /= (res.x + res.y + res.z);
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
vec2 VecToSphereOct(vec3 direction)
|
|
61
|
+
{
|
|
62
|
+
vec3 octant = sign_not_zero(direction);
|
|
63
|
+
|
|
64
|
+
// |x| + |y| + |z| = 1
|
|
65
|
+
float sum = dot(direction, octant);
|
|
66
|
+
vec3 octahedron = direction / sum;
|
|
67
|
+
|
|
68
|
+
if (direction.y < 0.0)
|
|
69
|
+
{
|
|
70
|
+
vec3 absolute = abs(octahedron);
|
|
71
|
+
|
|
72
|
+
octahedron.xz = octant.xz * vec2(1.0f - absolute.z, 1.0f - absolute.x);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return octahedron.xz;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
79
|
+
|
|
80
|
+
float samp0 = textureLod(tex, uv0, 0.0).r;
|
|
81
|
+
float samp1 = textureLod(tex, uv1, 0.0).r;
|
|
82
|
+
float samp2 = textureLod(tex, uv2, 0.0).r;
|
|
83
|
+
|
|
84
|
+
return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
float lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
88
|
+
// get offset
|
|
89
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
90
|
+
uvec2 atlas_size = uvec2(4096u);
|
|
91
|
+
|
|
92
|
+
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
93
|
+
|
|
94
|
+
uint tile_x = probe_index % tiles_per_row;
|
|
95
|
+
uint tile_y = probe_index / tiles_per_row;
|
|
96
|
+
|
|
97
|
+
vec2 tile_offset = vec2(
|
|
98
|
+
tile_x * depth_tile_resolution,
|
|
99
|
+
tile_y * depth_tile_resolution
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// convert direction to UV
|
|
103
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
104
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);
|
|
105
|
+
|
|
106
|
+
vec2 gridFrac = fract(grid);
|
|
107
|
+
vec2 gridFloor = floor(grid);
|
|
108
|
+
|
|
109
|
+
vec4 weights = quadBlendWieghts(gridFrac);
|
|
110
|
+
|
|
111
|
+
//3 nearest frames
|
|
112
|
+
vec2 frame0 = gridFloor;
|
|
113
|
+
vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);
|
|
114
|
+
vec2 frame2 = gridFloor + vec2(1.0, 1.0);
|
|
115
|
+
|
|
116
|
+
// move frames to atlas space
|
|
117
|
+
frame0 += tile_offset;
|
|
118
|
+
frame1 += tile_offset;
|
|
119
|
+
frame2 += tile_offset;
|
|
120
|
+
|
|
121
|
+
vec2 uv0 = (frame0 + 0.5) / vec2(atlas_size);
|
|
122
|
+
vec2 uv1 = (frame1 + 0.5) / vec2(atlas_size);
|
|
123
|
+
vec2 uv2 = (frame2 + 0.5) / vec2(atlas_size);
|
|
124
|
+
|
|
125
|
+
return SampleBlended(
|
|
126
|
+
lpv_t_probe_depth,
|
|
127
|
+
uv0, uv1, uv2,
|
|
128
|
+
weights
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
vec3 lpv_probe_getPosition(uint probe_index) {
|
|
133
|
+
return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
137
|
+
|
|
138
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
139
|
+
|
|
140
|
+
vec3 local_probe_offset = probe_position - position;
|
|
141
|
+
|
|
142
|
+
vec3 direction = normalize(local_probe_offset);
|
|
143
|
+
|
|
144
|
+
float depth = lpv_probe_getDepth(probe_index, -direction);
|
|
145
|
+
|
|
146
|
+
// return step(depth, length(local_probe_offset));
|
|
147
|
+
return step(depth, 20.0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
varying vec3 vNormal;
|
|
151
|
+
flat varying uint instance_index;
|
|
152
|
+
|
|
153
|
+
void main() {
|
|
154
|
+
vec3 normal = normalize(vNormal);
|
|
155
|
+
vec3 worldNormal = normalize(inverseTransformDirection(normal, viewMatrix));
|
|
156
|
+
|
|
157
|
+
float depth = lpv_probe_getDepth(instance_index , worldNormal) / 7.0;
|
|
158
|
+
|
|
159
|
+
gl_FragColor = vec4(vec3(depth), 1.0);
|
|
160
|
+
// gl_FragColor = vec4( 1.0);
|
|
161
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
varying vec3 vNormal;
|
|
2
|
+
|
|
3
|
+
attribute vec3 instancePosition;
|
|
4
|
+
flat varying uint instance_index;
|
|
5
|
+
|
|
6
|
+
void main() {
|
|
7
|
+
|
|
8
|
+
vNormal = normalize( normalMatrix * normal );
|
|
9
|
+
instance_index = uint(gl_InstanceID);
|
|
10
|
+
|
|
11
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position + instancePosition, 1.0 );
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sh3_bake_depth.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.js"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,uCATW,MAAM,EAAE,iBACR,MAAM,sCAEN,MAAM,cACN,MAAM,cACN,MAAM,cACN,MAAM,eACN,MAAM,QAsDhB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { array_copy } from "
|
|
2
|
-
import { Ray3 } from "
|
|
3
|
-
import { sh3_basis_at } from "
|
|
4
|
-
import { sh3_vector_accumulate } from "
|
|
5
|
-
import { vector_scale_array } from "
|
|
6
|
-
import { clamp01 } from "
|
|
7
|
-
import { OctahedralUvEncoder } from "
|
|
1
|
+
import { array_copy } from "../../../../../core/collection/array/array_copy.js";
|
|
2
|
+
import { Ray3 } from "../../../../../core/geom/3d/Ray3.js";
|
|
3
|
+
import { sh3_basis_at } from "../../../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
|
|
4
|
+
import { sh3_vector_accumulate } from "../../../../../core/geom/3d/sphere/harmonics/sh3_vector_accumulate.js";
|
|
5
|
+
import { vector_scale_array } from "../../../../../core/geom/vec/vector_scale_array.js";
|
|
6
|
+
import { clamp01 } from "../../../../../core/math/clamp01.js";
|
|
7
|
+
import { OctahedralUvEncoder } from "../../../impostors/octahedral/grid/OctahedralUvEncoder.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} vertex_index
|
|
4
|
+
* @param {TetrahedralMesh} mesh
|
|
5
|
+
* @param {number[]} points
|
|
6
|
+
*/
|
|
7
|
+
export function find_max_depth_radius_for_point(vertex_index: number, mesh: TetrahedralMesh, points: number[]): number;
|
|
8
|
+
//# sourceMappingURL=find_max_depth_radius_for_point.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_max_depth_radius_for_point.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,8DAJW,MAAM,iCAEN,MAAM,EAAE,UAiClB"}
|