I'm working on a WebGL scene in Three.js that uses custom shaders and am trying to optimize the rendering. To do so, I'm wanting to understand: When and how often is data passed into the GPU?
Does every vertex, uv, etc. that are passed as attributes or uniforms into the shaders need to be passed in each frame, or do these values get passed once and cached until the user sends new data for a given attribute or uniform key?
I'd be grateful for any help others can offer in describing the times when data is passed into the GPU in WebGL.
BufferGeometry is very efficient because it sends attributes (such as UVs, normals, vertices, and indices) only once to the GPU when you declare the Mesh.
If you want to make changes to one of these attributes after it's been initiated, at a later frame, you must set its .needsUpdate
property to true, and then it will be re-sent to the GPU. Otherwise, the initial values will remain in GPU cache undisturbed.
See: https://threejs.org/docs/#api/core/BufferAttribute.needsUpdate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With