Results 1 to 4 of 4

Thread: Particle System

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2010

    Particle System

    Hello! I'm making a simple particle system for my asteroid-belt. It consists of only GL_POINTS with a randomized location, color, and alpha value.

    I have a class called Particle which consists of the mentioned variables. Then I have a class called ParticleSystem which includes a vector of Particle.

    If I have very small values for the number of particles it works fine. But I want to have a lot more for a better look. When I have about 7000 particles it begins to lag. But for it to look good I want to have at least 30000.

    So, my question is, how can this be optimized? I bet a complicated particle system consists of more than 7000 particles, or?

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2011

    Re: Particle System

    A lot depends on how you draw the particles. Are you using glBegin and glEnd? Because those will kill your framerate with that many calls. Its best to use a VBO, but that means you will have to combine all your vertices into a single array (or keep them ordered regularly).

  3. #3
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    UK, London

    Re: Particle System

    For upwards of 10,000 instances you could use 'instancing' techniques. The only real advantage this gives is less API calling - and that is only a benefit if you believe this is the application bottle neck.
    There are two really useful methods for instancing: TextureBuffer objects and ARB_instanced_arrays which method you choose depends upon your GL version + supported extentions and preference.
    With TBO you pack your 'instance' data into a texture and read that back in the vertex shader to fill out vertex position and color/alpha.
    With instanced arrays, you set up another set of vertex attributes containing the per-instance data (position, colour)
    Both will work, but I suspect it comes down to whether you intend to update the 'instance' data in real time or not.

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007

    Re: Particle System

    With this number of points you could easily just put them all into a single static VBO, with attributes representing initial position, velocity, direction, etc, then each frame draw the VBO in a single draw call, passing the current time as a uniform and calculating the final position to draw at in your vertex shader.

    You may find however that it's fillrate that's killing you rather than vertex submission, in which case no trick to optimize vertex submission is going to help.

    One thing is for certain - going OO at such a fine level of detail as a single point is not really necessary at all.

Similar Threads

  1. particle system
    By debinair in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-09-2014, 10:59 AM
  2. Particle System
    By micetta2482 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-14-2010, 11:05 AM
  3. Particle System API
    By cochondinde in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-20-2005, 03:37 AM
  4. Particle System
    By Coluna in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-13-2003, 09:09 PM
  5. Particle system?
    By CyBBe in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-16-2000, 11:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean