Simple way to deactivate prims based on camera intersection #3258
Unanswered
jcoelho88
asked this question in
Show and tell
Replies: 1 comment
-
Thank you for sharing that with us! :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to share something we are looking to use in a possible workflow.
We have seen a need on our end to be able to quickly clean up prims that never cross the camera in a shot.
We've done this before with just pure Maya data, you can see the inspiration for this here: https://gizmosandgames.com/2017/05/21/frustum-culling-in-maya/
To do the same on a USD stage we made a function that will do essentially the same thing.
The function takes a stage and the prim path to a camera you want to check the intersections with.
It currently only cares to check the visibility of Mesh types or if a prim is an instance.
The reason for checking for an instance is because if there was a mesh whos bounding box intersected with the camera you would not be able to give an opinion to either keep it active or deactivate, this way the parent prim of that instance mesh is what will be active or deactivated.
You can make adjustments by changing what its going to be checking for intersects.
Once it has the list of prims it creates a bounding box cache and gets the cameras frustum. It will loop through the stages time range and confirm which prims bounding boxes intersect with the camera and returns you that list.
You can do whatever you want with the returned list of prims, in our case we deactivate them. Just be aware that in some cases you would want to keep some meshes who's prims do not intersect active(for shadows and the like)
I hope this can be helpful and would like to know if anyone has any other ideas where camera based intersects can be used.
Cheers,
Jason Coelho
Edit: I realized the name of the function was not descriptive of it's actual purpose so I changed it.
Beta Was this translation helpful? Give feedback.
All reactions