Asked 1 year ago by MeteorScientist435
Best Practices for Handling mat4 Attributes in WebGPURenderer and Resolving Geometry Update Errors
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 1 year ago by MeteorScientist435
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
I previously used WebGLRenderer to create a mat4 attribute and pass it to the shader, but after switching to WebGPURenderer I encountered issues: WebGPU does not directly support mat4 attributes and has a limit of 8 vertex buffers. Although simulating a mat4 with four vec4 attributes is possible, it feels wasteful, and updating the mat4 in WebGPURenderer has become problematic.
What is the best practice for passing a mat4 attribute using WebGPURenderer? Should I emulate it with four vec4 attributes or is there another approach?
I attempted to mimic the handling of an instanceMatrix in instanceNode as follows:
JAVASCRIPTconst buffer = new InstancedInterleavedBuffer( instanceAttribute.array, 16, 1 ); this.buffer = buffer; const bufferFn = instancedBufferAttribute; const buffers = [ // F.Signature -> bufferAttribute( array, type, stride, offset ) bufferFn( buffer, 'vec4', 16, 0 ), bufferFn( buffer, 'vec4', 16, 4 ), bufferFn( buffer, 'vec4', 16, 8 ), bufferFn( buffer, 'vec4', 16, 12 ) ]; matrix = mat4( ...buffers ).toVar(); currentMatrix.assign(matrix);
However, when my geometry changes (disposing of the old geometry and creating a new one), this code results in an error. Why does this happen and how can it be fixed?
Comments 0
•Answers 0
•Views 34
No comments yet.