@woosh/meep-engine 2.75.6 → 2.75.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/meep.cjs +268 -252
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +268 -252
- package/editor/ecs/component/createObjectEditor.js +2 -2
- package/package.json +1 -1
- package/src/core/geom/3d/frustum/read_three_planes_to_array.d.ts +3 -0
- package/src/core/model/object/ImmutableObjectPool.js +14 -5
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +7 -9
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +15 -16
- package/src/engine/ecs/storage/binary/BinaryClassUpgrader.js +10 -59
- package/src/engine/ecs/storage/binary/BinarySerializationRegistry.js +14 -15
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +3 -3
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +60 -62
- package/src/engine/ecs/storage/binary/executeBinaryClassUpgraderChain.js +46 -0
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter.js +2 -2
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +37 -31
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +8 -7
- package/src/engine/graphics/render/RendererPool.js +36 -40
- package/src/engine/graphics/render/buffer/FrameBuffer.js +25 -24
- package/src/engine/graphics/render/buffer/RenderGraph.js +21 -21
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/frame_graph/IRenderContext.js +31 -1
- package/src/engine/graphics/render/frame_graph/RenderGraph.js +5 -5
- package/src/engine/graphics/render/frame_graph/RenderTarget.js +9 -0
- package/src/engine/graphics/render/frame_graph/RenderTextureManager.js +57 -0
- package/src/engine/graphics/render/frame_graph/ResourceEntry.js +7 -5
- package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +48 -33
- package/src/engine/graphics/render/frame_graph/TextureInitialState.js +14 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/CopyPass.js +20 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/LightingPass.js +4 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/run.js +34 -6
- package/src/engine/graphics/render/frame_graph/webgl/WebGLRenderContext.js +34 -0
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +3 -2
- package/src/engine/graphics/sh3/gi/prototypeSHGI.js +92 -0
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMemoryMapping.js → VirtualTextureMemoryMapping.js} +2 -26
- package/src/engine/graphics/texture/virtual/{v2/VirtualTexturePage.js → VirtualTexturePage.js} +10 -10
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureTileLoader.js → VirtualTextureTileLoader.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsage.js → VirtualTextureUsage.js} +1 -1
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageUpdater.js → VirtualTextureUsageUpdater.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/ResidencyDebugView.js +4 -4
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsageDebugView.js +2 -2
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsagePyramidDebugView.js +4 -4
- package/src/engine/graphics/texture/virtual/{v2/prototype.js → prototype.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_finger_print.js +1 -1
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_tile_address.js +2 -2
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/tile_address_to_finger_print.js +1 -1
- package/src/core/geom/3d/frustum/read_frustum_planes_to_array.d.ts +0 -3
- package/src/engine/ecs/storage/json/Blueprint.js +0 -129
- package/src/engine/ecs/storage/json/EntityFactory.js +0 -207
- package/src/engine/ecs/storage/json/JSONDeSerializer.js +0 -148
- package/src/engine/ecs/storage/json/JSONSerializer.js +0 -132
- package/src/engine/ecs/storage/json/README.md +0 -5
- package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +0 -108
- package/src/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +0 -71
- package/src/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +0 -39
- package/src/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +0 -21
- package/src/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +0 -41
- package/src/engine/graphics/render/webgpu/sample/main.js +0 -605
- package/src/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +0 -9
- package/src/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +0 -30
- package/src/engine/graphics/texture/virtual/TileOperation.js +0 -13
- package/src/engine/graphics/texture/virtual/TileTree.js +0 -150
- package/src/engine/graphics/texture/virtual/TileTree.spec.js +0 -58
- package/src/engine/graphics/texture/virtual/TileUsage.js +0 -137
- package/src/engine/graphics/texture/virtual/VirtualTexture.js +0 -238
- package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +0 -39
- package/src/engine/graphics/texture/virtual/page/TilePage.js +0 -148
- package/src/engine/graphics/texture/virtual/page/TilePageSlot.js +0 -36
- package/src/engine/graphics/texture/virtual/tile/Tile.js +0 -44
- package/src/engine/graphics/texture/virtual/tile/Tile.spec.js +0 -11
- package/src/engine/graphics/texture/virtual/tile/TileAddress.js +0 -63
- package/src/engine/graphics/texture/virtual/tile/TileAddress.spec.js +0 -30
- package/src/engine/graphics/texture/virtual/tile/TileLoader.js +0 -178
- package/src/engine/graphics/texture/virtual/tile/TileRequest.js +0 -40
- package/src/engine/graphics/texture/virtual/tile/TileStatus.js +0 -10
- /package/src/engine/graphics/texture/virtual/{v2/NOTES.md → NOTES.md} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMaterial.js → VirtualTextureMaterial.js} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageShader.js → VirtualTextureUsageShader.js} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/VirtualTextureTile.js +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/decompose_finger_print.js +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/finger_print_to_tile_address.js +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 12/10/2016.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function JSONSerializer() {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {EntityComponentDataset} entityDataset
|
|
14
|
-
* @returns {{blueprints, objects: Array}}
|
|
15
|
-
*/
|
|
16
|
-
JSONSerializer.prototype.process = function (entityDataset) {
|
|
17
|
-
console.time('serializing');
|
|
18
|
-
|
|
19
|
-
const blueprintsHash = {};
|
|
20
|
-
const objects = [];
|
|
21
|
-
|
|
22
|
-
let blueprintCount = 0;
|
|
23
|
-
|
|
24
|
-
function computeBlueprintHash(components, componentCount) {
|
|
25
|
-
let hash = "";
|
|
26
|
-
let i = 0;
|
|
27
|
-
for (; i < componentCount; i++) {
|
|
28
|
-
const component = components[i];
|
|
29
|
-
hash += component.constructor.typeName + "#";
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return hash;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function createBlueprint(components, componentCount) {
|
|
36
|
-
const blueprint = {};
|
|
37
|
-
const blueprintComponents = [];
|
|
38
|
-
let i = 0;
|
|
39
|
-
for (; i < componentCount; i++) {
|
|
40
|
-
const component = components[i];
|
|
41
|
-
const ComponentClass = component.constructor;
|
|
42
|
-
const typeName = ComponentClass.typeName;
|
|
43
|
-
if (typeName === undefined) {
|
|
44
|
-
console.error("typeName is not defined for component class " + ComponentClass);
|
|
45
|
-
}
|
|
46
|
-
blueprintComponents.push({
|
|
47
|
-
type: typeName
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
blueprint.components = blueprintComponents;
|
|
51
|
-
blueprint.id = (blueprintCount++);
|
|
52
|
-
|
|
53
|
-
return blueprint;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function obtainBlueprint(components, componentCount) {
|
|
57
|
-
const blueprintId = computeBlueprintHash(components, componentCount);
|
|
58
|
-
|
|
59
|
-
let blueprint = blueprintsHash[blueprintId];
|
|
60
|
-
if (blueprint === undefined) {
|
|
61
|
-
blueprint = createBlueprint(components, componentCount, blueprintId);
|
|
62
|
-
blueprintsHash[blueprintId] = blueprint;
|
|
63
|
-
}
|
|
64
|
-
return blueprint;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function isEmptyObject(o) {
|
|
68
|
-
let result = true;
|
|
69
|
-
if (typeof o === 'object') {
|
|
70
|
-
for (let p in o) {
|
|
71
|
-
if (o.hasOwnProperty(p)) {
|
|
72
|
-
result = false;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
result = false;
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const serializableComponentTypes = entityDataset.getComponentTypeMap().filter(function (componentClass) {
|
|
83
|
-
return componentClass.serializable !== false;
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
entityDataset.traverseEntitiesCompactedFiltered(serializableComponentTypes, function (entity, components, componentCount) {
|
|
89
|
-
const blueprint = obtainBlueprint(components, componentCount);
|
|
90
|
-
|
|
91
|
-
const objectParameters = {};
|
|
92
|
-
const object = {
|
|
93
|
-
blueprint: blueprint.id
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
let i = 0;
|
|
97
|
-
for (; i < componentCount; i++) {
|
|
98
|
-
const component = components[i];
|
|
99
|
-
if (typeof component.toJSON !== 'function') {
|
|
100
|
-
console.error("toJSON is not a function", component);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const json = component.toJSON();
|
|
104
|
-
if (!isEmptyObject(json)) {
|
|
105
|
-
objectParameters[component.constructor.typeName] = json;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (!isEmptyObject(objectParameters)) {
|
|
109
|
-
object.parameters = objectParameters;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
objects.push(object);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
//rebuild blueprints into ID based structure
|
|
117
|
-
const blueprints = {};
|
|
118
|
-
for (let h in blueprintsHash) {
|
|
119
|
-
const blueprint = blueprintsHash[h];
|
|
120
|
-
blueprints[blueprint.id] = blueprint;
|
|
121
|
-
//remove id
|
|
122
|
-
delete blueprint.id;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
console.timeEnd('serializing');
|
|
126
|
-
return {
|
|
127
|
-
blueprints: blueprints,
|
|
128
|
-
objects: objects
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export default JSONSerializer;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { array_copy } from "../../../../../core/collection/array/array_copy.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
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
}
|