Results 1 to 6 of 6

Thread: Any obvious improvements to my particle system?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Any obvious improvements to my particle system?

    Hi again,

    I've written a basic particle system. I don't need a GPU based one, but I'd like to check that there aren't some obvious improvements to what I've implemented.

    Each frame I fill an array with a quad for each particle i.e. 4 vertices which each have; Pos (3 floats), Tex Coords (2 floats) and Color (4 floats). I then call glBufferSubData to put this into an existing GL_WRITE_ONLY VBO which I have created to be big enough to hold the max number of particles

    I then render the VBO of particles with glDrawArrays GL_QUADS.

    Each particle and be a different size and colour and graphics come from a single texture sprite sheet of particles.

    Any improvements I could make?

    Thanks,

    Stuart.

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: Any obvious improvements to my particle system?

    You can save per particle data (less data to upload) by using a geometry shader to generate the 4 particle vertices from a single position and color. Make position a vec4 and you can use the w coordinate as an index into a texture atlas (if you need that).

    I don't know how much of a performance improvement this can yield, but since you avoid a bit of CPU computation (no need to figure out the 4 corners of the quad) and PCIe bandwith it may help.

    Using two (or more) VBOs to avoid stalling the pipeline (ideally you want the previous render and the next upload to be parallel) may help too.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Any obvious improvements to my particle system?

    Quote Originally Posted by carsten neumann
    I don't know how much of a performance improvement this can yield, but since you avoid a bit of CPU computation (no need to figure out the 4 corners of the quad) and PCIe bandwith it may help.
    If you have no geom shader/or too slow, you can still use a vertex shader : send 4 vertices with same position, but each with a different screen-space direction to inflate it within the vertex shader.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    592

    Re: Any obvious improvements to my particle system?

    Zbuffer and neumann, isn't it possible that the shader switch will take up more time than the particles he wants to render would take without the switch?

    This is one of the dilemmas I am trying to resolve right now. When do you adapt an existing shader to render something and when you write a new shader to render something. Maybe you write a shader for everything at first and then coalesce them together at a later time as needed.

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Any obvious improvements to my particle system?

    Well to be honest, the original poster did not reveal how many particles are drawn.
    Of course for such low-level tuning, benchmarks must be done to verify if any tangible gains exists. A shader based approach can free CPU work, so in the end "it depends".

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    146

    Re: Any obvious improvements to my particle system?

    Thanks for the replys. Want to keep running on older cards, so Geom Shader is out, but I'll try the vertex shader approach and do some benchmarking. I've only just got it to the "it seems to run" and haven't had time to do any real testing.

Similar Threads

  1. Particle system help
    By EchoDolphin in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-11-2018, 10:23 AM
  2. particle system
    By debinair in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-09-2014, 10:59 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