Reputation: 55
In THREE.js what is the best way to share vertex data across two or more different Scenes? My goal is to avoid copying the same data to GPU memory as well as reduce GPU memory footprint. (The scenes are rendered in different WebGL renderers.)
Should I use the same THREE.BufferGeometry objects in the scenes? What is the relation between THREE.BufferGeometry, THREE.Float32BufferAttribute and actual VBOs? What if the mesh has the same vertex positions but different colors - is there any option to reuse just the positions data and provide different colors?
Upvotes: 2
Views: 335
Reputation: 31086
The scenes are rendered in different WebGL renderers.
In this case it's not possible what you are looking for. Each instance of WebGLRenderer
has its own WebGL rendering context. It's not possible share resources like WebGL buffer data across different contexts.
So even if you share an instance of BufferGeometry
, the renderers will create own internal WebGLBuffer objects for this geometry since there is no way around it.
What is the relation between THREE.BufferGeometry, THREE.Float32BufferAttribute and actual VBOs?
THREE.BufferGeometry
represents the entire geometry data for a single 3D object. Buffer attributes are representations of VBOs.
What if the mesh has the same vertex positions but different colors - is there any option to reuse just the positions data and provide different colors?
You can reuse buffer attributes for different geometries. However, this has no effect when using multiple renderers.
three.js R107
Upvotes: 3