Jump to content
Eternal Lands Official Forums
Sign in to follow this  
Xaphier

Particles for OpenGL 2

Recommended Posts

The biggest missing part for the new OpenGL 2+ el client is the particle system. The goals for the new particle system are:

  • Faster
  • More effects
  • using modern OpenGL features (OpenGL 2/3) and not fixed function

The problem of the eye-candy system is that it works on individual particles. This makes it nearly impossible to use the power of OpenGL and OpenCL to accelerate the particles.

 

Any ideas are welcome :)

Share this post


Link to post
Share on other sites

General design ideas about the particle system

 

To be able to design a fast and efficient particle system, it is important to understand that the hardware used to accelerate the animation and rendering is different from the normal cpu. For particles, that means we should group them so similar effects can be animated together, but also limiting the interaction between the individual particles.

 

Particle animation:

There are mainly two types of particle animations we need.

  1. Type one is the simple type where animation and rendering can be merged, because only simple calculations are needed to get the data for rendering them. The animation calculations only depends on the starting data and the time.
  2. Type two is the complex type, where the animation calculations are iterative. That means, we need to update the animation data and than can use these data for rendering.

Implementing the type two of the particles is the more challenging case, but thanks to modern OpenGL (2.1 & 3+) there are two different ways to implement the animation acceleration. For OpenGL 2.1, we can use "Render to vertex buffer"(R2VB) using "Pixel Buffer Objects" (PBO) and "Vertex Buffer Objects" (VBO). The idea is to use a "Frame Buffer Object" (FBO) to render the updated particle data into a texture and than using these texture data as input for the rendering. This is possible thanks to PBO & VBO. For OpenGL 3+, the thing is easier, because we can use "Transform Feedback". That way, we can animate the data and directly getting them into a VBO after the vertex shader. This is a nice example for the OpenGL 3 way.

 

Particle blending:

There are two different blending types used for particles, additive blending and interpolation blending. Thanks to fragment shaders, we can merge these two blend modes into just one multiplying the particle color with the wanted alpha in the fragment shader and outputting only the alpha for the background as alpha value.

glBlendFunc(GL_ONE,  GL_SRC_ALPHA);

Particle animation & rendering functions:

Those functions don't need to be coded in the client/engine, because we use OpenGL (and later perhaps OpenCL). That means we can read the source code of those functions and than the driver will compile them. That means a lot of freedom.

 

Particle data formats:

For the particles, every vertex format will work, but it never hurts to try to use the smallest memory usage that fits the need. The best is to stick with four values per attribute to avoid shortcomings in the driver of some OpenGL 2.1 implementation.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×