Point Sprite particles

jME currently renders particles using either triangles or points, but it’s possible to render point particles that look identical to normal particles using a new OpenGL 2.0 extension called ARBPointSprite and an older extension called ARBPointParameters.









To try this out, add this code to the end of simpleInitGame in TestPointParticles:


// point sprites are useless without a texture
TextureState ts = display.getRenderer().createTextureState();
        ts.setTexture(
            TextureManager.loadTexture(
            TestPointParticles.class.getClassLoader().getResource(
            "jmetest/data/texture/flaresmall.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR));
        ts.setEnabled(true);
        pPoints.setRenderState(ts);
       
        // enable point sprite mode, generate special texture coordinates for points
        GL11.glEnable(ARBPointSprite.GL_POINT_SPRITE_ARB);
        GL11.glTexEnvi(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, 1);
       
        // set up the distance attenuation
        FloatBuffer ceoff = BufferUtils.createFloatBuffer(0.0f, 0.00001f, 0.0f, 0.0f);
        ceoff.rewind();
        ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB, ceoff);

delicious  :-o

How does performance compare?  Do you feel this is something that could be setup (for performance gains) as part of the particle system as an auto-enable on supporting platforms?

Beautiful!  This is why I read the forums.  I want this feature, and didn't know how there was a OpenGL feature to do it.  I am doing the distance fadeoff for particles by myself right now.  I'd love to move that out of my code's responsibility.



Plus this gives me a better formula to do the fadeoff if this isn't implemented.

How does performance compare?  Do you feel this is something that could be setup (for performance gains) as part of the particle system as an auto-enable on supporting platforms?

I didn't do any specific benchmarks or anything like that, I don't even understand how point rendering works..
I assume that a lot less data needs to be sent to the GPU, which saves bandwidth and memory on the video card.

Points are faster than quads for particles on both CPU and GPU.

CPU: there is no need to reorient the particles to face the camera.

GPU: less data to process.



Ideally this would be the default particle implementation with quads as a fall-back for the older hardware.

Thanks Lex, that makes good sense.