@@ -301,11 +301,9 @@ class InstanceNode extends Node {
} else {
- // WebGPU has a 64kb UBO limit, WebGL 2 ensures only 16KB; fallback to attributes if a certain count is exceeded
+ const uniformBufferSize = count * 16 * 4; // count * 16 components * 4 bytes (float)
- const limit = ( builder.renderer.backend.isWebGPUBackend === true ) ? 1000 : 250;
-
- if ( count <= limit ) {
+ if ( uniformBufferSize <= builder.getUniformBufferLimit() ) {
instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
@@ -829,6 +829,17 @@ class NodeBuilder {
}
+ /**
+ * Returns the maximum number of bytes available for uniform buffers.
+ *
+ * @return {number} The maximum number of bytes available for uniform buffers.
+ */
+ getUniformBufferLimit() {
+
+ return 16384;
+ }
/**
* Adds the given node to the internal node chain.
* This is used to check recursive calls in node-graph.
@@ -168,8 +168,9 @@ class RangeNode extends Node {
const nodeType = this.getNodeType( builder );
+ const uniformBufferSize = object.count * 4 * 4; // count * 4 components * 4 bytes (float)
- if ( object.count <= 4096 ) {
output = buffer( array, 'vec4', object.count ).element( instanceIndex ).convert( nodeType );
@@ -1307,6 +1307,18 @@ ${ flowData.code }
+ const gl = this.renderer.backend.gl;
+ return gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );
* Enables hardware clipping.
*
@@ -2143,7 +2143,6 @@ ${ flowData.code }
* Returns the WGSL type of the given node data type.
@@ -2186,6 +2185,17 @@ ${ flowData.code }
+ * Returns the maximum uniform buffer size limit.
+ * @return {number} The maximum uniform buffer size in bytes.
+ return this.renderer.backend.device.limits.maxUniformBufferBindingSize;
* Returns the native shader method name for a given generic name.