bruyata Posted March 2, 2015 Share Posted March 2, 2015 Hi everyone!I have in my application a lot of object (around 5 000) moving. I want to leave a trail behind them. I've tried with the particle engine of babylon.js but it was a fail with 5 fps...I wonder how i can make a trail with good performance with Babylon.js. This code is pretty clean but i'm afraid of the performance of this for so many object. How can i do this ? Thank you guy! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 10, 2015 Share Posted March 10, 2015 Hi bruyata, welcome to the forum, and sorry for the lack of replies. I think you have the forum stumped. 5000 mesh. That's ... substantial. Even without trails, the scene might be slow. You COULD put a "trailing" plane behind each moving mesh, and put images of different trail-lengths on it... as the mesh moved. But... they would be straight sim-trails. If the mesh made a tight turn, it would be difficult to "curl" the trail. (with the trailing plane method I described). A good puzzle, bruyata. *scratch scratch* Again, welcome to the forum. Sorry for the lack of ideas/solutions for you. Quote Link to comment Share on other sites More sharing options...
jerome Posted March 10, 2015 Share Posted March 10, 2015 Hi, In your demo site, I can see your trail is designed with a succession of triangles along a curve.We have this 3D object in BJS called a ribbon : http://babylondoc.azurewebsites.net/page.php?p=24847 So you could so create a ribbon and then apply to it either a texture looking like a trail, either compute a procedural texture on your own (http://babylondoc.azurewebsites.net/page.php?p=22601) and apply it to the ribbon, either play directly with particles whereas monitoring performance : http://www.babylonjs-playground.com/#2KOEWJ#9 (3600 particles moving along a Möbius ribbon, but no BJS ribbon object here) Do you really need trail animation as there is none in your demo site ? Wingnut 1 Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 10, 2015 Share Posted March 10, 2015 I was thinking about this a while ago. The problem might be that each particle system gets drawn separately, so if you have 5000 particle emitters then that's 5000 draws, even if they all draw identical particles. As a solution, you might try using a single particle system and overriding the start function so as to distribute the particles among your objects. In pseudocode:sys = new ParticleSystemsys.capacity = moreThanFiveThousandsys.startPositionFunction = function(world, pos) { emitter = choose() // randomly or iteratively choose one of the 5K objects pos = emitter.position}That way the whole scene's particles would all get drawn at once, with the system's "capacity" spread among the 5K emitters. I haven't tried this yet however. jerome and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted March 10, 2015 Share Posted March 10, 2015 Stressing this BJS un-optimized code (initially from iiceman) : http://www.babylonjs-playground.com/#2KOEWJ#10Here 20 000 particles... between 25 and 30 fps on Chromium and FF on my computer, not that bad for now http://www.babylonjs-playground.com/#2KOEWJ#11200 000 particles now !!! chromium down to 15-17 fps Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 10, 2015 Share Posted March 10, 2015 http://www.babylonjs-playground.com/#2KOEWJ#11200 000 particles now !!! chromium down to 15-17 fps I'm not really sure how this affects the OP's question, but I optimized it some more for you:http://www.babylonjs-playground.com/#2KOEWJ#12 iiceman 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted March 10, 2015 Share Posted March 10, 2015 Waaaooowww ! Fenomas, you are a king !!! 20 000 particles at 60 fps in my chromium200 000 particles at 30 fps !800 000 particles at 12 fps PR this, right now It needs 100 000 particles to get my Chromium hardly reaching 60 fps (57-58 fps). So bruyata, I guess you can opt for particles if only have 5000 elements Quote Link to comment Share on other sites More sharing options...
bruyata Posted March 11, 2015 Author Share Posted March 11, 2015 Wow! impressive! I've work on my problem on this time. Here is my first draw : http://www.babylonjs-playground.com/#1WM8Z7#2 (sry for bad code, i must cut a lot of the code of my project to make it work in the babylon playgroundà For this, i'm using the sprite manager and use them as particles. For the fadeout effect, i've just reducing the "alpha" of the sprite! It's working very good but the rendering is not as good as the particle engine.As you can guess, i'm making a transportation simulator! And all of my users must have a trail! I've maked a try with the particle engine but encoutered some problems by summoning a lot of particle sources. Maybe a solution for could be to use one particle engine and dispatch the particle through my moving point. I will see this =)Thank you for this page too! i will give a try for this technics as soon as i can! Quote Link to comment Share on other sites More sharing options...
jerome Posted March 11, 2015 Share Posted March 11, 2015 WaoowVery nice playground example !!!I really like your trailing sprites. (45 fps on FF with my fast computer) Maybe the particle approach could be the good one if you handle them by yourself instead of multiplying emitters.Worth a try anyway. Btw, this guy made a real time traffic visualizer one year ago :http://www.html5gamedevs.com/topic/6557-babylon-projects/?p=43485Well, it's Netherlands and not Drôme Quote Link to comment Share on other sites More sharing options...
fenomas Posted March 12, 2015 Share Posted March 12, 2015 PR this, right now Hehe, I didn't touch the engine, just cleaned up the update function. The main thing is I removed the dynamic lookups so chrome didn't bail out of optimization. I've maked a try with the particle engine but encoutered some problems by summoning a lot of particle sources. Maybe a solution for could be to use one particle engine and dispatch the particle through my moving point. That's what I suggest. Pseudocode is in my previous reply. 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.