nfaralli / particleflow

MIT License
52 stars 14 forks source link

how to make particle fade? #3

Open ksy5662 opened 6 years ago

ksy5662 commented 6 years ago

I just want to implement airflow with particle flow such as

https://earth.nullschool.net/

any recommendation to modify the render script to make it.

Also want to know how to make SurfaceView Background Transparent.

Thanks in advance!!

nfaralli commented 6 years ago

Hey So-Young, Interesting, I haven't touched this app in a long while but just a few weeks ago I saw an app doing something similar and thought it would be cool and fairly easy to do (if I had time ... :'( ). The way I'd do it would be to "simply" store the last N points computed by the render script for each particles and display the (N-1) lines per particle rather than just one point. I did that for another program I wrote with OpenGL many years ago which was rendering particles too. It was fairly easy to do, however the more lines you draw the more resources it takes of course. Also, if you want to the traces to fade, you can add some blending with OpenGL and set some opacity coefficient for each of the N points (older points get smaller coef for example). Overall, I don't think you need to change much or anything at all in the render script. Changes should be mainly done in the OpenGL layer. Good luck! :)

On Tue, Oct 2, 2018 at 11:23 PM So-Young Kim notifications@github.com wrote:

I just want to implement airflow with particle flow such as

https://earth.nullschool.net/

any recommendation to modify the render script to make it.

Thanks in advance!!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nfaralli/particleflow/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFRiaoCMxoGinJJb18Rzs4hfTQreKChks5uhFfcgaJpZM4XFX1X .

ksy5662 commented 6 years ago

Dear Nicolas Faralli,

I really appreciate your answer for my question. That suggestion is really helpful and informative for me to implement that particle fade.

One another quick question! I tried to make opengl background transparent by checking most of stackoverflow. But I couldn't make it. Any suggestion on this??

Thank you so much for your answers and wish you all the best.

So-Young Kim

nfaralli commented 6 years ago

Not sure what you mean by transparent background. As far as I know transparency is done using blending (I'm really not an expert in OpenGL lol): basically when you decide to draw a pixel you can tell OpenGL to mix the color of this pixel with what has been draw before. If nothing has been drawn before, then the background color is used. However in the end you still need to get a color for your pixel right? (either coming from an object you drew yourself, or the background color). If the background is fully transparent (i.e. invisible), and you don't create any object in your scene, then what do you expect to see? Regarding blending, here https://github.com/nfaralli/BPV is the old project I mentioned before. I wrote it 10+ years ago and put it on GitHub as a souvenir :) It's quite messy, but if you look at the class glwidget.cpp https://github.com/nfaralli/BPV/blob/master/app/source/glwidget.cpp (lines 335-340) you'll see how blending is used to draw opaque and transparent objects. The color of each vertex has for components (RGBA). The last one, alpha, is used to tell OpenGL how transparent your vertex is (1.0 (or 255) fully opaque, 0 fully transparent). The drawScene function first draws all the objects in the scene where alpha=1.0, then tells OpenGL to start blending the next objects (glEnable(GL_BLEND)), and then draw the transparent objects (alpha < 1.0). However this is with OpenGL and not OpenGL ES... so I doubt it will be that easy with OpenGL ES ... :( I'm sure there are good tutorial online for that!

Hope this helps! Nick

On Fri, Oct 5, 2018 at 12:35 AM So-Young Kim notifications@github.com wrote:

Dear Nicolas Faralli,

I really appreciate your answer for my question. That suggestion is really helpful and informative for me to implement that particle fade.

One another quick question! I tried to make opengl background transparent by checking most of stackoverflow. But I couldn't make it. Any suggestion on this??

Thank you so much for your answers and wish you all the best.

So-Young Kim

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nfaralli/particleflow/issues/3#issuecomment-427273489, or mute the thread https://github.com/notifications/unsubscribe-auth/ABFRiSdd9RlM8hKexS5s5RDL7aUI-4X4ks5uhwu3gaJpZM4XFX1X .

ksy5662 commented 6 years ago

Dear Nick, I really appreciate your explanation on OpneGL. That helps a lot for me to understand how OpenGL draw objects and etc.

I am trying to put google map first as a background and put ParticleView on top of it so that I can display like this app.

https://play.google.com/store/apps/details?id=co.windyapp.android

To do this, ParticleView's background should be transparent so that I can see google map unless there is an object.

Seems the ball is on my hand and I will try to solve this issue.

Thanks again and wish you all the best.

So-Young Kim