Vousk-prod. Posted February 20, 2015 Share Posted February 20, 2015 Hi fellows, Is there a way to determine whether a mesh is or not hidden by other meshes ? For now I'm hijacking scene.pick to do that (I calculate mesh XY position in canvas space and then use scene.pick to see if that mesh is the first one to be hit).That works pretty well, but scene.pick is a heavy ressource consumer when the scene contains complex meshes. You can check that in this PG (uncomment the loading of the skull to see the impact of complex meshes, FPS drop to 5 / 20 instead of 60 with simple objects - without scene.pick, skull scene is easily 60 FPS -) :http://www.babylonjs-playground.com/#NA4OQ#4 Is there a smarter way to check mesh visibility (or to optimise scene.pick hijacking) ? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 20, 2015 Share Posted February 20, 2015 You can use Octree regarding the resource consumption scene.pick mesh.useOctreeForPicking = true;or octree = scene.createOrUpdateSelectionOctree(); Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 21, 2015 Author Share Posted February 21, 2015 Thanks for the suggestion, my problem here with octree is that I can't predict the scene in advance (created on the fly), most of the case there will be few objects but they can have around 1k to 5k vertices each, with submeshes (because using submaterials), and to be really annoying those meshes are not static (that's why I need to check visibility at every frame). I'm pretty sure the situation would make octree usage counter productive. But thanks for the suggestion I'll do some tests. Anyway if someone has a better method than mine to check if a mesh is hidden by another that would be nice. I feel that scene.pick is an ugly workaround for that and I don't like coding too badly Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 21, 2015 Author Share Posted February 21, 2015 Hmmm, when I activate octree, the skull doesn't appear anymore (but it still drop FPS down ) (First attempt with octree for me, I'm certainly doing something bad...) http://www.babylonjs-playground.com/#NA4OQ#6 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 21, 2015 Share Posted February 21, 2015 Here is the good one:)http://www.babylonjs-playground.com/#NA4OQ#7 Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 21, 2015 Author Share Posted February 21, 2015 Oh yes, thank you.I forgot this mesh.subdivide()stuff. However the octree doc well mentions it Since I have scenes where not pre-known meshes can be injected on the fly, I think that a vertices count check at each insertion could be a good way to determine for each one if octree would be interesting, am I right ?Is there an avergae vertices count I should keep in each mesh and subMeshes for performance to not drop down ? And also, if I apply subdivide() to mesh that already have submeshes (I always have submaterials on those meshes), will this add submaterials or brake submaterials indexes ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 21, 2015 Share Posted February 21, 2015 You're right:) I have no good heuristic but I try to get like 200 vertices per sub-meshes Do not subdivide on a mesh with submeshes because this will kill the submaterials Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 21, 2015 Author Share Posted February 21, 2015 Ok. Thanks for the piece of info.Sad news for the submaterials killing, I won't be able to use subdivide very often... Any other idea to check if a mesh is viewed by the camera ? Maybe an already existing mechanism you're using for mesh visilibility / rendering / culling I can study and hijack to do this with maximum efficiency ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 22, 2015 Share Posted February 22, 2015 Internally you can use mesh.isInFrustum(frustumPlanes) Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 22, 2015 Author Share Posted February 22, 2015 Hmmm, I must definitly have a look at this ! Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.