|
| ParticleSystemGPU (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1.0f)) |
|
virtual | ~ParticleSystemGPU () |
|
void | push (const NewParticle &pos) |
| Add a new particle to upload in next frame. More...
|
|
GLuint | getActiveCount () const |
|
GLuint | getParticlePosVBO () const |
|
void | draw () const |
|
bool | animate (double time) |
|
void | update (double deltaT) |
|
void | setShader (Shader *val) |
|
| Tessellation (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1)) |
|
virtual | ~Tessellation () |
|
void | draw () const |
|
bool | animate (double time) |
|
void | update (double deltaT) |
|
void | setShader (Shader *val) |
|
GLuint | getDispTexture () const |
|
unsigned int | getTessLevelIn () const |
|
unsigned int | getTessLevelOut () const |
|
void | setTessLevelIn (unsigned int val) |
|
void | setTessLevelOut (unsigned int val) |
|
| SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1)) |
|
| SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1)) |
|
virtual | ~SceneObject () |
|
Model * | getModel () const |
|
Shader * | getShader () const |
|
glm::mat4 | getModelMatrix () const |
|
glm::mat4 | getGlobalModelMatrix () const |
|
std::string | getName () const |
|
std::shared_ptr< SceneObject > | getParent () const |
|
void | setAnimationTime (double time) |
|
bool | setAnimation (const Animation &anim) |
|
bool | delChild (size_t idx) |
|
bool | getChild (size_t idx, std::shared_ptr< SceneObject > &child) const |
|
bool | addChild (std::shared_ptr< SceneObject > &child) |
|
bool | remEffect (const std::string &name) |
|
SceneObject * | getEffect (const std::string &name) const |
|
bool | addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect) |
|
bool | doNotRender () |
|
bool | getIsVolSun () |
|
virtual void | reset () |
|
Implementation of GPU particle system.
- Author
- Adam
For the moving of animated flying bullets effect, a GPU particle system was implemented using the Compute Shader. This way the moving of the particles are computed on the GPU and it could handle even more bullets, then what appears in the demo. Two Shader Storage Buffer Objects and one Atomic Counter Buffer Object are used. In the first buffer particles can have arbitrary order, in this buffer all the attributes of a bullet are stored. The second buffer stores the position and life of the particles aligned, this is the render buffer. A GPU thread is executed on one particle. If it lives, then its new position is computed, the active particle atomic counter is incremented and data is placed into the render buffer at the position retrieved from the atomic operation. When a particle is dead and a new particle should be inserted, an atomic increment is done. If the prefix from the atomic operation is smaller then the number of new particles, then the particle at the prefix is loaded by the current thread. There is an article about atomic counter on LightHouse 3D, according to this article, when atomic counters are supported by hardware, the cost of atomic functions are just like any other function call. Finally, the value of the atomic counter of active particles is read back to the CPU to be able to render with instancing.
- See also
- https://www.opengl.org/wiki/Compute_Shader