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

Add InstancedMesh2 Culling behavior for shadow casting #90

Open
johnnyrainbow opened this issue Jul 8, 2024 · 6 comments
Open

Add InstancedMesh2 Culling behavior for shadow casting #90

johnnyrainbow opened this issue Jul 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@johnnyrainbow
Copy link

Hey, I love the instancedMesh2 implementation, its fantastic.

However i'd very much like the option to add a culling behaviour that works similar to CullingDynamic, however only culls objects that are both offscreen AND not casting a shadow on screen. (example, a tree outside the frustrum, casting a shadow on a plane. The visible within frustrum shadow disappears when the out of frustrum object is culled. I'd like to prevent culling if the shadow is in frustrum.

Would this be possible?

@agargaro
Copy link
Owner

agargaro commented Jul 9, 2024

Hi, thanks :)

With the current version it is not possible.

I don't want to go into too much technical detail, but the current implementation has limitations due to the matrices swaps within InstanceMatrix, so these days, I am writing a new version that allows to swap indexes instead of all data (better performance and it will also be possible to sort).

So I'm going to fix this shadow problem directly in the new version, in the next days.

If you want to follow library updates, this is the new repo link (on npm it will remain the same): https://github.com/three-ez/instanced-mesh

@agargaro agargaro added the bug Something isn't working label Jul 9, 2024
@johnnyrainbow
Copy link
Author

Amazing, I can't wait to try the new version! Can you please post here when its ready, and i'll try it :)

@agargaro
Copy link
Owner

@johnnyrainbow

Everything is ready for the first release 🎉 I just need to write the README.

Would you like to come to the three.ez discord server, so I can let you try it before I publish it?

@agargaro
Copy link
Owner

In this example you can see fixed shadow :)

https://stackblitz.com/edit/three-ez-instancedmesh2-cullingstatic-1kk-forest?file=src%2Fmain.ts

@johnnyrainbow
Copy link
Author

@agargaro Legend!! I'll update and test it out first thing tomorrow 😁

@agargaro
Copy link
Owner

The package on npm is called @three.ez/instanced-mesh-test (it is being tested).
The constructor parameters have changed a bit.
Maybe let me know when you test it so I can help you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants