diff --git a/examples/files.json b/examples/files.json index 1a4f9a01325b75..1b49918b43bc51 100644 --- a/examples/files.json +++ b/examples/files.json @@ -324,6 +324,7 @@ "webgpu_clearcoat", "webgpu_clipping", "webgpu_compute_audio", + "webgpu_compute_geometry", "webgpu_compute_particles", "webgpu_compute_particles_rain", "webgpu_compute_particles_snow", diff --git a/examples/jsm/nodes/accessors/StorageBufferNode.js b/examples/jsm/nodes/accessors/StorageBufferNode.js index 37ed817117be38..96ab3488d6a951 100644 --- a/examples/jsm/nodes/accessors/StorageBufferNode.js +++ b/examples/jsm/nodes/accessors/StorageBufferNode.js @@ -18,6 +18,15 @@ class StorageBufferNode extends BufferNode { this._attribute = null; this._varying = null; + if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) { + + // TOOD: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer + + if ( value.isInstancedBufferAttribute ) value.isStorageInstancedBufferAttribute = true; + else value.isStorageBufferAttribute = true; + + } + } getInputType( /*builder*/ ) { diff --git a/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js b/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js index a9ca11a4b6378c..8203fcdbc3453a 100644 --- a/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +++ b/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js @@ -64,7 +64,6 @@ class WebGPUAttributeUtils { if ( ( bufferAttribute.isStorageBufferAttribute || bufferAttribute.isStorageInstancedBufferAttribute ) && bufferAttribute.itemSize === 3 ) { - bufferAttribute.itemSize = 4; array = new array.constructor( bufferAttribute.count * 4 ); for ( let i = 0; i < bufferAttribute.count; i ++ ) { @@ -73,6 +72,10 @@ class WebGPUAttributeUtils { } + // Update BufferAttribute + bufferAttribute.itemSize = 4; + bufferAttribute.array = array; + } const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment, see #20441 diff --git a/examples/screenshots/webgpu_compute_geometry.jpg b/examples/screenshots/webgpu_compute_geometry.jpg new file mode 100644 index 00000000000000..1d5f8309b51c65 Binary files /dev/null and b/examples/screenshots/webgpu_compute_geometry.jpg differ diff --git a/examples/webgpu_compute_geometry.html b/examples/webgpu_compute_geometry.html new file mode 100644 index 00000000000000..45267483aebdb7 --- /dev/null +++ b/examples/webgpu_compute_geometry.html @@ -0,0 +1,147 @@ + + +
+