@woosh/meep-engine 2.138.16 → 2.138.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/Editor.d.ts.map +1 -1
- package/editor/SelectionVisualizer.d.ts.map +1 -1
- package/editor/actions/concrete/ComponentAddAction.d.ts.map +1 -1
- package/editor/actions/concrete/EntityCreateAction.d.ts.map +1 -1
- package/editor/actions/concrete/SelectionAddAction.d.ts.map +1 -1
- package/editor/enableEditor.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/ecs/grid/HeightMap2AOMap.d.ts +25 -0
- package/src/engine/ecs/grid/HeightMap2AOMap.d.ts.map +1 -0
- package/src/engine/ecs/grid/HeightMap2AOMap.js +96 -0
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts +15 -7
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.js +44 -99
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/Terrain.js +36 -0
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +3 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts +12 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +21 -0
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderDepthV0.js +2 -14
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderLitV0.js +1 -7
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderNormalsV0.js +1 -6
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/shader/ImpostorShaderViewportDepthV0.js +1 -6
- package/src/engine/graphics/material/TerrainDepthMaterial.d.ts +36 -0
- package/src/engine/graphics/material/TerrainDepthMaterial.d.ts.map +1 -0
- package/src/engine/graphics/material/TerrainDepthMaterial.js +65 -0
- package/src/engine/graphics/shaders/AmbientOcclusionShader.d.ts +69 -12
- package/src/engine/graphics/shaders/AmbientOcclusionShader.d.ts.map +1 -1
- package/src/engine/graphics/shaders/AmbientOcclusionShader.js +386 -128
- package/src/engine/graphics/util/build_max_height_pyramid.d.ts +32 -0
- package/src/engine/graphics/util/build_max_height_pyramid.d.ts.map +1 -0
- package/src/engine/graphics/util/build_max_height_pyramid.js +143 -0
- package/editor/ecs/component/FieldDescriptor.d.ts +0 -27
- package/editor/ecs/component/FieldDescriptor.d.ts.map +0 -1
- package/editor/ecs/component/FieldValueAdapter.d.ts +0 -7
- package/editor/ecs/component/FieldValueAdapter.d.ts.map +0 -1
- package/editor/ecs/component/createFieldEditor.d.ts +0 -9
- package/editor/ecs/component/createFieldEditor.d.ts.map +0 -1
- package/editor/ecs/component/createObjectEditor.d.ts +0 -14
- package/editor/ecs/component/createObjectEditor.d.ts.map +0 -1
- package/editor/ecs/component/findNearestRegisteredType.d.ts +0 -8
- package/editor/ecs/component/findNearestRegisteredType.d.ts.map +0 -1
- package/src/engine/ecs/grid/HeightMap2NormalMap.d.ts +0 -10
- package/src/engine/ecs/grid/HeightMap2NormalMap.d.ts.map +0 -1
- package/src/engine/ecs/grid/HeightMap2NormalMap.js +0 -72
- package/src/engine/ecs/grid/NormalMap2AOMap.d.ts +0 -15
- package/src/engine/ecs/grid/NormalMap2AOMap.d.ts.map +0 -1
- package/src/engine/ecs/grid/NormalMap2AOMap.js +0 -82
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom depth material attached to terrain tile meshes as
|
|
3
|
+
* `mesh.customDepthMaterial`. Used during the shadow-caster pass to inset
|
|
4
|
+
* the recorded depth into the terrain surface.
|
|
5
|
+
*
|
|
6
|
+
* In the vertex shader, each vertex is sunk along its negative geometric
|
|
7
|
+
* normal by `shadowBias` units (object space) before projection into the
|
|
8
|
+
* shadow camera. The resulting shadow map stores the terrain at depths
|
|
9
|
+
* slightly beyond the true surface, so when the terrain shader samples its
|
|
10
|
+
* own shadow at a crease the receiver depth is strictly less than the
|
|
11
|
+
* stored occluder depth and the surface does not self-shadow — sidestepping
|
|
12
|
+
* VSM over-darkening at depth discontinuities.
|
|
13
|
+
*
|
|
14
|
+
* Trade-off: other meshes that *receive* the terrain's cast shadow see the
|
|
15
|
+
* terrain silhouette shrunk inward by `shadowBias`. For terrain that mostly
|
|
16
|
+
* self-shadows (hills, cliffs, valleys) this is invisible. For objects
|
|
17
|
+
* resting on the surface, contact shadows from the terrain become very
|
|
18
|
+
* slightly smaller. This is the explicit trade-off this material exists
|
|
19
|
+
* to make.
|
|
20
|
+
*
|
|
21
|
+
* Bias is in OBJECT space. If the terrain mesh is scaled non-uniformly the
|
|
22
|
+
* caller is responsible for scaling the value accordingly.
|
|
23
|
+
*
|
|
24
|
+
* The bias is exposed on `material.userData.shadowBias` so callers can
|
|
25
|
+
* mutate it without reaching into uniforms directly:
|
|
26
|
+
* material.userData.shadowBias.value = newBias;
|
|
27
|
+
*
|
|
28
|
+
* @param {number} [initialBias=0.1] starting shadowBias, object-space units.
|
|
29
|
+
* Chosen as a conservative default that clears typical VSM crease artifacts
|
|
30
|
+
* at common shadow-map resolutions while keeping caster-side shrinkage on
|
|
31
|
+
* other receivers visually negligible.
|
|
32
|
+
* @returns {MeshDepthMaterial}
|
|
33
|
+
*/
|
|
34
|
+
export function makeTerrainDepthMaterial(initialBias?: number): MeshDepthMaterial;
|
|
35
|
+
import { MeshDepthMaterial } from 'three';
|
|
36
|
+
//# sourceMappingURL=TerrainDepthMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerrainDepthMaterial.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/material/TerrainDepthMaterial.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,uDANW,MAAM,GAIJ,iBAAiB,CA+B7B;kCAhE+D,OAAO"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DoubleSide, MeshDepthMaterial, RGBADepthPacking } from 'three';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom depth material attached to terrain tile meshes as
|
|
5
|
+
* `mesh.customDepthMaterial`. Used during the shadow-caster pass to inset
|
|
6
|
+
* the recorded depth into the terrain surface.
|
|
7
|
+
*
|
|
8
|
+
* In the vertex shader, each vertex is sunk along its negative geometric
|
|
9
|
+
* normal by `shadowBias` units (object space) before projection into the
|
|
10
|
+
* shadow camera. The resulting shadow map stores the terrain at depths
|
|
11
|
+
* slightly beyond the true surface, so when the terrain shader samples its
|
|
12
|
+
* own shadow at a crease the receiver depth is strictly less than the
|
|
13
|
+
* stored occluder depth and the surface does not self-shadow — sidestepping
|
|
14
|
+
* VSM over-darkening at depth discontinuities.
|
|
15
|
+
*
|
|
16
|
+
* Trade-off: other meshes that *receive* the terrain's cast shadow see the
|
|
17
|
+
* terrain silhouette shrunk inward by `shadowBias`. For terrain that mostly
|
|
18
|
+
* self-shadows (hills, cliffs, valleys) this is invisible. For objects
|
|
19
|
+
* resting on the surface, contact shadows from the terrain become very
|
|
20
|
+
* slightly smaller. This is the explicit trade-off this material exists
|
|
21
|
+
* to make.
|
|
22
|
+
*
|
|
23
|
+
* Bias is in OBJECT space. If the terrain mesh is scaled non-uniformly the
|
|
24
|
+
* caller is responsible for scaling the value accordingly.
|
|
25
|
+
*
|
|
26
|
+
* The bias is exposed on `material.userData.shadowBias` so callers can
|
|
27
|
+
* mutate it without reaching into uniforms directly:
|
|
28
|
+
* material.userData.shadowBias.value = newBias;
|
|
29
|
+
*
|
|
30
|
+
* @param {number} [initialBias=0.1] starting shadowBias, object-space units.
|
|
31
|
+
* Chosen as a conservative default that clears typical VSM crease artifacts
|
|
32
|
+
* at common shadow-map resolutions while keeping caster-side shrinkage on
|
|
33
|
+
* other receivers visually negligible.
|
|
34
|
+
* @returns {MeshDepthMaterial}
|
|
35
|
+
*/
|
|
36
|
+
export function makeTerrainDepthMaterial(initialBias = 0.1) {
|
|
37
|
+
const m = new MeshDepthMaterial({
|
|
38
|
+
depthPacking: RGBADepthPacking,
|
|
39
|
+
side: DoubleSide
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// single uniform reference shared between shader and userData so external
|
|
43
|
+
// writes via userData.shadowBias.value reach the shader without rebinding
|
|
44
|
+
const shadowBias = { value: initialBias };
|
|
45
|
+
|
|
46
|
+
m.userData.shadowBias = shadowBias;
|
|
47
|
+
|
|
48
|
+
m.onBeforeCompile = (shader) => {
|
|
49
|
+
shader.uniforms.shadowBias = shadowBias;
|
|
50
|
+
|
|
51
|
+
shader.vertexShader = shader.vertexShader
|
|
52
|
+
.replace(
|
|
53
|
+
'#include <common>',
|
|
54
|
+
`#include <common>
|
|
55
|
+
uniform float shadowBias;`
|
|
56
|
+
)
|
|
57
|
+
.replace(
|
|
58
|
+
'#include <begin_vertex>',
|
|
59
|
+
`#include <begin_vertex>
|
|
60
|
+
transformed -= normal * shadowBias;`
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return m;
|
|
65
|
+
}
|
|
@@ -1,27 +1,84 @@
|
|
|
1
1
|
export default AmbientOcclusionShader;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Lightmap baker for heightfield terrain.
|
|
4
|
+
*
|
|
5
|
+
* Per output texel, traces `NUM_RAYS` cosine-weighted rays into the
|
|
6
|
+
* hemisphere around the surface normal and counts how many are occluded by
|
|
7
|
+
* the heightfield. The output channel is visibility ∈ [0, 1]:
|
|
8
|
+
* 1 = fully lit (no occlusion)
|
|
9
|
+
* 0 = fully occluded
|
|
10
|
+
*
|
|
11
|
+
* Architecture
|
|
12
|
+
* ------------
|
|
13
|
+
*
|
|
14
|
+
* 1. Pre-pass (orchestrator side): a max-reduction mipmap pyramid is built
|
|
15
|
+
* from the heightmap — see `build_max_height_pyramid`. Each mip stores
|
|
16
|
+
* per-cell upper bounds on height. The whole pyramid is one DataTexture
|
|
17
|
+
* with `tex.mipmaps[]`, sampled by `textureLod`.
|
|
18
|
+
*
|
|
19
|
+
* 2. Sampling: directions are drawn from a cosine-weighted hemisphere using
|
|
20
|
+
* Shirley's concentric disk mapping. Cosine-weighting matches the
|
|
21
|
+
* Lambertian diffuse assumption — each sample's contribution to the AO
|
|
22
|
+
* integral has unit weight, and the estimator collapses to a simple
|
|
23
|
+
* hits/total ratio.
|
|
24
|
+
*
|
|
25
|
+
* 3. Random seeding: a PCG hash (pcg3d on the fragment coordinate) seeds an
|
|
26
|
+
* independent stream per output texel. Subsequent rays draw from `pcg`
|
|
27
|
+
* on the running state. White noise — no Halton/blue-noise sequences —
|
|
28
|
+
* keeps the implementation simple and the noise spectrum unbiased; a
|
|
29
|
+
* bilateral denoise pass downstream cleans up the speckle.
|
|
30
|
+
*
|
|
31
|
+
* 4. Tracing: Hi-Z traversal in world space. The ray's XZ projection walks
|
|
32
|
+
* texture-space cells; per cell, the max-height at the current mip is
|
|
33
|
+
* compared against the ray's min height across the cell. Above max:
|
|
34
|
+
* advance to the next cell and try to coarsen the mip. Below max:
|
|
35
|
+
* refine the mip; at mip 0, record a hit. Bounded by MAX_HIZ_ITER per
|
|
36
|
+
* ray as a safety net for pathological convergence.
|
|
37
|
+
*
|
|
38
|
+
* World space
|
|
39
|
+
* -----------
|
|
40
|
+
*
|
|
41
|
+
* Convention: X and Z are horizontal (UV-aligned), Y is up. The heightmap's
|
|
42
|
+
* UV maps linearly to world (x, z) ∈ [0, worldSize.x] × [0, worldSize.y],
|
|
43
|
+
* and the heightmap value at any UV is the world Y coordinate of the
|
|
44
|
+
* surface. Surface normals are recomputed in-shader by central differences
|
|
45
|
+
* on the heightmap, removing any dependency on an external normal map.
|
|
46
|
+
*
|
|
47
|
+
* Inputs (uniforms — plumbing, not user-facing)
|
|
48
|
+
* ---------------------------------------------
|
|
49
|
+
*
|
|
50
|
+
* heightMap R32F texture with a max-reduction mipmap chain
|
|
51
|
+
* worldSize XZ extent of the terrain in world units
|
|
52
|
+
* heightMapSize Resolution of heightMap mip 0 in texels
|
|
53
|
+
* maxMipLevel Index of the coarsest mip in heightMap
|
|
54
|
+
*
|
|
55
|
+
* The single user-facing parameter is `NUM_RAYS`, configured by the factory
|
|
56
|
+
* argument.
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} [opts]
|
|
59
|
+
* @param {number} [opts.numRays=64] number of rays per output texel
|
|
60
|
+
*/
|
|
61
|
+
declare function AmbientOcclusionShader({ numRays }?: {
|
|
62
|
+
numRays?: number;
|
|
63
|
+
}): {
|
|
3
64
|
uniforms: {
|
|
4
|
-
normalMap: {
|
|
5
|
-
type: string;
|
|
6
|
-
value: any;
|
|
7
|
-
};
|
|
8
65
|
heightMap: {
|
|
9
|
-
type: string;
|
|
10
66
|
value: any;
|
|
11
67
|
};
|
|
12
|
-
|
|
13
|
-
|
|
68
|
+
worldSize: {
|
|
69
|
+
value: Vector2;
|
|
70
|
+
};
|
|
71
|
+
heightMapSize: {
|
|
14
72
|
value: Vector2;
|
|
15
73
|
};
|
|
16
|
-
|
|
17
|
-
type: string;
|
|
74
|
+
maxMipLevel: {
|
|
18
75
|
value: number;
|
|
19
76
|
};
|
|
20
77
|
};
|
|
21
78
|
defines: {
|
|
22
|
-
|
|
23
|
-
NUM_RINGS: number;
|
|
79
|
+
NUM_RAYS: number;
|
|
24
80
|
};
|
|
81
|
+
glslVersion: import("three").GLSLVersion;
|
|
25
82
|
vertexShader: string;
|
|
26
83
|
fragmentShader: string;
|
|
27
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmbientOcclusionShader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/shaders/AmbientOcclusionShader.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"AmbientOcclusionShader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/shaders/AmbientOcclusionShader.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH;IAFyB,OAAO,GAArB,MAAM;;;;;;;;;;;;;;;;;;;;;;EA4ThB;wBA/X8B,OAAO"}
|