freetoplay 6 Report post Posted November 30, 2018 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? Quote Share this post Link to post Share on other sites
brianzinn 373 Report post Posted November 30, 2018 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. Quote Share this post Link to post Share on other sites
freetoplay 6 Report post Posted November 30, 2018 7 minutes ago, brianzinn said: I would suggest to keep the meshes, if memory usage is not a concern. Does this mean that I shouldn't have a lot of hidden meshes? Is there a way to measure how much memory an invisible mesh is consuming? Quote Share this post Link to post Share on other sites
brianzinn 373 Report post Posted November 30, 2018 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 Quote Share this post Link to post Share on other sites
JohnK 991 Report post Posted November 30, 2018 You can use mesh.setEnabled(false) and mesh.setEnabled(true) instead of isVisible. The method setEnabled takes the mesh out of the rendering loop and so does not consume processing time. Whereas isVisible hides the mesh but keeps it in the rendering loop. 3 QuintusHegie, freetoplay and Sebavan reacted to this Quote Share this post Link to post Share on other sites
brianzinn 373 Report post Posted December 1, 2018 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. Quote Share this post Link to post Share on other sites
JohnK 991 Report post Posted December 1, 2018 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 1 brianzinn reacted to this Quote Share this post Link to post Share on other sites
thrice 18 Report post Posted December 1, 2018 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. 2 Deltakosh and brianzinn reacted to this Quote Share this post Link to post Share on other sites
Dad72 916 Report post Posted December 1, 2018 The difference is that the hide object with isVisible can still be clickable or receive collisions. Think of an invisible wall that gets the collisions. While with setEnabled, the object is not visible and not rendered. 2 brianzinn and Deltakosh reacted to this Quote Share this post Link to post Share on other sites