-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Introduce intersectsFrustum so that objects can override it #25525
Conversation
cc4a933
to
e828fd0
Compare
9b0a0ff
to
59af27e
Compare
I have added a class The function assumes no scaling, as determining scale would require something like computing matrix determinant, which I do not feel like doing. If you use scaling, you'd better compute the bounding sphere on your own. Note: I did not test the function, as I am using my own computation of the bounding sphere, I find it easier to compute it from the same source data I use to compute the instancing matrices, but I think having it could be useful for users which want to have something ready to use. |
59af27e
to
f8910ef
Compare
f8910ef
to
b74058f
Compare
@Mugen87 @WestLangley Do you have any feedback on this? Merging the second commit with I have a scene with a lot of instancing and CSM used for shadows. As shadow frustums are much smaller than the whole scene, having an option to cull instanced objects is very important and reduces rendering of instanced objects to about 1/10, causing very significant performance gain. |
The first commit seams reasonable to me. Perhaps that is the API we should have had in the first place. // This PR raises some current nomenclature issues...
But then there is |
TBH, I favor a different approach which has already been implemented in #21507. The idea is to introduce bounding volumes for certain types of To be clear, the real issue are incorrect bounding volumes. Configurable/custom frustum intersection tests do not really address it. |
That one would work for me well. The benefit of this one is its simplicity - that PR is open for two years and not merged yet. |
#25591 is merged so this PR can be closed now. |
Description
Introduce a method
intersectsFrustum
intoObject3D
so that objects can customize it. The intended use is to implement frustum culling forInstancedMesh
, but it could be used for other purposes as well, e.g. some objects might prefer culling against box instead of sphere, or implement some other culling implementations based on its internal knowledge.The PR is inspired by https://discourse.threejs.org/t/how-to-do-frustum-culling-with-instancedmesh/22633/6, but attempts to be more flexible.
If you are willing to compute the bounding sphere on your own, culling is easy:
I will provide a function to compute the
boundingSphere
forInstancedMesh
later.