BMWPilote Posted June 25, 2018 Share Posted June 25, 2018 I am just wondering if there is a more efficient way of adding a lot of meshes than adding them one by one? Currently it seems that we can only use the constructor of Mesh which adds it into the scene automatically. But when we have a lot of (100 000) for example, the performance will be crazily low...anyway, is there any way to add it more quickly? Quote Link to comment Share on other sites More sharing options...
BMWPilote Posted June 25, 2018 Author Share Posted June 25, 2018 Another question is can we know how much memory in byte that each Mesh consumes? Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 25, 2018 Share Posted June 25, 2018 @BMWPilote From my experience, cloning is the most efficient method for drawing many meshes. However, if they are all different, then no way. Also, 100,000 meshes displayed at the same time is far too many meshes to display with any attributes - even if they are low res. WebGL will attempt this, however, I doubt your fps would be anywhere near useful for the user. But when would you EVER need 100,000 meshes displayed at once? You should consider the SPS (solid particle system), as it might do what you want. As for measuring memory usage per mesh, from my experience this requires an OpenGL shader to count vertices' per mesh and return this however you like. But I've never found an extension to do this on many meshes in a rendered scene in WebGL. If something like this exists for babylon.js, I'd love to know about it. You can report the memory usage for all vertices' (meshes) in the scene, but that's all I know.. DB Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 25, 2018 Share Posted June 25, 2018 You can import complete scenes or several scene pieces with SceneLoader.Append() instead of using SceneLoader.ImportMesh() which add "mesh by mesh" to the scene. 100,000 meshes? it's really huge. you should divide by at least 100 to 200 and separate your game into several scenes. For example a city scene, you all do the city scene without the interiors, and on other scenes all the scenes of interiors. That's what a lot of professional games do. You reduce the number of meshes per scene. Then, for more meshes, use, Octree, OcclusionRequest, and all that will allow you to optimize the scene. Of course you have to model in lowPoly if you want a lot of mesh on the scene. do not hesitate also to merge meshes to reduce their numbers too Quote Link to comment Share on other sites More sharing options...
BMWPilote Posted June 25, 2018 Author Share Posted June 25, 2018 51 minutes ago, Dad72 said: You can import complete scenes or several scene pieces with SceneLoader.Append() instead of using SceneLoader.ImportMesh() which add "mesh by mesh" to the scene. 100,000 meshes? it's really huge. you should divide by at least 100 to 200 and separate your game into several scenes. For example a city scene, you all do the city scene without the interiors, and on other scenes all the scenes of interiors. That's what a lot of professional games do. You reduce the number of meshes per scene. Then, for more meshes, use, Octree, OcclusionRequest, and all that will allow you to optimize the scene. Of course you have to model in lowPoly if you want a lot of mesh on the scene. do not hesitate also to merge meshes to reduce their numbers too How does SceneLoader.Append() work exactly? It calls new Mesh() anyway, right? I would like to use Occlusion Query, but seems that it is not supported on IOS? Quote Link to comment Share on other sites More sharing options...
BMWPilote Posted June 25, 2018 Author Share Posted June 25, 2018 1 hour ago, dbawel said: @BMWPilote From my experience, cloning is the most efficient method for drawing many meshes. However, if they are all different, then no way. Also, 100,000 meshes displayed at the same time is far too many meshes to display with any attributes - even if they are low res. WebGL will attempt this, however, I doubt your fps would be anywhere near useful for the user. But when would you EVER need 100,000 meshes displayed at once? You should consider the SPS (solid particle system), as it might do what you want. As for measuring memory usage per mesh, from my experience this requires an OpenGL shader to count vertices' per mesh and return this however you like. But I've never found an extension to do this on many meshes in a rendered scene in WebGL. If something like this exists for babylon.js, I'd love to know about it. You can report the memory usage for all vertices' (meshes) in the scene, but that's all I know.. DB Yeah they are in generally very small. I have many meshes which share the same Geometry data. I used (the same) VertexData.apply() to feed them. But my question is that just creating many meshes by "new", consumes a lot of time... Quote Link to comment Share on other sites More sharing options...
jerome Posted June 25, 2018 Share Posted June 25, 2018 please tell us a bit more about what you're trying to achieve and where you notice the bottleneck ? Do you download thousands of different meshes ? Do you build, from BJS native constructors, the meshes ? Do you need to display all of them in the same time on the screen (not sure there are enough pixels on the screen to display thousands meshes anyway) ? Do your meshes share the same geometry, same material, same colors, etc ? There are tools in BJS to load scenes or meshes before starting a scene. There are also tools to clone meshes or merge them in a bigger geometry, there are tools (and user practices) to optimize the rendering process too by selecting only the meshes to be rendered... well there are many ways to improve things once we know what is to be done actually ? Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 25, 2018 Share Posted June 25, 2018 @BMWPilote makes a VERY good point. cloning loads of meshes takes time. However, you can keep the scene from rendering until all meshes are loaded using the Assets Manager. Never tried this with cloning, but I don't see why this wouldn't work. Anyone have experience with this specific task? DB Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 25, 2018 Share Posted June 25, 2018 10 hours ago, BMWPilote said: How does SceneLoader.Append() work exactly? Append () loads a scene that contains multiple meshes. ImportMesh (), only loads a single mesh. You look for a method to add more mesh at once. Append () is done for that. dbawel 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 26, 2018 Share Posted June 26, 2018 Instead of cloning I would recommend createInstance: fast and clean 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.