jerome Posted April 25, 2016 Share Posted April 25, 2016 http://www.babylonjs-playground.com/#WCDZS#20 line 45 : isAlwaysVisible == always selected as active, so no more frustum test, so more speed (60 fps here) As the SPS is a mesh, you can then use the LOD to improve the perfs when the distance increases. Maybe the flat shaded cylinders would then run at 60 fps also with LOD when displaying the whole mesh (I removed the flat shading because this added a lot of vertices to each tile) what do you mean by replacing some tiles ? actually, you can modify some tiles : changing color, uv, position, scaling, rotation, and even vertex positions, but not the number of vertices, of any particle when you want. setParticles() iterates, each call, on the whole particle pool unless you specify that you want to alter only some given particles for performance reasons by using setParticles(start, end). example : setParticles(20000, 20000) would update the sps geometry by applying only the change passed to the particle at index 20000 and then would update the global mesh according to this little change If you want say remove a particle (you can't actually remove it because it's a part of the whole geometry), you could just remove it either from the user view (scale it to zero or move it to an invisble part of the space, or hide it in another bigger particle), either from the logic : manage a side pool of pre-built invisible tiles (any shapes you want, same way than before : scaled to zero, or positioned in a invisible part of the space, etc) and push or pull the wanted tiles to add or to remove to your terrain from this side pool. In other terms, have a bigger SPS than the visible terrain with pre-generated needed particles for a further use. In short, the SPS is only a mesh so one geometry. You can update this geometry at will by mixing or kneadind it. But if you need to remove or add some vertices, I'm afraid the mesh is to be rebuilt from scratch... what is the case for any WebGL instance actually because the VBO passed from the CPU to the GPU won't have the same size. [EDIT] little test without LOD but with some usual optimizers (freezeWorldMatrix, freeze material and freeze normals if the light wouldn't hae any importance) and flat shaded cylinders : http://www.babylonjs-playground.com/#WCDZS#21 almost 3 millions vertices though... arrg Quote Link to comment Share on other sites More sharing options...
iiceman Posted April 25, 2016 Author Share Posted April 25, 2016 Sounds promising, I'll give it a try as soon as I have time! Thanks for all the help guys! I just rotated the cylinders to make the grid look nice again: http://www.babylonjs-playground.com/#WCDZS#26 Quote Link to comment Share on other sites More sharing options...
jerome Posted April 25, 2016 Share Posted April 25, 2016 http://www.babylonjs-playground.com/#WCDZS#28 I update here only the particles from 15000 to 20000 each 20 frames iiceman 1 Quote Link to comment Share on other sites More sharing options...
iiceman Posted April 25, 2016 Author Share Posted April 25, 2016 That looks pretty cool Well, the idea is some kind of terra forming, changing forst into gras, gras into dirt, dirt into wheat fields. I think that could work since I only change the color and the decorations on the tile. I don't plan on changing mountains into flat tiles or the other way around. I'll have to try it out and see how it goes. I need to find a good (free) node.js hosting service so I can show you guys Quote Link to comment Share on other sites More sharing options...
jerome Posted April 25, 2016 Share Posted April 25, 2016 if you want to change each particle texture, you can with the property uvs : http://doc.babylonjs.com/overviews/Solid_Particle_System#uvs Imagine you've got a single image file containing each style of decoration, like a sprite atlas. This image will be the global sps material texture. Then you can choose what parts of the image to assign to each particle. This can be updated at will also ;-) Knowing all this, remember that the SPS is only one of the solution to design an updatable terrain. There are also the instances or other voxel approaches like Fenomas explained once. There is no magic bullet, each approach has its pro and cons according to your own need. Quote Link to comment Share on other sites More sharing options...
iiceman Posted June 4, 2016 Author Share Posted June 4, 2016 Sooo.. I finally had some time and mood to take another shot at this... looking good so far, 200x200 tiles with constant 60fps on my pc. I create several SPS, one for each terrain type and one additional for the tree decorations (I also simplified that tree model to save some performance here). It takes a while to load with the huge map but my final maps might not be that big. I still have to check the performance when picking tiles and how long it takes to rebuild the SPSs when a player is converting from one tile type to another. If rebuiding everything is too slow I might use multiple chunks for each terrain type instead of putting everything into one SPS. But still have to play around with things. Just wanted to keep you guys updated. Thanks again for helping me out with all your suggestions. Here are two early footage screenshots that show the size of a test map: NasimiAsl and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 4, 2016 Share Posted June 4, 2016 seems really great If not everything is pickable, you can have a not pickable SPS beside a pickable one. Unpickable SPS are obviously faster. About particle update, have you checked this recent post : 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.