# Can Storage Instanced Buffer Attribute be used with render()?

**URL:** <https://discourse.threejs.org/t/can-storage-instanced-buffer-attribute-be-used-with-render/62584>\
**Category:** Questions\
**Created:** [March 11, 2024, 2:30am UTC](https://discourse.threejs.org/t/can-storage-instanced-buffer-attribute-be-used-with-render/62584 "2024-03-11T02:30:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ionox0](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ionox0/32/45023_2.png) [@ionox0](https://discourse.threejs.org/u/ionox0)\
**Post date:** [March 11, 2024, 2:30am UTC](https://discourse.threejs.org/t/can-storage-instanced-buffer-attribute-be-used-with-render/62584/1 "2024-03-11T02:30:36Z")

</div>

I am trying to make use of StorageInstancedBufferAttribute to store data with the nodes system, but I receive an error with a simple example:

```javascript
const normalBuffer = new StorageInstancedBufferAttribute(data.normals.length, 3);
const normalBufferNode = storage(normalBuffer, 'vec3', data.normals.length);
this._geometry.setAttribute( 'normal', normalBuffer );

this._params._material = new MeshBasicNodeMaterial();
this._params._material.side = THREE.BackSide;
this._params._material.colorNode = PS(normalBufferNode);
  
function PS (normalBufferNode) {
  const normal = normalBufferNode.element( instanceIndex );
  const update = tslFn( ( ) => {
      normal.x = float(0.3);
      const d = vec4().toVar();
      return vec4(0.5, 0.5, 0.5, 0.5);
  });
  
  update.setLayout( {
      name: 'update',
      type: 'vec4',
      inputs: []
  });
  
  return update();
}

```

Tint Errors:

```javascript
Binding usage (BufferUsage::(CopySrc|CopyDst|Vertex)) of [Buffer] doesn't match expected usage (BufferUsage::Storage).
 - While validating entries[1] as a Buffer.
Expected entry layout: { binding: 1, visibility: ShaderStage::Fragment, buffer: { type: BufferBindingType::Storage, hasDynamicOffset: 0, minBindingSize: 0 } }
 - While validating [BindGroupDescriptor] against [BindGroupLayout]
 - While calling [Device].CreateBindGroup([BindGroupDescriptor]).

```

```javascript
Tint WGSL reader failure: :34:32 error: unresolved value 'nodeVarying0'
  NodeBuffer_3737.nodeUniform0[nodeVarying0].x = 0.3;
                                ^^^^^^^^^^^^

 - While validating [ShaderModuleDescriptor "fragment"]
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor "fragment"]).

```

Note that in the examples I can only find usages of this data structure with `WebGPURenderer.compute()`

Is it possible to do this with `WebGPURenderer.render()`?

Or does this only for for `.compute()`?

---

<div class="post-metadata">

**Author:** ![sunag](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sunag/32/29472_2.png) [@sunag](https://discourse.threejs.org/u/sunag)\
**Post date:** [March 20, 2024, 1:46am UTC](https://discourse.threejs.org/t/can-storage-instanced-buffer-attribute-be-used-with-render/62584/2 "2024-03-20T01:46:05Z")

</div>

Have you tried removing the `update.setLayout( ... )` code?

---

<div class="post-metadata">

**Author:** ![ionox0](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/ionox0/32/45023_2.png) [@ionox0](https://discourse.threejs.org/u/ionox0)\
**Post date:** [March 29, 2024, 7:57pm UTC](https://discourse.threejs.org/t/can-storage-instanced-buffer-attribute-be-used-with-render/62584/3 "2024-03-29T19:57:06Z")

</div>

Thank you, yes that fixes the errors. I thought the `setLayout` was required for all tlsl functions but now I see that it is not.
