@woosh/meep-engine 2.33.60 → 2.33.64
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/core/geom/3d/SurfacePoint3.js +44 -5
- package/core/geom/Vector2.d.ts +2 -0
- package/core/geom/packing/MaxRectangles.js +13 -4
- package/core/math/hash/murmur3_32.js +3 -3
- package/ecs/grid/pick.js +44 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +1 -1
- package/editor/process/ObstacleGridDisplayProcess.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/tools/FoliagePaintTool.js +1 -1
- package/editor/tools/GridPaintTool.js +2 -2
- package/editor/tools/paint/TerrainPaintTool.js +2 -2
- package/editor/tools/paint/TerrainTexturePaintTool.js +1 -1
- package/editor/view/EditorView.js +1 -1
- package/editor/view/GridPickCoordinateView.js +2 -2
- package/engine/asset/loaders/material/computeTextureHash.js +7 -13
- package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
- package/engine/ecs/attachment/AttachmentSystem.js +9 -56
- package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +2 -2
- package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
- package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
- package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
- package/engine/ecs/parent/EntityNode.d.ts +20 -0
- package/engine/ecs/parent/EntityNode.js +284 -0
- package/engine/ecs/parent/FaceEditor.js +137 -0
- package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
- package/engine/ecs/parent/testHuDPerf.js +123 -0
- package/engine/ecs/team/Team.js +82 -0
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/Terrain.js +14 -5
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +112 -0
- package/engine/ecs/terrain/util/obtainTerrain.js +23 -0
- package/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
- package/engine/graphics/GraphicsEngine.js +1 -2
- package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
- package/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/engine/graphics/ecs/water/WaterSystem.js +1 -1
- package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
- package/engine/graphics/geometry/AttributeSpec.d.ts +8 -0
- package/engine/graphics/geometry/VertexDataSpec.d.ts +15 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferAttribute.js +39 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferGeometry.js +50 -0
- package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +10 -7
- package/engine/graphics/micron/format/MicronGeometry.d.ts +4 -0
- package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -4
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -4
- package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
- package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
- package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
- package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
- package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
- package/engine/graphics/render/frame_graph/Resource.js +21 -0
- package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
- package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
- package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
- package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
- package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +108 -0
- package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +71 -0
- package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +39 -0
- package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
- package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +41 -0
- package/engine/graphics/render/webgpu/sample/main.js +604 -0
- package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
- package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +30 -0
- package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
- package/engine/graphics/util/modelHitTest.js +63 -0
- package/engine/grid/systems/GridPosition2TransformSystem.js +1 -1
- package/engine/grid/systems/ViewportGridProjectionSystem.js +1 -1
- package/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/engine/scene/transitionToScene.js +1 -1
- package/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.js +1 -1
- package/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +1 -1
- package/generation/markers/debug/visualizeMarkers.js +1 -1
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/main.js +117 -0
- package/view/minimap/Minimap.js +1 -1
- package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { array_copy } from "../../../../../core/collection/array/copyArray.js";
|
|
2
|
+
|
|
3
|
+
const BIND_GROUP_MATERIAL = 1;
|
|
4
|
+
|
|
5
|
+
export class MeshInstance {
|
|
6
|
+
constructor() {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @type {THREE.BufferGeometry|null}
|
|
11
|
+
*/
|
|
12
|
+
this.geometry = null;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {null}
|
|
17
|
+
*/
|
|
18
|
+
this.material = null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {GPUBuffer|null}
|
|
23
|
+
*/
|
|
24
|
+
this.vertex_buffer = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @type {GPUBuffer|null}
|
|
29
|
+
*/
|
|
30
|
+
this.index_buffer = null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {GPUDevice} device
|
|
36
|
+
*/
|
|
37
|
+
init(device) {
|
|
38
|
+
const mesh = this.geometry;
|
|
39
|
+
|
|
40
|
+
const kVertexStride = 8;
|
|
41
|
+
const attribute_position = mesh.getAttribute('position');
|
|
42
|
+
const vertexBuffer = device.createBuffer({
|
|
43
|
+
// position: vec3, normal: vec3, uv: vec2
|
|
44
|
+
size: attribute_position.array.length * kVertexStride * Float32Array.BYTES_PER_ELEMENT,
|
|
45
|
+
usage: GPUBufferUsage.VERTEX,
|
|
46
|
+
mappedAtCreation: true,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
const mapping = new Float32Array(vertexBuffer.getMappedRange());
|
|
51
|
+
|
|
52
|
+
const attribute_normal = mesh.getAttribute('normal');
|
|
53
|
+
const attribute_uv = mesh.getAttribute('uv');
|
|
54
|
+
|
|
55
|
+
const vertex_count = attribute_position.count;
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < vertex_count; ++i) {
|
|
58
|
+
const address = kVertexStride * i;
|
|
59
|
+
array_copy(attribute_position.array, i * 3, mapping, address, 3);
|
|
60
|
+
array_copy(attribute_normal.array, i * 3, mapping, address + 3, 3);
|
|
61
|
+
array_copy(attribute_uv.array, i * 2, mapping, address + 6, 2);
|
|
62
|
+
}
|
|
63
|
+
vertexBuffer.unmap();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.vertex_buffer = vertexBuffer;
|
|
67
|
+
|
|
68
|
+
const indexCount = mesh.getIndex().array.length;
|
|
69
|
+
const indexBuffer = device.createBuffer({
|
|
70
|
+
size: indexCount * Uint32Array.BYTES_PER_ELEMENT,
|
|
71
|
+
usage: GPUBufferUsage.INDEX,
|
|
72
|
+
mappedAtCreation: true,
|
|
73
|
+
});
|
|
74
|
+
{
|
|
75
|
+
const mapping = new Uint32Array(indexBuffer.getMappedRange());
|
|
76
|
+
|
|
77
|
+
mapping.set(mesh.getIndex().array);
|
|
78
|
+
|
|
79
|
+
indexBuffer.unmap();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.index_buffer = indexBuffer;
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param {GPURenderPassEncoder} pass
|
|
89
|
+
*/
|
|
90
|
+
preparePass(pass) {
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param {GPURenderPassEncoder} pass
|
|
97
|
+
*/
|
|
98
|
+
draw(pass) {
|
|
99
|
+
// set material bindings
|
|
100
|
+
|
|
101
|
+
// pass.setBindGroup(BIND_GROUP_MATERIAL, {});
|
|
102
|
+
|
|
103
|
+
pass.setVertexBuffer(0, this.vertex_buffer);
|
|
104
|
+
pass.setIndexBuffer(this.index_buffer, 'uint32');
|
|
105
|
+
|
|
106
|
+
pass.drawIndexed(this.geometry.getIndex().array.length);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[[group(0), binding(0)]] var gBufferPosition: texture_2d<f32>;
|
|
2
|
+
[[group(0), binding(1)]] var gBufferNormal: texture_2d<f32>;
|
|
3
|
+
[[group(0), binding(2)]] var gBufferAlbedo: texture_2d<f32>;
|
|
4
|
+
|
|
5
|
+
struct LightData {
|
|
6
|
+
position : vec4<f32>;
|
|
7
|
+
color : vec3<f32>;
|
|
8
|
+
radius : f32;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
struct LightsBuffer {
|
|
12
|
+
lights: array<LightData>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
[[group(1), binding(0)]] var<storage, read> lightsBuffer: LightsBuffer;
|
|
16
|
+
|
|
17
|
+
struct Config {
|
|
18
|
+
numLights : u32;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
[[group(1), binding(1)]] var<uniform> config: Config;
|
|
22
|
+
|
|
23
|
+
struct CanvasConstants {
|
|
24
|
+
size: vec2<f32>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
[[group(2), binding(0)]] var<uniform> canvas : CanvasConstants;
|
|
28
|
+
|
|
29
|
+
[[stage(fragment)]]
|
|
30
|
+
fn main([[builtin(position)]] coord : vec4<f32>)
|
|
31
|
+
-> [[location(0)]] vec4<f32> {
|
|
32
|
+
var result = vec3<f32>(0.0, 0.0, 0.0);
|
|
33
|
+
|
|
34
|
+
let position = textureLoad(
|
|
35
|
+
gBufferPosition,
|
|
36
|
+
vec2<i32>(floor(coord.xy)),
|
|
37
|
+
0
|
|
38
|
+
).xyz;
|
|
39
|
+
|
|
40
|
+
if (position.z > 10000.0) {
|
|
41
|
+
discard;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let normal = textureLoad(
|
|
45
|
+
gBufferNormal,
|
|
46
|
+
vec2<i32>(floor(coord.xy)),
|
|
47
|
+
0
|
|
48
|
+
).xyz;
|
|
49
|
+
|
|
50
|
+
let albedo = textureLoad(
|
|
51
|
+
gBufferAlbedo,
|
|
52
|
+
vec2<i32>(floor(coord.xy)),
|
|
53
|
+
0
|
|
54
|
+
).rgb;
|
|
55
|
+
|
|
56
|
+
for (var i : u32 = 0u; i < config.numLights; i = i + 1u) {
|
|
57
|
+
let L = lightsBuffer.lights[i].position.xyz - position;
|
|
58
|
+
let distance = length(L);
|
|
59
|
+
if (distance > lightsBuffer.lights[i].radius) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let lambert = max(dot(normal, normalize(L)), 0.0);
|
|
63
|
+
result = result + vec3<f32>(
|
|
64
|
+
lambert * pow(1.0 - distance / lightsBuffer.lights[i].radius, 2.0) * lightsBuffer.lights[i].color * albedo);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// some manual ambient
|
|
68
|
+
result = result + vec3<f32>(0.2, 0.2, 0.2);
|
|
69
|
+
|
|
70
|
+
return vec4<f32>(result, 1.0);
|
|
71
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[[group(0), binding(0)]] var gBufferPosition: texture_2d<f32>;
|
|
2
|
+
[[group(0), binding(1)]] var gBufferNormal: texture_2d<f32>;
|
|
3
|
+
[[group(0), binding(2)]] var gBufferAlbedo: texture_2d<f32>;
|
|
4
|
+
|
|
5
|
+
struct CanvasConstants {
|
|
6
|
+
size: vec2<f32>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
[[group(1), binding(0)]] var<uniform> canvas : CanvasConstants;
|
|
10
|
+
|
|
11
|
+
[[stage(fragment)]]
|
|
12
|
+
fn main([[builtin(position)]] coord : vec4<f32>)
|
|
13
|
+
-> [[location(0)]] vec4<f32> {
|
|
14
|
+
var result : vec4<f32>;
|
|
15
|
+
let c = coord.xy / canvas.size;
|
|
16
|
+
if (c.x < 0.33333) {
|
|
17
|
+
result = textureLoad(
|
|
18
|
+
gBufferPosition,
|
|
19
|
+
vec2<i32>(floor(coord.xy)),
|
|
20
|
+
0
|
|
21
|
+
);
|
|
22
|
+
} else if (c.x < 0.66667) {
|
|
23
|
+
result = textureLoad(
|
|
24
|
+
gBufferNormal,
|
|
25
|
+
vec2<i32>(floor(coord.xy)),
|
|
26
|
+
0
|
|
27
|
+
);
|
|
28
|
+
result.x = (result.x + 1.0) * 0.5;
|
|
29
|
+
result.y = (result.y + 1.0) * 0.5;
|
|
30
|
+
result.z = (result.z + 1.0) * 0.5;
|
|
31
|
+
} else {
|
|
32
|
+
result = textureLoad(
|
|
33
|
+
gBufferAlbedo,
|
|
34
|
+
vec2<i32>(floor(coord.xy)),
|
|
35
|
+
0
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
struct GBufferOutput {
|
|
2
|
+
[[location(0)]] position : vec4<f32>;
|
|
3
|
+
[[location(1)]] normal : vec4<f32>;
|
|
4
|
+
|
|
5
|
+
// Textures: diffuse color, specular color, smoothness, emissive etc. could go here
|
|
6
|
+
[[location(2)]] albedo : vec4<f32>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
[[stage(fragment)]]
|
|
10
|
+
fn main([[location(0)]] fragPosition: vec3<f32>,
|
|
11
|
+
[[location(1)]] fragNormal: vec3<f32>,
|
|
12
|
+
[[location(2)]] fragUV : vec2<f32>) -> GBufferOutput {
|
|
13
|
+
var output : GBufferOutput;
|
|
14
|
+
output.position = vec4<f32>(fragPosition, 1.0);
|
|
15
|
+
output.normal = vec4<f32>(fragNormal, 1.0);
|
|
16
|
+
// faking some kind of checkerboard texture
|
|
17
|
+
let uv = floor(30.0 * fragUV);
|
|
18
|
+
let c = 0.2 + 0.5 * ((uv.x + uv.y) - 2.0 * floor((uv.x + uv.y) / 2.0));
|
|
19
|
+
output.albedo = vec4<f32>(c, c, c, 1.0);
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
struct LightData {
|
|
2
|
+
position : vec4<f32>;
|
|
3
|
+
color : vec3<f32>;
|
|
4
|
+
radius : f32;
|
|
5
|
+
};
|
|
6
|
+
struct LightsBuffer {
|
|
7
|
+
lights: array<LightData>;
|
|
8
|
+
};
|
|
9
|
+
[[group(0), binding(0)]] var<storage, read_write> lightsBuffer: LightsBuffer;
|
|
10
|
+
|
|
11
|
+
struct Config {
|
|
12
|
+
numLights : u32;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
[[group(0), binding(1)]] var<uniform> config: Config;
|
|
16
|
+
|
|
17
|
+
struct LightExtent {
|
|
18
|
+
min : vec4<f32>;
|
|
19
|
+
max : vec4<f32>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
[[group(0), binding(2)]] var<uniform> lightExtent: LightExtent;
|
|
23
|
+
|
|
24
|
+
[[stage(compute), workgroup_size(64, 1, 1)]]
|
|
25
|
+
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
|
26
|
+
var index = GlobalInvocationID.x;
|
|
27
|
+
if (index >= config.numLights) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let light = &lightsBuffer.lights[index];
|
|
32
|
+
|
|
33
|
+
(*light).position.y = (*light).position.y - 0.001 - 0.003 * (f32(index) - 64.0 * floor(f32(index) / 64.0));
|
|
34
|
+
|
|
35
|
+
if ((*light).position.y < lightExtent.min.y) {
|
|
36
|
+
(*light).position.y = lightExtent.max.y;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// write out
|
|
40
|
+
// lightBuffer.lighs[index] = light;
|
|
41
|
+
}
|