# • Atomize • GPGPU elastic-viscuous particles simulation

## • Atomize •

I’ve been working on and off on this project for quite a while now. Slowly adjusting and implementing more and more features. I think this is finally at a stage where I consider it fit for display, so I thought I would share this here.

I won’t go into much detail about how it all works, but if you are interested in learning about GPGPU techniques, I highly recommend this blog post by Nicolas Barradeau.

You can also check the complete code on the github repo.

Would greatly appreciate some feedback about the project, I’ve tried my best to make it as compatible and mobile friendly as possible. Enjoy

13 Likes

Are you calculating depth of field, or is it just a soft particle texture that gives that illusion?

2 Likes

@marquizzo I’m definitely calculating depth of field, in my opinion it adds a lot to the scene.

Due to the nature of dof effect and particles being small circles, we don’t need to make use of complex post-processing rendering to achieve a good depth of field on them.

In regular dof, frag pixels become larger circular spots, which need to be calculated at every frame. How big is that spot and how bright or faint depends on the distance to focal plane of the camera.This is not a linear function though, nor is it mirrored before/after focal point. Objects before the focal place (closer to the camera) have a faster exponential growth rate, compared to the ones after the focal plane.

In the case of dof on circular particles, I already have control over the size of each particle. So, I just calculate the enlargement ratio and transparency falloff based on z-distance to the focal plane.

##### Using transparency on particles can add a few problems when rendering, because we can’t sort their rendering order, since that is locked by the order you define the vertices on geometry instantiation. I handled this by dividing the particle field intro discrete blocks and sorting these blocks accordingly.
2 Likes

Really cool! It evens runs (with a cool slow-mo effect) on my mobile!

Gonna investigate your code sometime soon

1 Like

Really cool! It evens runs (with a cool slow-mo effect) on my mobile!

Thank you, totally intentional mobile slow-mo effect

Gonna investigate your code sometime soon

Would love to hear your thoughts about it !

2 Likes

very very cool!

1 Like

I’ve updated the particle blending to additive. That way, I don’t have to sort all the discrete blocks and it can run at a better framerate.

I believe the visuals also look far superior that way, just needed to make some small changes to the lighting.

4 Likes

Such a cool demo!

1 Like