# Compute Shader Particle System in Processing

**URL:** <https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611>\
**Category:** Gallery\
**Created:** [December 30, 2020, 5:26am UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611 "2020-12-30T05:26:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElementMo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/elementmo/32/4253_2.png) [@ElementMo](https://discourse.processing.org/u/ElementMo)\
**Post date:** [December 30, 2020, 5:26am UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611/1 "2020-12-30T05:26:59Z")

</div>

I managed to implement a very simple particle system using compute shader.  
This example renders **1 million** particles on an Intel Iris 640 integrated graphics card, which is pretty amazing.  
Since compute shader requires OpenGL 4.x, so I am not sure if the original drawing mode will work anymore.  
Github repo:

> **[ElementMo/ComputeShader](https://github.com/ElementMo/ComputeShader)**
>
> Compute Shader in Processing. Contribute to ElementMo/ComputeShader development by creating an account on GitHub.

![ComputeShader01](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/db3c213f15344cb4c7868bdbc7f97f34a37a249c.gif)  
 ![ComputeShaderColor](https://github.com/ElementMo/ComputeShader/blob/master/img/ComputeShaderColor.gif?raw=true)

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [December 30, 2020, 11:29am UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611/2 "2020-12-30T11:29:48Z")

</div>

Code?

So are you computing particle positions then passing data back to Processing to draw particles, or is the shader drawing particles too?

Edit – found it at [https://github.com/ElementMo/ComputeShader](https://github.com/ElementMo/ComputeShader).

---

<div class="post-metadata">

**Author:** ![ElementMo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/elementmo/32/4253_2.png) [@ElementMo](https://discourse.processing.org/u/ElementMo)\
**Post date:** [December 30, 2020, 6:51pm UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611/3 "2020-12-30T18:51:11Z")

</div>

It’s purely shader drawing, nothing is passed back to Processing.

---

<div class="post-metadata">

**Author:** ![guillaume-leo](https://avatars.discourse-cdn.com/v4/letter/g/3da27b/32.png) [@guillaume-leo](https://discourse.processing.org/u/guillaume-leo)\
**Post date:** [December 15, 2021, 8:10am UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611/4 "2021-12-15T08:10:03Z")

</div>

Wow I’m discovering this one year later, that’s wonderfull congratulation for this. I feel that I really want to understand your code but it’s still a bit advanced for me. I mean not the glsl or the processing part, but the opengl part is hard to understand for me.

I already made some particles system by making transformation feedback, but now I would like to do it with compute shaders.

Do you have some resources to suggest?  
Or could I ask you some questions?

Thank you

Guillaume

---

<div class="post-metadata">

**Author:** ![ElementMo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/elementmo/32/4253_2.png) [@ElementMo](https://discourse.processing.org/u/ElementMo)\
**Post date:** [March 3, 2022, 3:52am UTC](https://discourse.processing.org/t/compute-shader-particle-system-in-processing/26611/5 "2022-03-03T03:52:11Z")

</div>

Hi~ Sorry for the late reply.

I found these posts useful. These are C++ compute shader examples:

- [GitHub - IGME-RIT/graphics-glfw-basicComputeShader](https://github.com/IGME-RIT/graphics-glfw-basicComputeShader)
- [GitHub - IGME-RIT/Basic-OpenGL-with-GLFW-Compute-Shaders](https://github.com/IGME-RIT/Basic-OpenGL-with-GLFW-Compute-Shaders)
- [GitHub - IGME-RIT/physics-massSpringLagrangian-tutorial: This is an example of a mass spring system using Lagrangian dynamics. Instead of considering the positions, velocities, and accelerations of each mass individually we use generalized forces to compute acceleration of the system.](https://github.com/IGME-RIT/physics-massSpringLagrangian-tutorial)
- [GitHub - IGME-RIT/graphics-glfw-clothComputeShader](https://github.com/IGME-RIT/graphics-glfw-clothComputeShader).

Also, this one is an example written in Java with JOGL:

- [GitHub - perses-games/jogl-compute-shaders-fireworks: Calculate particles with compute shaders (OpenGL 4.3)](https://github.com/perses-games/jogl-compute-shaders-fireworks)
