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

Problem implementing frustum culling and sorting for InstancedMesh #28102

Open
agargaro opened this issue Apr 9, 2024 · 0 comments
Open

Problem implementing frustum culling and sorting for InstancedMesh #28102

agargaro opened this issue Apr 9, 2024 · 0 comments
Labels

Comments

@agargaro
Copy link
Contributor

agargaro commented Apr 9, 2024

Description

Hello :)

I recently developed a library that add frustum culling to InstancedMesh and now I would like to implement culling and sorting on InstancedMesh on the main repository.

My implementation removes InstanceMatrix, InstanceColor, then adds InstanceIndex, textureMatrices, textureColors.
The work is very similar to that done for the BatchedMesh.

Here's the code: dev...agargaro:three.js:dev

Example (culling + sorting): https://agargaro.github.io/three.js/examples/webgl_instancing_performance.html

Before I open the PR, I would like to ask one thing:

before each render, I update the index array of the instances that are to be drawn, but this cannot be done in onBeforeRender because the attributes are sent to the gpu before this is called. How could this be solved?

Currently to get the example to work I had to manually call the update function in the animate cycle.

Solution

Can we send the instanceIndex attribute to gpu before rendering if perObjectFrustumCulling is true?

Alternatives

The user can manually call myInstancedMesh.update();.

Additional context

No response

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

No branches or pull requests

2 participants