Jump to content

Question about isVisible


freetoplay
 Share

Recommended Posts

If I make meshes invisible in the scene, does it have any impact on the performance of the scene? For example, if I have a several slow performing meshes in the scene, would making them invisible increase the performance of my scene? I want to make some meshes visible in only certain cases, but I don't know if making them invisible would do the trick or would I have to dispose to them, then reimport them?

Link to comment
Share on other sites

1 hour ago, freetoplay said:

For example, if I have a several slow performing meshes in the scene, would making them invisible increase the performance of my scene?

Yes.  The "active" meshes are the ones that slow down your scene.  Notice here where invisible (isVisible == false and visibility ==0) are not included:
https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L4259

If you dispose() a mesh instead of hiding it, then I would think it would give you a very marginal speed increase, but with the slow cost of re-importing. I would suggest to keep the meshes, if memory usage is not a concern.  Best thing is to do a speed comparison, as empirical evidence (ie: FPS/engine.getDeltaTime()) does not always show what would seem intuitive.

Link to comment
Share on other sites

2 minutes ago, freetoplay said:

Is there a way to measure how much memory an invisible mesh is consuming?

If you look in the inspector (ie: open PG click "inspector" button), then you can see the number of vertices/faces (ie: mesh.getTotalVertices()) - along with materials, these are in memory.  To answer your question, though, I am not aware of a way to measure memory usage of a single mesh - I just go by poly count as a basic measurement.  If you have materials with large textures would also have an impact.  Clones vs instances will also reduce memory footprint, if you have multiple.  If you need to "unhide" meshes quickly then disposing them is not a good option! :) 

You may find this useful, but they will remain in memory:
https://doc.babylonjs.com/how_to/how_to_use_assetcontainer

Link to comment
Share on other sites

18 hours ago, JohnK said:

The method setEnabled takes the mesh out of the rendering loop and so does not consume processing time.

The link from my first response was to the exact line that I thought does that (!mesh.isEnabled() ... continue;), from my understanding (https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L4259)

So, why does isVisible == false keep it in the rendering loop, while setEnabled(false) not?  I would think the difference would be hardly noticeable.  Is there somewhere else I should have referenced or a performance penalty I am not seeing? Thanks.

Link to comment
Share on other sites

4 hours ago, brianzinn said:

So, why does isVisible == false keep it in the rendering loop, while setEnabled(false) not?  I would think the difference would be hardly noticeable.  Is there somewhere else I should have referenced or a performance penalty I am not seeing? Thanks.

Sorry don't know the reason why. Just following @Deltakosh's advice http://www.html5gamedevs.com/search/?&q=setenabled&type=forums_topic&author=Deltakosh&nodes=28&search_and_or=or&sortby=relevancy

Link to comment
Share on other sites

18 hours ago, brianzinn said:

The link from my first response was to the exact line that I thought does that (!mesh.isEnabled() ... continue;), from my understanding (https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L4259)

So, why does isVisible == false keep it in the rendering loop, while setEnabled(false) not?  I would think the difference would be hardly noticeable.  Is there somewhere else I should have referenced or a performance penalty I am not seeing? Thanks.

The reason (or at least one of) is because isVisible=false can be used to group meshes together, so that the children meshes are still active in the scene (like a transform node in newer babylon versions). If you setEnabled(false) instead the child meshes will be removed from the rendering loop also. I believe there are other uses I've encountered as well just can't think of off the top.

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...