jpvaillancourt Posted November 19, 2018 Share Posted November 19, 2018 I'm trying to create a forest with planes. All with a unique texture. Since I want it to be optimize, I have created a sort of "clusterer" to append some textures together and draw the planes into one mesh (with some serverside work to append the textures). It works fine! The problem that I have is that I need to animate the scale of the planes dynamically. I am using mesh.setVerticesData() to update the vertex positions, but it has some performance issues. Is there a way to update only 16 vertices positions out of 64k without refreshing ALL of the mesh? I'm not sure if I'm clear enough... that's what I have so far to update the positions. updateMesh(index, vertexPositions) { let positions = this.mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); let dataLength = vertexPositions.length; let startIndex = index * dataLength; for(let i = 0; i < dataLength; i++) { positions[startIndex+i] = vertexPositions[i]; } this.mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions); } Quote Link to comment Share on other sites More sharing options...
jerome Posted November 19, 2018 Share Posted November 19, 2018 You could just update the 16 wanted vertices and still pass the whole modified buffer (verticesData).. The bottleneck isn't usually in the size of the buffer to be passed to the GPU but rather in the user logic. Have you profiled your code to check where the time was spent and what was responsible for this time consumption ? BJS provides a feature that could fit your need, called the Solid Particle System (SPS), with many optimizations already set : https://doc.babylonjs.com/how_to/solid_particle_system and the ability to update only some parts of the system (mesh) and to use a single texture too. ssaket, Sebavan and NasimiAsl 3 Quote Link to comment Share on other sites More sharing options...
jpvaillancourt Posted November 19, 2018 Author Share Posted November 19, 2018 I must say, the performance issue is a fps drop of 15 frames. I will profiled my code and get you back. As for the particle system, I have thought of it, but all my tree are user generated for the shape, decorations, colors, etc. They all have unique textures. Might it work?!? Haven't seen anything like this into the documentation. Sure it would save me a lot of time to manage and optimize the scale animation, but at the same time I feel I'll have an issue with the textures. 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.