Jump to content

Object leaving trail and BabylonJS


bruyata
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Waaaooowww ! :)

Fenomas, you are a  king !!!

 

20 000 particles at 60 fps in my chromium

200 000 particles at 30 fps !

800 000 particles at 12 fps

 

PR this, right now :lol:

 

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 ;)

Link to comment
Share on other sites

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! 

Link to comment
Share on other sites

Waoow

Very 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=43485

Well, it's Netherlands and not Drôme :P

Link to comment
Share on other sites

PR this, right now :lol:

 

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...