Jump to content

Checking mesh visibility (mesh hidden or not by other mesh)


Vousk-prod.
 Share

Recommended Posts

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) ?

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

Oh yes, thank you.

I forgot this mesh.subdivide()stuff. :wacko: 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 ?

Link to comment
Share on other sites

Ok. Thanks for the piece of info.

Sad news for the submaterials killing, I won't be able to use subdivide very often... :unsure:

 

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 ?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...