Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchedMesh.InstancedBufferGeometry instead BatchedMesh.BufferGeometry possible ? #29784

Open
chasergit opened this issue Nov 1, 2024 · 2 comments

Comments

@chasergit
Copy link

Description

BatchedMesh.InstancedBufferGeometry instead BatchedMesh.BufferGeometry possible ?

Solution

Change buffergeometry to InstancedBufferGeometry and recompute draw range after frustum culling

Alternatives

Maybe without raycasting. Its need for grass rendering with big amount

Additional context

No response

@donmccurdy
Copy link
Collaborator

@chasergit BatchedMesh supports instancing already, without InstancedBufferGeometry, could you describe why it would be helpful for you to use BatchedMesh in combination with InstancedBufferGeometry? What is it you are looking for that BatchedMesh alone, or InstancedBufferGeometry alone, cannot do?

@chasergit
Copy link
Author

chasergit commented Nov 2, 2024

Excuse my english. I will try to explain. For example i have got 9 meshes created with Three.MeshInstance. Each mesh is 100.000 instances. Total is 900.000 instances.
Case 1: When we will be using BatchedMesh then instances will be converted to 1 buffergeometry and 900.000 instances. And for frustum will be runs 900.000 times every frame and take about 100ms.
Case 2: We converted 9 meshes to indexed buffergeometry and then apply BatchedMesh. Frustum will be runs 9 times every frame, but 900.000 indexed BufferGeometry will slower then 9 instancedBufferGeometry am i right?
Case 3: If its possible. 9 meshes created with instancedBuffergeometry with 100.000 inctances (and custom shader).
We apply BatchedMesh and got 9 geometries in BatchedMesh.InstancedBufferGeometry instead BatchedMesh.BufferGeometry. Frustum will be runs 9 times every frame and take about 1ms but we will be have 900.000 instancedBufferGeometry instead 9 frustum with 900.000 indexedBufferGeometry and less memory of course. If its possible too realise.
I wrote script which merging 9 instancedBufferGeometry to 1 and i have got 1 draw call with 900.000 inctances, but i want to achive 1 draw with BatchedMesh and frustum and maybe without raycasting etc.

Totally BatchedMesh.InstancedBufferGeometry will be have 9 geometryes info into BatchedMesh.geometry.attributes.positions and 900.000 offsets into BatchedMesh.geometry.attributes.offsets. Offsets attributes i use into customShader to offset position to display instance.

Maybe its immposible because of drawrange. I dont know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants