]> Witch of Git - lovr-particles/commit
Implement compute-shader simulation of particles!
authorCassie Jones <code@witchoflight.com>
Sat, 1 Feb 2020 05:15:45 +0000 (00:15 -0500)
committerCassie Jones <code@witchoflight.com>
Sat, 1 Feb 2020 05:15:45 +0000 (00:15 -0500)
commita91af7ccb0d6e52c337854229c646751c2c186b4
tree5b381acd74c167913bb61455fa34d25e68264fbd
parentd02366e9b8f8f7f53455580d933e550a7b06f112
Implement compute-shader simulation of particles!

This uses a workaround for the previously mentioned shader glitch in
order to use the compute shaders successfully. Bjorn notes that reading
from an SSBO makes rendering start working properly. In order to
*hopefully* make this cheaper, I add a variable to the buffer that's
intended for only reading like this, which ends up being sufficient to
fix the behavior of the whole buffer.

The discussion comment with the workaround:
https://github.com/bjornbytes/lovr/issues/211#issuecomment-580985010
> Reading data out of the buffer (print(block:read('value')[1])) after
> the compute also fixes it, I suspect maybe because it maps the buffer.

For simulation, this updates the positions with the velocity, and
applies uniform quadratic drag to the particles.
main.lua
shaders/particles.comp
shaders/particles.frag
shaders/particles.vert