Jump to content
  • Advertisement
Sign in to follow this  
Darragh

OpenGL Point sprites bring system to its knees..

This topic is 4842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Well the time has come to do a little particle system for my engine so I'm currently learning how to use point sprites. I previously used a very crude method of doing them by drawing a polygonal diamond to represent each particle- not the best solution, so i'd much prefer point sprites along with some nice particle textures. With point sprites I can also other nice effects such as explosions, lens flare etc.. But... As you no doubt guessed i'm having problems! My current code draws the point sprite- but brings my entire system to a near standstill.. It's so slow that I can actually see individual triangles being rasterized- not good performance at all! [headshake] What seems to be annoying my graphics card is the actual size of the point sprite. If I use a maximum size of 1.0f (a single pixel) then everything is fine, however anything larger than this results in the above problem. Querying my hardware I found that it has a maximum supported sprite size of 1024f and a minimum size of 0f. I just don't know why this problem is happening- it should work fine. My code is basically the same code used in the OpenGLCode samplers demonstration of point sprites. I had no problems running that demo- even though I'm doing almost exactly the same thing. Here is the code anyway for rendering the sprite:

public void drawParticleSprite(GL myGL)
{

//  PARTICLE TEXTURE

myGL.glBindTexture(GL.GL_TEXTURE_2D,Texture_list.TEXTURE_PARTICLE);

//  ENABLE BLENDING

myGL.glEnable	(GL.GL_BLEND);
myGL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE );

//  PARTICLE SETTINGS

float 	particleMinSize 			= 1.0f;
float 	particleMaxSize 			= 32.0f;
float 	particleFadeDistance 		= 128.0f;
float[]	particleDistanceModifier 	= {1.0f,0.0f,0.01f};

// DISTANCE MODIFICATION

myGL.glPointParameterfvARB
	(
	GL.GL_POINT_DISTANCE_ATTENUATION_ARB,
	particleDistanceModifier
	);

// FADE THRESHOLD

myGL.glPointParameterfARB
	(
	GL.GL_POINT_FADE_THRESHOLD_SIZE,
	particleFadeDistance
	);

// MAX SIZE
	
myGL.glPointParameterfARB
	(
	GL.GL_POINT_SIZE_MAX_ARB,
	particleMaxSize
	);

// MIN SIZE

myGL.glPointParameterfARB
	(
	GL.GL_POINT_SIZE_MIN_ARB,
	particleMinSize
	);

// POINT SIZE
	
myGL.glPointSize(particleMaxSize);

// TEXTURE REPLACEMENT MODE

myGL.glTexEnvf( GL.GL_POINT_SPRITE_ARB, GL.GL_COORD_REPLACE_ARB, GL.GL_TRUE );

// DRAW THE PARTICLE

myGL.glEnable(GL.GL_POINT_SPRITE_ARB);

myGL.glBegin(GL.GL_POINTS);

myGL.glColor3f
	(
	this.particle_red,
	this.particle_blue,
	this.particle_green
	);
	
myGL.glVertex3f
	(
	this.position_x,
	this.position_y,
	this.position_z
	);
	
myGL.glEnd();	

// SHUTDOWN PARTICLE DRAWING

myGL.glDisable	(GL.GL_POINT_SPRITE_ARB);
myGL.glDisable	(GL.GL_BLEND);	

}




Can anyone see any reason why this is happening? Even a solution maybe? I'm totally at a loss here... It should also be noted that I'm using the java JOGL bindings for openGL- perhaps this has something to do with the problem... Here is my hardware also: P4 2.6GHZ 1GB RAM Radeon X800XT Any ideas? [Edited by - Darragh on May 15, 2005 5:55:27 PM]

Share this post


Link to post
Share on other sites
Advertisement
the above code aint the fastest but anyways i believe the main problem is ATI cards/drivers seem to have problems with pointsprites from what ive heard.
this is not a major problem since u shouldnt really be using pointsprites anyway ,for many reasons
eg no rotations, only one vertex in vertex/fragment programs,maximum size is limited on certain systems, the whole thing gets clipped if the center is off the screen etc

Share this post


Link to post
Share on other sites
I think doing a simple quad/two tris is fine for a particle system, though I would optimize with vertex arrays. You can still do most special effects, and you don't get the "let-downs" of point sprites.

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
the above code aint the fastest but anyways i believe the main problem is ATI cards/drivers seem to have problems with pointsprites from what ive heard.


the only problem I've known of with ATI cards and point sprites was a problem with it not resetting the texture coord mapping properly so it broke any texture mapped objects in the scene, however this was corrected around the middle of last year iirc (cat 4.7/4.8)

Share this post


Link to post
Share on other sites
i believe something was mentioned in the glsl forum at www.opengl.org
i was wrong, just searched it was enabling point_smooth that caused the problem
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=11;t=000736

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
i believe something was mentioned in the glsl forum at www.opengl.org
i was wrong, just searched it was enabling point_smooth that caused the problem
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=11;t=000736


Interesting, although I haven't enabled either point or line smooth in my application (perhaps it is on by default).

I don't know if this is related or not but i've experienced some horrific slowdown also in Star Wars: Knights of the old Republic 2 on one of the game's levels (Dantooine). This slowdown occurs for no reason, even though the rest of the game runs fine- and switching it to absolute minimum detail makes no difference. Now I've noticed several point sprite style objects (flocks of birds in the sky, the sun, smoke etc..) which all could be potential users of this extension. I have my suspicions that this may perhaps be the same problem I am experiencing, though I do not know for certain if they are using point sprites...

Nonetheless I now have managed to work my around the problem by using a simple vertex shader to billboard all of my particles so that they always face towards the camera. It does the job so I am happy enough now..

Thanks for all your feedback everybody.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!