Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle trails #20

Open
timeroute opened this issue Jun 20, 2019 · 6 comments
Open

Particle trails #20

timeroute opened this issue Jun 20, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@timeroute
Copy link

how can i draw particle trails?
just like the demo of mapbox/webgl-wind.

@gampleman
Copy link
Contributor

At the moment this isn't supported.

In order to do that ala mapbox/webgl-wind, you need to render the output to a framebuffer and fade it out progressively over time. This has the following negative consequences in a full featured implementation:

  1. The output is completely wrong when panning/zooming, so you have to throw it out. This leads to a somewhat disconcerting effect where every time you move the map, all the particle trails disappear only to show up a few seconds later.
  2. This limits the speed of the particle: it cannot travel more than a single pixel per frame, otherwise the particle trail develops holes, breaking the visual effect.

In the longer term we can develop some solutions to this. My thoughts went something like this:

  1. choose a number of frames that we will have a particle trail for, call it n.
  2. allocate n + 1 textures to hold particle positions.
  3. on a normal frame, compute the current position based on frame n, shift the textures around one position and store it frame n
    • on a frame where a zoom/pan has occurred, recompute the position for all n. This will be slow, so this needs to put a limit on the size of n
  4. When drawing to the screen, draw in line mode, drawing a segment of the line between pairs of frames.

@gampleman gampleman changed the title how can i draw particle trails Particle trails Jun 21, 2019
@gampleman gampleman added the enhancement New feature or request label Jun 21, 2019
@Robert-OP
Copy link

At the moment this isn't supported.

In order to do that ala mapbox/webgl-wind, you need to render the output to a framebuffer and fade it out progressively over time. This has the following negative consequences in a full featured implementation:

  1. The output is completely wrong when panning/zooming, so you have to throw it out. This leads to a somewhat disconcerting effect where every time you move the map, all the particle trails disappear only to show up a few seconds later.
  2. This limits the speed of the particle: it cannot travel more than a single pixel per frame, otherwise the particle trail develops holes, breaking the visual effect.

In the longer term we can develop some solutions to this. My thoughts went something like this:

  1. choose a number of frames that we will have a particle trail for, call it n.

  2. allocate n + 1 textures to hold particle positions.

  3. on a normal frame, compute the current position based on frame n, shift the textures around one position and store it frame n

    • on a frame where a zoom/pan has occurred, recompute the position for all n. This will be slow, so this needs to put a limit on the size of n
  4. When drawing to the screen, draw in line mode, drawing a segment of the line between pairs of frames.

thanks @gampleman for your work up until now on this, one question:

would this feature require to continue with webgl implementation?

@gampleman
Copy link
Contributor

would this feature require to continue with webgl implementation?

Not totally sure what you mean by that?

@Robert-OP
Copy link

would this feature require to continue with webgl implementation?

Not totally sure what you mean by that?

so, in order to implement the particle trails feature is it needed for one to know more how to work with webgl?

@gampleman
Copy link
Contributor

Yes. I'm afraid that to do anything interesting inside this repo fairly decent knowledge of WebGL is required.

@Robert-OP
Copy link

Robert-OP commented Aug 27, 2020

thank you @gampleman - would you be interested to develop this feature forward if sponsored?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants