First commit

This commit is contained in:
2025-12-25 10:36:24 +01:00
commit 17ce5ef2fa
7 changed files with 2961 additions and 0 deletions

876
nodes.json Normal file
View File

@@ -0,0 +1,876 @@
{
"shaders": [
{
"name": "gravityShader",
"path": "../shaders/gravity.wgsl",
"start": 1750,
"end": 1826,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "positions",
"varType": "array<vec3<f32>>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "velocities",
"varType": "array<vec3<f32>>"
},
{
"group": 0,
"binding": 2,
"type": "storage",
"varName": "distances",
"varType": "array<f32>"
},
{
"group": 0,
"binding": 3,
"type": "storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "deltaTimeSeconds",
"varType": "f32"
},
{
"group": 0,
"binding": 5,
"type": "uniform",
"varName": "cameraPosition",
"varType": "vec3<f32>"
},
{
"group": 0,
"binding": 6,
"type": "uniform",
"varName": "updateDistancesAndIndices",
"varType": "u32"
},
{
"group": 0,
"binding": 7,
"type": "uniform",
"varName": "cellCount",
"varType": "u32"
},
{
"group": 0,
"binding": 8,
"type": "uniform",
"varName": "gravity",
"varType": "f32"
}
]
},
{
"name": "copyIndicesShader",
"path": "../shaders/copyBuffer.wgsl",
"start": 2067,
"end": 2149,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "read-only-storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "sortedIndices",
"varType": "array<u32>"
}
]
},
{
"name": "renderShader",
"path": "../shaders/points.wgsl",
"start": 2237,
"end": 2311,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "read-only-storage",
"varName": "positions",
"varType": "array<Point>"
},
{
"group": 0,
"binding": 1,
"type": "read-only-storage",
"varName": "sortedIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "uniform",
"varName": "viewProjectionMatrix",
"varType": "mat4x4<f32>"
},
{
"group": 0,
"binding": 3,
"type": "uniform",
"varName": "cameraRight",
"varType": "BillboardAxis"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "cameraUp",
"varType": "BillboardAxis"
}
]
},
{
"name": "findGridHashShader",
"path": "../shaders/findGridHash.wgsl",
"start": 2785,
"end": 2869,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "positions",
"varType": "array<vec3<f32>>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "gridHashes",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 3,
"type": "uniform",
"varName": "cellCount",
"varType": "u32"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "gridMin",
"varType": "vec3<f32>"
},
{
"group": 0,
"binding": 5,
"type": "uniform",
"varName": "gridMax",
"varType": "vec3<f32>"
}
]
},
{
"name": "localSortShader",
"path": "../shaders/localSort.wgsl",
"start": 3401,
"end": 3478,
"ifStatements": [
{
"test": "this.useLocalSort",
"consequent": "{\n\n\t\t\tthis.localSortShader = new Shader( this.device, \"../shaders/localSort.wgsl\");\n\n\t\t\tawait this.localSortShader.addStage(\"main\", GPUShaderStage.COMPUTE );\n\n\t\t\tthis.localSortShader.setBuffer( \"gridHashes\", this.findGridHashShader.getBuffer(\"gridHashes\" ) );\n\n\t\t\tthis.localSortShader.setBuffer( \"indices\", this.findGridHashShader.getBuffer(\"indices\" ) );\n\n\t\t\tthis.localSortShader.setVariable( \"totalCount\", this.particleCount );\n\n\t\t}",
"alternate": null,
"start": 3371,
"end": 3829
}
],
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "gridHashes",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "uniform",
"varName": "totalCount",
"varType": "u32"
}
]
},
{
"name": "bitonicSortGridHashShader",
"path": "../shaders/bitonicSortUIntMultiPass.wgsl",
"start": 3833,
"end": 3935,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "gridHashes",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "threadPassIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "storage",
"varName": "kArray",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 3,
"type": "storage",
"varName": "jArray",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 4,
"type": "storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 5,
"type": "uniform",
"varName": "totalCount",
"varType": "u32"
}
]
},
{
"name": "findGridHashRangeShader",
"path": "../shaders/findGridHashRanges.wgsl",
"start": 4714,
"end": 4809,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "read-only-storage",
"varName": "gridHashes",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 1,
"type": "read-only-storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "storage",
"varName": "startIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 3,
"type": "storage",
"varName": "endIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "totalCount",
"varType": "u32"
}
]
},
{
"name": "collisionDetectionShader",
"path": "../shaders/collisionDetection.wgsl",
"start": 4911,
"end": 5006,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "positions",
"varType": "array<vec3<f32>>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "velocities",
"varType": "array<vec3<f32>>"
},
{
"group": 0,
"binding": 2,
"type": "storage",
"varName": "gridHashes",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 3,
"type": "storage",
"varName": "hashSortedIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "cellCount",
"varType": "u32"
},
{
"group": 0,
"binding": 5,
"type": "uniform",
"varName": "gridMin",
"varType": "vec3<f32>"
},
{
"group": 0,
"binding": 6,
"type": "read-only-storage",
"varName": "startIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 7,
"type": "read-only-storage",
"varName": "endIndices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 8,
"type": "uniform",
"varName": "collisionRadius",
"varType": "f32"
},
{
"group": 0,
"binding": 9,
"type": "uniform",
"varName": "deltaTimeSeconds",
"varType": "f32"
},
{
"group": 0,
"binding": 10,
"type": "uniform",
"varName": "gridMax",
"varType": "vec3<f32>"
}
]
},
{
"name": "bitonicSortShader",
"path": "../shaders/bitonicSort.wgsl",
"start": 6436,
"end": 6516,
"bindings": [
{
"group": 0,
"binding": 0,
"type": "storage",
"varName": "compare",
"varType": "array<f32>"
},
{
"group": 0,
"binding": 1,
"type": "storage",
"varName": "indices",
"varType": "array<u32>"
},
{
"group": 0,
"binding": 2,
"type": "uniform",
"varName": "k",
"varType": "u32"
},
{
"group": 0,
"binding": 3,
"type": "uniform",
"varName": "j",
"varType": "u32"
},
{
"group": 0,
"binding": 4,
"type": "uniform",
"varName": "totalCount",
"varType": "u32"
}
]
}
],
"edges": [
{
"from": "gravityShader",
"to": "findGridHashShader",
"buffer": "positions",
"fromBuffer": "positions"
},
{
"from": "findGridHashShader",
"to": "localSortShader",
"buffer": "gridHashes",
"fromBuffer": "gridHashes"
},
{
"from": "findGridHashShader",
"to": "localSortShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "localSortShader",
"to": "bitonicSortGridHashShader",
"buffer": "gridHashes",
"fromBuffer": "gridHashes"
},
{
"from": "localSortShader",
"to": "bitonicSortGridHashShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "findGridHashShader",
"to": "bitonicSortGridHashShader",
"buffer": "gridHashes",
"fromBuffer": "gridHashes"
},
{
"from": "findGridHashShader",
"to": "bitonicSortGridHashShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "gravityShader",
"to": "collisionDetectionShader",
"buffer": "positions",
"fromBuffer": "positions"
},
{
"from": "gravityShader",
"to": "collisionDetectionShader",
"buffer": "velocities",
"fromBuffer": "velocities"
},
{
"from": "gravityShader",
"to": "collisionDetectionShader",
"buffer": "positions",
"fromBuffer": "positions"
},
{
"from": "gravityShader",
"to": "collisionDetectionShader",
"buffer": "velocities",
"fromBuffer": "velocities"
},
{
"from": "findGridHashShader",
"to": "collisionDetectionShader",
"buffer": "gridHashes",
"fromBuffer": "gridHashes"
},
{
"from": "localSortShader",
"to": "collisionDetectionShader",
"buffer": "hashSortedIndices",
"fromBuffer": "indices"
},
{
"from": "bitonicSortGridHashShader",
"to": "collisionDetectionShader",
"buffer": "hashSortedIndices",
"fromBuffer": "indices"
},
{
"from": "findGridHashRangeShader",
"to": "collisionDetectionShader",
"buffer": "startIndices",
"fromBuffer": "startIndices"
},
{
"from": "findGridHashRangeShader",
"to": "collisionDetectionShader",
"buffer": "endIndices",
"fromBuffer": "endIndices"
},
{
"from": "gravityShader",
"to": "bitonicSortShader",
"buffer": "compare",
"fromBuffer": "distances"
},
{
"from": "gravityShader",
"to": "bitonicSortShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "bitonicSortGridHashShader",
"to": "findGridHashRangeShader",
"buffer": "gridHashes",
"fromBuffer": "gridHashes"
},
{
"from": "bitonicSortGridHashShader",
"to": "findGridHashRangeShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "bitonicSortShader",
"to": "copyIndicesShader",
"buffer": "indices",
"fromBuffer": "indices"
},
{
"from": "gravityShader",
"to": "renderShader",
"buffer": "positions",
"fromBuffer": "positions"
},
{
"from": "copyIndicesShader",
"to": "renderShader",
"buffer": "sortedIndices",
"fromBuffer": "sortedIndices"
}
],
"definitions": [
{
"name": "canvas",
"init": null,
"start": 356,
"end": 363
},
{
"name": "device",
"init": null,
"start": 366,
"end": 373
},
{
"name": "camera",
"init": null,
"start": 376,
"end": 383
},
{
"name": "useLocalSort",
"init": "true",
"start": 386,
"end": 407
},
{
"name": "eventManager",
"init": "new EventManager()",
"start": 410,
"end": 445
},
{
"name": "frameCount",
"init": "0",
"start": 448,
"end": 466
},
{
"name": "context",
"init": "offscreenCanvas.getContext(\"webgpu\")",
"start": 692,
"end": 741
},
{
"name": "adapter",
"init": "await self.navigator.gpu.requestAdapter()",
"start": 881,
"end": 935
},
{
"name": "boundsMinimum",
"init": "new Vector3(-2, -2, -2)",
"start": 1108,
"end": 1151
},
{
"name": "boundsMaximum",
"init": "new Vector3(2, 2, 2)",
"start": 1160,
"end": 1199
},
{
"name": "cellsPerDimension",
"init": "12",
"start": 1208,
"end": 1231
},
{
"name": "gravity",
"init": "-2.3",
"start": 1240,
"end": 1257
},
{
"name": "jArray",
"init": "new Array()",
"start": 1377,
"end": 1401
},
{
"name": "kArray",
"init": "new Array()",
"start": 1410,
"end": 1434
},
{
"name": "startK",
"init": "this.workgroupSize * 2",
"start": 1473,
"end": 1504
},
{
"name": "startK",
"init": "2",
"start": 1563,
"end": 1573
},
{
"name": "k",
"init": "startK",
"start": 1595,
"end": 1605
},
{
"name": "j",
"init": "k >> 1",
"start": 1657,
"end": 1667
},
{
"name": "quadOffsets",
"init": "new Float32Array([\n// Triangle 1\n-1, -1,\n// bottom-left\n1, -1,\n// bottom-right\n1, 1,\n// top-right\n\n// Triangle 2\n-1, -1,\n// bottom-left\n1, 1,\n// top-right\n-1, 1 // top-left\n])",
"start": 2486,
"end": 2715
},
{
"name": "positions",
"init": "new Float32Array(this.particleCount * 3)",
"start": 7719,
"end": 7775
},
{
"name": "velocities",
"init": "new Float32Array(this.particleCount * 3)",
"start": 7786,
"end": 7843
},
{
"name": "i",
"init": "0",
"start": 7858,
"end": 7863
},
{
"name": "now",
"init": "performance.now()",
"start": 8329,
"end": 8355
},
{
"name": "commandEncoder",
"init": "this.device.createCommandEncoder()",
"start": 8488,
"end": 8539
},
{
"name": "passEncoder",
"init": "commandEncoder.beginComputePass()",
"start": 8606,
"end": 8653
},
{
"init": null,
"start": 8733,
"end": 8753
},
{
"name": "threadPassIndices",
"init": "new Uint32Array(this.particleCount)",
"start": 8986,
"end": 9044
},
{
"name": "i",
"init": "0",
"start": 9059,
"end": 9064
},
{
"name": "passEncoder",
"init": "commandEncoder.beginComputePass()",
"start": 9233,
"end": 9280
},
{
"init": null,
"start": 9370,
"end": 9390
},
{
"name": "startK",
"init": "this.workgroupSize * 2",
"start": 9546,
"end": 9577
},
{
"name": "startK",
"init": "2",
"start": 9601,
"end": 9611
},
{
"name": "k",
"init": "startK",
"start": 9632,
"end": 9642
},
{
"name": "j",
"init": "k >> 1",
"start": 9695,
"end": 9705
},
{
"name": "commandBuffer",
"init": "commandEncoder.finish()",
"start": 9839,
"end": 9878
},
{
"name": "k",
"init": "2",
"start": 10153,
"end": 10158
},
{
"name": "j",
"init": "k >> 1",
"start": 10209,
"end": 10219
},
{
"name": "commandBuffers",
"init": "new Array()",
"start": 10250,
"end": 10278
},
{
"name": "commandEncoder",
"init": "this.device.createCommandEncoder()",
"start": 10434,
"end": 10485
},
{
"name": "passEncoder",
"init": "commandEncoder.beginComputePass()",
"start": 10498,
"end": 10545
},
{
"init": null,
"start": 10629,
"end": 10649
},
{
"name": "viewMatrixData",
"init": "this.camera.getViewMatrix()",
"start": 11861,
"end": 11908
},
{
"name": "projectionMatrixData",
"init": "Matrix4.createProjectionMatrix(this.camera, this.canvas)",
"start": 11919,
"end": 12002
},
{
"name": "viewProjectionMatrix",
"init": "Matrix4.multiply(projectionMatrixData, viewMatrixData)",
"start": 12012,
"end": 12093
},
{
"name": "cameraWorldMatrix",
"init": "Matrix4.invert(viewMatrixData)",
"start": 12104,
"end": 12158
},
{
"name": "cameraRight",
"init": "Matrix4.getColumn(cameraWorldMatrix, 0)",
"start": 12171,
"end": 12229
},
{
"name": "cameraUp",
"init": "Matrix4.getColumn(cameraWorldMatrix, 1)",
"start": 12240,
"end": 12296
},
{
"name": "cameraPosition",
"init": "Matrix4.getColumn(cameraWorldMatrix, 3)",
"start": 12307,
"end": 12367
}
]
}