@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,484 @@
|
|
|
1
|
+
#ifndef LPV_SHADER_CHUNK_COMMON
|
|
2
|
+
#define LPV_SHADER_CHUNK_COMMON
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
uniform usampler2D lpv_t_mesh_vertices;
|
|
6
|
+
uniform usampler2D lpv_t_mesh_neighbours;
|
|
7
|
+
uniform usampler3D lpv_t_mesh_lookup;
|
|
8
|
+
|
|
9
|
+
uniform sampler2D lpv_t_probe_positions;
|
|
10
|
+
uniform sampler2D lpv_t_probe_data;
|
|
11
|
+
|
|
12
|
+
uniform sampler2D lpv_t_probe_depth;
|
|
13
|
+
uniform uint lpv_u_probe_depth_resolution;
|
|
14
|
+
|
|
15
|
+
uniform uint lpv_u_mesh_tet_count;
|
|
16
|
+
uniform vec3 lpv_v3_bounds_min;
|
|
17
|
+
uniform vec3 lpv_v3_bounds_max;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const float lpv_min_thickness = 0.03; // in Meters
|
|
21
|
+
const float lpv_max_thickness = 0.50; // in Meters
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#define SEARCH_STEP_LIMIT 32u
|
|
25
|
+
#define INVALID_TET 1073741823u
|
|
26
|
+
|
|
27
|
+
ivec2 lpv_index_to_256_coordinate(uint index) {
|
|
28
|
+
|
|
29
|
+
uint pixel_x = index % 256u;
|
|
30
|
+
uint pixel_y = index / 256u;
|
|
31
|
+
|
|
32
|
+
return ivec2(int(pixel_x), int(pixel_y));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
uvec4 lpv_mesh_getVertices(uint tet_index) {
|
|
36
|
+
ivec2 p = lpv_index_to_256_coordinate(tet_index);
|
|
37
|
+
|
|
38
|
+
return texelFetch(lpv_t_mesh_vertices, p, 0);
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
uvec4 lpv_mesh_getNeighbours(uint tet_index) {
|
|
43
|
+
ivec2 p = lpv_index_to_256_coordinate(tet_index);
|
|
44
|
+
|
|
45
|
+
return texelFetch(lpv_t_mesh_neighbours, p, 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
vec3[9] lpv_probe_getData(uint probe_index) {
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
int slot = int(probe_index % 256u);
|
|
52
|
+
int column = int(probe_index / 256u);
|
|
53
|
+
|
|
54
|
+
int offset_x = int(slot * 9);
|
|
55
|
+
|
|
56
|
+
vec3[9] result;
|
|
57
|
+
|
|
58
|
+
for (int i = 0; i < 9; i++) {
|
|
59
|
+
result[i] = texelFetch(lpv_t_probe_data, ivec2(offset_x + i, column), 0).rgb;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
vec3 sign_not_zero(vec3 x) {
|
|
66
|
+
return vec3(
|
|
67
|
+
x.x >= 0.0 ? 1.0 : -1.0,
|
|
68
|
+
x.y >= 0.0 ? 1.0 : -1.0,
|
|
69
|
+
x.z >= 0.0 ? 1.0 : -1.0
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
vec4 quadBlendWieghts(vec2 coords)
|
|
74
|
+
{
|
|
75
|
+
vec4 res;
|
|
76
|
+
/* 0 0 0
|
|
77
|
+
0 0 0
|
|
78
|
+
1 0 0 */
|
|
79
|
+
res.x = min(1.0f - coords.x, 1.0f - coords.y);
|
|
80
|
+
/* 1 0 0
|
|
81
|
+
0 0 0
|
|
82
|
+
0 0 1 */
|
|
83
|
+
res.y = abs(coords.x - coords.y);
|
|
84
|
+
/* 0 0 1
|
|
85
|
+
0 0 0
|
|
86
|
+
0 0 0 */
|
|
87
|
+
res.z = min(coords.x, coords.y);
|
|
88
|
+
/* 0 0 0
|
|
89
|
+
0 0 1
|
|
90
|
+
0 1 1 */
|
|
91
|
+
res.w = ceil(coords.x - coords.y);
|
|
92
|
+
//res.xyz /= (res.x + res.y + res.z);
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//vec2 VecToSphereOct(vec3 direction)
|
|
97
|
+
//{
|
|
98
|
+
// vec3 octant = sign_not_zero(direction);
|
|
99
|
+
//
|
|
100
|
+
// // |x| + |y| + |z| = 1
|
|
101
|
+
// float sum = dot(direction, octant);
|
|
102
|
+
// vec3 octahedron = direction / sum;
|
|
103
|
+
//
|
|
104
|
+
// if (direction.z < 0.0)
|
|
105
|
+
// {
|
|
106
|
+
// vec3 absolute = abs(octahedron);
|
|
107
|
+
//
|
|
108
|
+
// octahedron.xy = octant.xy * vec2(1.0f - absolute.y, 1.0f - absolute.x);
|
|
109
|
+
// }
|
|
110
|
+
//
|
|
111
|
+
// return octahedron.xy;
|
|
112
|
+
//}
|
|
113
|
+
|
|
114
|
+
vec2 VecToSphereOct(vec3 direction)
|
|
115
|
+
{
|
|
116
|
+
vec3 octant = sign_not_zero(direction);
|
|
117
|
+
|
|
118
|
+
// |x| + |y| + |z| = 1
|
|
119
|
+
float sum = dot(direction, octant);
|
|
120
|
+
vec3 octahedron = direction / sum;
|
|
121
|
+
|
|
122
|
+
if (direction.y < 0.0)
|
|
123
|
+
{
|
|
124
|
+
vec3 absolute = abs(octahedron);
|
|
125
|
+
|
|
126
|
+
octahedron.xz = octant.xz * vec2(1.0f - absolute.z, 1.0f - absolute.x);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return octahedron.xz;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
133
|
+
|
|
134
|
+
float samp0 = textureLod(tex, uv0, 0.0).r;
|
|
135
|
+
float samp1 = textureLod(tex, uv1, 0.0).r;
|
|
136
|
+
float samp2 = textureLod(tex, uv2, 0.0).r;
|
|
137
|
+
|
|
138
|
+
return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
vec2 lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
142
|
+
// get offset
|
|
143
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
144
|
+
uvec2 atlas_size = uvec2(4096u);
|
|
145
|
+
|
|
146
|
+
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
147
|
+
|
|
148
|
+
uint tile_x = probe_index % tiles_per_row;
|
|
149
|
+
uint tile_y = probe_index / tiles_per_row;
|
|
150
|
+
|
|
151
|
+
vec2 tile_offset = vec2(
|
|
152
|
+
tile_x * depth_tile_resolution,
|
|
153
|
+
tile_y * depth_tile_resolution
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// convert direction to UV
|
|
157
|
+
vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);
|
|
158
|
+
vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);
|
|
159
|
+
|
|
160
|
+
vec2 gridFrac = fract(grid);
|
|
161
|
+
vec2 gridFloor = floor(grid);
|
|
162
|
+
|
|
163
|
+
vec4 weights = quadBlendWieghts(gridFrac);
|
|
164
|
+
|
|
165
|
+
//3 nearest frames
|
|
166
|
+
vec2 frame0 = gridFloor;
|
|
167
|
+
vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);
|
|
168
|
+
vec2 frame2 = gridFloor + vec2(1.0, 1.0);
|
|
169
|
+
|
|
170
|
+
// move frames to atlas space
|
|
171
|
+
frame0 += tile_offset;
|
|
172
|
+
frame1 += tile_offset;
|
|
173
|
+
frame2 += tile_offset;
|
|
174
|
+
|
|
175
|
+
float samp0 = texelFetch(lpv_t_probe_depth, ivec2(frame0), 0).r;
|
|
176
|
+
float samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).r;
|
|
177
|
+
float samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).r;
|
|
178
|
+
|
|
179
|
+
float mean = samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
180
|
+
float mean2 = samp0 * samp0 * weights.x + samp1 * samp1 * weights.y + samp2 * samp2 * weights.z;
|
|
181
|
+
|
|
182
|
+
return vec2(mean, mean2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
vec3 lpv_probe_getPosition(uint probe_index) {
|
|
186
|
+
return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
mat3 lpv_mesh_makeMatrix(vec3 p0, vec3 p1, vec3 p2, vec3 p3) {
|
|
190
|
+
|
|
191
|
+
return inverse(
|
|
192
|
+
mat3(
|
|
193
|
+
p0 - p3,
|
|
194
|
+
p1 - p3,
|
|
195
|
+
p2 - p3
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
vec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position) {
|
|
202
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
203
|
+
|
|
204
|
+
vec3 p0 = lpv_probe_getPosition(vertices[0]);
|
|
205
|
+
vec3 p1 = lpv_probe_getPosition(vertices[1]);
|
|
206
|
+
vec3 p2 = lpv_probe_getPosition(vertices[2]);
|
|
207
|
+
vec3 p3 = lpv_probe_getPosition(vertices[3]);
|
|
208
|
+
|
|
209
|
+
mat3 matrix = lpv_mesh_makeMatrix(p0, p1, p2, p3);
|
|
210
|
+
|
|
211
|
+
vec3 mult = matrix * (position - p3);
|
|
212
|
+
|
|
213
|
+
return vec4(mult, 1.0 - mult.x - mult.y - mult.z);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void lpv_walk_to_tetrahedron(
|
|
217
|
+
in vec3 position,
|
|
218
|
+
in uint tet_guess,
|
|
219
|
+
out uint tet_index,
|
|
220
|
+
out vec4 weights
|
|
221
|
+
) {
|
|
222
|
+
uint came_from = 0u;
|
|
223
|
+
|
|
224
|
+
tet_index = tet_guess;
|
|
225
|
+
|
|
226
|
+
for (uint i = 0u; i < SEARCH_STEP_LIMIT; i++) {
|
|
227
|
+
|
|
228
|
+
weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);
|
|
229
|
+
|
|
230
|
+
if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
uvec4 neighbors = lpv_mesh_getNeighbours(tet_index);
|
|
235
|
+
|
|
236
|
+
uint next_tet;
|
|
237
|
+
|
|
238
|
+
// Otherwise find the smallest barycentric coord and move in that direction
|
|
239
|
+
if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) {
|
|
240
|
+
next_tet = neighbors[0];
|
|
241
|
+
} else if (weights.y < weights.z && weights.y < weights.w) {
|
|
242
|
+
next_tet = neighbors[1];
|
|
243
|
+
} else if (weights.z < weights.w) {
|
|
244
|
+
next_tet = neighbors[2];
|
|
245
|
+
} else {
|
|
246
|
+
next_tet = neighbors[3];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (next_tet == came_from) {
|
|
250
|
+
// numerical instability caused us to oscillate on the boundary
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
came_from = tet_index;
|
|
255
|
+
tet_index = next_tet;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
tet_index = INVALID_TET;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
262
|
+
|
|
263
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
264
|
+
|
|
265
|
+
vec3 local_probe_offset = probe_position - position;
|
|
266
|
+
|
|
267
|
+
float distToProbe = length(local_probe_offset);
|
|
268
|
+
|
|
269
|
+
vec3 direction = normalize(local_probe_offset);
|
|
270
|
+
|
|
271
|
+
vec2 temp = lpv_probe_getDepth(probe_index, direction);
|
|
272
|
+
|
|
273
|
+
float mean = temp.x;
|
|
274
|
+
float variance = abs(mean * mean - temp.y);
|
|
275
|
+
|
|
276
|
+
// http://www.punkuser.net/vsm/vsm_paper.pdf; equation 5
|
|
277
|
+
// Need the max in the denominator because biasing can cause a negative displacement
|
|
278
|
+
float distance_delta = max(distToProbe - mean, 0.0);
|
|
279
|
+
|
|
280
|
+
float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
|
|
281
|
+
|
|
282
|
+
// Increase contrast in the weight
|
|
283
|
+
// chebyshevWeight = max(chebyshevWeight*chebyshevWeight*chebyshevWeight, 0.0);
|
|
284
|
+
|
|
285
|
+
return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
vec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4 weights) {
|
|
289
|
+
|
|
290
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
291
|
+
|
|
292
|
+
vec4 visibility = vec4(
|
|
293
|
+
lpv_probe_getVisibilityMask(position, vertices[0]),
|
|
294
|
+
lpv_probe_getVisibilityMask(position, vertices[1]),
|
|
295
|
+
lpv_probe_getVisibilityMask(position, vertices[2]),
|
|
296
|
+
lpv_probe_getVisibilityMask(position, vertices[3])
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
return visibility * weights;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
float lpv_probe_visibility_weight(uint probe_index, vec3 position, vec3 normal) {
|
|
303
|
+
float weight = 1.0;
|
|
304
|
+
|
|
305
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
306
|
+
|
|
307
|
+
vec3 direction_to_probe = normalize(probe_position - position);
|
|
308
|
+
|
|
309
|
+
// Smooth backface test
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// The naive soft backface weight would ignore a probe when
|
|
313
|
+
// it is behind the surface. That's good for walls. But for small details inside of a
|
|
314
|
+
// room, the normals on the details might rule out all of the probes that have mutual
|
|
315
|
+
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
316
|
+
// NPR work.
|
|
317
|
+
// weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
318
|
+
|
|
319
|
+
// The small offset at the end reduces the "going to zero" impact
|
|
320
|
+
// where this is really close to exactly opposite
|
|
321
|
+
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
322
|
+
weight *= backface_term * backface_term + 0.2;
|
|
323
|
+
|
|
324
|
+
weight *= lpv_probe_getVisibilityMask(position, probe_index);
|
|
325
|
+
|
|
326
|
+
// Avoid zero weight
|
|
327
|
+
weight = max(0.000001, weight);
|
|
328
|
+
|
|
329
|
+
return weight;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {
|
|
333
|
+
|
|
334
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
335
|
+
|
|
336
|
+
vec4 visibility;
|
|
337
|
+
|
|
338
|
+
for (int i = 0; i < 4; i++) {
|
|
339
|
+
vec3 probe_position = lpv_probe_getPosition(vertices[i]);
|
|
340
|
+
|
|
341
|
+
vec3 direction_to_probe = position - probe_position;
|
|
342
|
+
|
|
343
|
+
visibility[i] = step(dot(direction_to_probe, normal), 0.0);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return visibility * weights;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
vec4 lvp_mask_weights_by_visibility(vec3 position, vec3 normal, uint tet_index) {
|
|
350
|
+
|
|
351
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
352
|
+
|
|
353
|
+
vec4 visibility;
|
|
354
|
+
|
|
355
|
+
for (int i = 0; i < 4; i++) {
|
|
356
|
+
visibility[i] = lpv_probe_visibility_weight(vertices[i], position, normal);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return visibility;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
vec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index) {
|
|
363
|
+
|
|
364
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
365
|
+
|
|
366
|
+
vec3[9] probe0 = lpv_probe_getData(vertices[0]);
|
|
367
|
+
vec3[9] probe1 = lpv_probe_getData(vertices[1]);
|
|
368
|
+
vec3[9] probe2 = lpv_probe_getData(vertices[2]);
|
|
369
|
+
vec3[9] probe3 = lpv_probe_getData(vertices[3]);
|
|
370
|
+
|
|
371
|
+
vec3[9] result;
|
|
372
|
+
|
|
373
|
+
for (int i = 0; i < 9; i++) {
|
|
374
|
+
|
|
375
|
+
result[i] = probe0[i] * weights[0]
|
|
376
|
+
+ probe1[i] * weights[1]
|
|
377
|
+
+ probe2[i] * weights[2]
|
|
378
|
+
+ probe3[i] * weights[3];
|
|
379
|
+
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
uint lpv_guess_initial_tet(vec3 position) {
|
|
386
|
+
|
|
387
|
+
vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
|
|
388
|
+
vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
|
|
389
|
+
|
|
390
|
+
vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);
|
|
391
|
+
|
|
392
|
+
return textureLod(lpv_t_mesh_lookup, lookup_coordinates, 0.0).r;
|
|
393
|
+
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
|
|
397
|
+
vec3 lpv_get_irradiance_at(in vec3 normal, in vec3 shCoefficients[9]) {
|
|
398
|
+
// normal is assumed to have unit length
|
|
399
|
+
float x = normal.x, y = normal.y, z = normal.z;
|
|
400
|
+
|
|
401
|
+
// band 0
|
|
402
|
+
vec3 result = shCoefficients[0] * 0.8862269254527579;
|
|
403
|
+
|
|
404
|
+
// band 1
|
|
405
|
+
result -= shCoefficients[1] * 1.0233267079464885 * y;
|
|
406
|
+
result += shCoefficients[2] * 1.0233267079464885 * z;
|
|
407
|
+
result -= shCoefficients[3] * 1.0233267079464885 * x;
|
|
408
|
+
|
|
409
|
+
// band 2
|
|
410
|
+
result += shCoefficients[4] * 0.8580855308097834 * x * y;
|
|
411
|
+
result -= shCoefficients[5] * 0.8580855308097834 * y * z;
|
|
412
|
+
result += shCoefficients[6] * (0.7431238683011272 * z * z - 0.24770795610037571);
|
|
413
|
+
result -= shCoefficients[7] * 0.8580855308097834 * x * z;
|
|
414
|
+
result += shCoefficients[8] * 0.4290427654048917 * (x * x - y * y);
|
|
415
|
+
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
vec4 lpv_renormalize_weights(in vec4 source) {
|
|
420
|
+
|
|
421
|
+
float sum = source.x + source.y + source.z + source.w;
|
|
422
|
+
|
|
423
|
+
if (sum <= 0.0) {
|
|
424
|
+
return vec4(1.0);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return source / sum;
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
/** Slightly bump the location of the shadow test point away from the shadow casting surface.
|
|
434
|
+
The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is
|
|
435
|
+
to it the more the light leaks.
|
|
436
|
+
*/
|
|
437
|
+
#define LPV_NORMAL_BIAS 0.01f
|
|
438
|
+
|
|
439
|
+
vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
440
|
+
|
|
441
|
+
// Bias the position at which visibility is computed; this
|
|
442
|
+
// avoids performing a shadow test *at* a surface, which is a
|
|
443
|
+
// dangerous location because that is exactly the line between
|
|
444
|
+
// shadowed and unshadowed. If the normal bias is too small,
|
|
445
|
+
// there will be light and dark leaks. If it is too large,
|
|
446
|
+
// then samples can pass through thin occluders to the other
|
|
447
|
+
// side (this can only happen if there are MULTIPLE occluders
|
|
448
|
+
// near each other, a wall surface won't pass through itself.)
|
|
449
|
+
vec3 lookup_position = position + (normal + view_direction * 3.0) * LPV_NORMAL_BIAS;
|
|
450
|
+
|
|
451
|
+
// lookup nearby tet
|
|
452
|
+
vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
|
|
453
|
+
vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
|
|
454
|
+
vec3 lookup_coordinates = (lookup_position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
uint nearest_tet = lpv_guess_initial_tet(lookup_position);
|
|
458
|
+
|
|
459
|
+
uint tet;
|
|
460
|
+
vec4 weights;
|
|
461
|
+
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet, weights);
|
|
462
|
+
|
|
463
|
+
// apply visibility term
|
|
464
|
+
// weights = lvp_mask_weights_by_visibility_by_depth(lookup_position, tet, weights);
|
|
465
|
+
// weights = lvp_mask_weights_by_visibility_by_normal(lookup_position,normal, tet, weights);
|
|
466
|
+
weights *= lvp_mask_weights_by_visibility(lookup_position, normal, tet);
|
|
467
|
+
|
|
468
|
+
// re-normalize weights
|
|
469
|
+
weights = lpv_renormalize_weights(weights);
|
|
470
|
+
|
|
471
|
+
if (tet == INVALID_TET) {
|
|
472
|
+
// do nothing
|
|
473
|
+
return vec3(0.0);
|
|
474
|
+
|
|
475
|
+
} else {
|
|
476
|
+
|
|
477
|
+
vec3[9] lpv_values = lpv_interpolate_probes(weights, tet);
|
|
478
|
+
|
|
479
|
+
return lpv_get_irradiance_at(normal, lpv_values);
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#endif
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeLookupTexture3D.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,gDAHW,MAAM,GACJ,aAAa,CA6BzB;8BAlCoG,OAAO"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ClampToEdgeWrapping, DataTexture3D, NearestFilter, RedIntegerFormat, UnsignedIntType } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Uint32
|
|
5
|
+
* @param {number} resolution
|
|
6
|
+
* @returns {DataTexture3D}
|
|
7
|
+
*/
|
|
8
|
+
export function makeLookupTexture3D(resolution) {
|
|
9
|
+
|
|
10
|
+
const lookup = new DataTexture3D(
|
|
11
|
+
new Uint32Array(resolution * resolution * resolution),
|
|
12
|
+
resolution,
|
|
13
|
+
resolution,
|
|
14
|
+
resolution
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
lookup.name = "Tetrahedron Lookup";
|
|
18
|
+
|
|
19
|
+
lookup.flipY = false;
|
|
20
|
+
lookup.generateMipmaps = false;
|
|
21
|
+
lookup.magFilter = NearestFilter;
|
|
22
|
+
lookup.minFilter = NearestFilter;
|
|
23
|
+
|
|
24
|
+
lookup.wrapT = ClampToEdgeWrapping;
|
|
25
|
+
lookup.wrapS = ClampToEdgeWrapping;
|
|
26
|
+
lookup.wrapR = ClampToEdgeWrapping;
|
|
27
|
+
|
|
28
|
+
lookup.type = UnsignedIntType;
|
|
29
|
+
lookup.format = RedIntegerFormat;
|
|
30
|
+
lookup.internalFormat = "R32UI";
|
|
31
|
+
|
|
32
|
+
lookup.needsUpdate = true;
|
|
33
|
+
|
|
34
|
+
return lookup;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeOctahedralDepthAtlas.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sDAHW,MAAM,GACJ,WAAW,CAsBvB;4BA3BqF,OAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ClampToEdgeWrapping, DataTexture, FloatType, NearestFilter, RedFormat } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} resolution
|
|
6
|
+
* @returns {DataTexture}
|
|
7
|
+
*/
|
|
8
|
+
export function makeOctahedralDepthAtlas(resolution = 4096) {
|
|
9
|
+
const texture = new DataTexture(
|
|
10
|
+
new Float32Array(resolution * resolution),
|
|
11
|
+
resolution,
|
|
12
|
+
resolution,
|
|
13
|
+
RedFormat,
|
|
14
|
+
FloatType
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
texture.minFilter = texture.magFilter = NearestFilter;
|
|
18
|
+
|
|
19
|
+
texture.wrapT = ClampToEdgeWrapping;
|
|
20
|
+
texture.wrapS = ClampToEdgeWrapping;
|
|
21
|
+
|
|
22
|
+
texture.flipY = false;
|
|
23
|
+
texture.generateMipmaps = false;
|
|
24
|
+
|
|
25
|
+
texture.needsUpdate = true;
|
|
26
|
+
|
|
27
|
+
return texture;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_fragment_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js"],"names":[],"mappings":"AAkCA;;;GAGG;AACH,8CAFW,MAAM,UAchB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { insert_after } from "../../../../../../core/primitives/strings/insert_after.js";
|
|
2
|
+
import PREAMBLE_COMMON from "../common.glsl";
|
|
3
|
+
|
|
4
|
+
const PREAMBLE = `
|
|
5
|
+
#ifndef LPV_SHADER_CHUNK_PREAMBLE
|
|
6
|
+
#define LPV_SHADER_CHUNK_PREAMBLE
|
|
7
|
+
|
|
8
|
+
precision highp usampler2D;
|
|
9
|
+
precision highp usampler3D;
|
|
10
|
+
|
|
11
|
+
varying vec3 vWorldPosition;
|
|
12
|
+
|
|
13
|
+
uniform float lpv_f_intensity;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const ACCUMULATION = `
|
|
21
|
+
{
|
|
22
|
+
|
|
23
|
+
vec3 world_normal = normalize(inverseTransformDirection( geometry.normal, viewMatrix ));
|
|
24
|
+
|
|
25
|
+
vec3 probe_irradiance = lpv_sample_irradiance( vWorldPosition, world_normal, geometry.viewDir );
|
|
26
|
+
|
|
27
|
+
irradiance += probe_irradiance * lpv_f_intensity;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {string} source
|
|
38
|
+
*/
|
|
39
|
+
export function build_fragment_shader(source) {
|
|
40
|
+
|
|
41
|
+
let result = PREAMBLE + PREAMBLE_COMMON + source;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
result = insert_after(
|
|
45
|
+
result,
|
|
46
|
+
'#include <lights_fragment_begin>',
|
|
47
|
+
ACCUMULATION
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_vertex_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH,4CAFW,MAAM,UAmBhB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { insert_after } from "../../../../../../core/primitives/strings/insert_after.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const PREAMBLE = `
|
|
5
|
+
varying vec3 vWorldPosition;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {string} source
|
|
11
|
+
*/
|
|
12
|
+
export function build_vertex_shader(source) {
|
|
13
|
+
|
|
14
|
+
let result = PREAMBLE + source;
|
|
15
|
+
|
|
16
|
+
result = insert_after(
|
|
17
|
+
result,
|
|
18
|
+
'#include <fog_vertex>',
|
|
19
|
+
`
|
|
20
|
+
{
|
|
21
|
+
vWorldPosition = worldPosition.xyz;
|
|
22
|
+
}
|
|
23
|
+
`
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// console.log(result)
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space_fragment_transform_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wDAFW;IAAC,YAAY,CAAC;IAAC,cAAc,CAAA;CAAC,QAMxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { build_fragment_shader } from "./build_fragment_shader.js";
|
|
2
|
+
import { build_vertex_shader } from "./build_vertex_shader.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {{vertexShader, fragmentShader}} shader
|
|
7
|
+
*/
|
|
8
|
+
export function space_fragment_transform_shader(shader) {
|
|
9
|
+
|
|
10
|
+
shader.vertexShader = build_vertex_shader(shader.vertexShader);
|
|
11
|
+
shader.fragmentShader = build_fragment_shader(shader.fragmentShader);
|
|
12
|
+
}
|