Jump to content
  • Advertisement
Sign in to follow this  
Pirosan

OpenGL Large triangle/ slow fillrate?

This topic is 4671 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

Hiya, I have an opengl program rendering 800 or so particles with alpha blending. The particles are actually small triangles, the texture is rendered within and clamped so that the corners are not shown (if that doesnt make sense don't worry). Basically i am rendering a ton of triangles and if the triangles are about .1 by .1 by .1 in size the framerate is wonderful, about 100-150. If they are enlarged (for smoke, fire etc) or if you are very very close to them so it fills a lot of the screen the framerate drops down to around 30 fps. I have tried turning off blending as well as textures and those both dont change anything performance wise (or at least nothing noticable). Also i'm in read-only mode for the z buffer I think its just the fill rate for the polygons, how can i fix this? Could it be i'm in some wierd rendering mode? Thanks

Share this post


Link to post
Share on other sites
Advertisement
its normal behaviour
use lower quality textures eg tex compression etc or dont draw the particles if they get above a certain size

Share this post


Link to post
Share on other sites
Again, even without any texturing at all, just white triangles, its slow.

Is opengl really that slow to fill triangles? is there a way to fix this?

as for sorting the polygons, it shouldnt really matter, if it never writes to the z buffer. Its just adding color to the screen

Share this post


Link to post
Share on other sites
Quote:
Original post by Pirosan
Again, even without any texturing at all, just white triangles, its slow.

Is opengl really that slow to fill triangles? is there a way to fix this?

No, your video card really is that slow. OpenGL doesn't have much to do with it.

As to actually being helpful, how about posting some code? I can't imagine that you'd be drawing a particle system with glBegin/End but how are we to know?

Typically, the root problem is overdraw. When you get close to the particle system and a single particle is near screen-size, rasterizing the screen 800 times (for each particle) is just too much for any vid card. Try using LOD for the system, draw less particles as the camera approaches for any system that uses unusually large particles.

Share this post


Link to post
Share on other sites
I do use glBegin and glEnd to render my triangles as particles.

My basic code is as follows... i set up the correct modes and calculate the theta (the direction this particular set of polygons is pointing. i do this once per bunch, i'm not expecting a certain set of particles to fly too far apart) in BillboardBegin:


cameraLocation[0] = camX;

cameraLocation[1] = camY;

cameraLocation[2] = camZ;



objectCenter[0] = objPosX;

objectCenter[1] = objPosY;

objectCenter[2] = objPosZ;

float[] distObject = new float[]{(camX - objPosX),(camY - objPosY), (camZ- objPosZ)};



GL11.glDisable(GL11.GL_LIGHTING);

GL11.glEnable(GL11.GL_BLEND);

GL11.glBlendFunc (GL11.GL_SRC_ALPHA, GL11.GL_ONE);



GL11.glDepthMask(false);





theta = (float) Math.atan(distObject[2] / distObject[0]);

System.out.println("the answer is:" + theta);



currCos = (float)(-theta * 180 / 3.14) + 90;

GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);

GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);



I render the polygons in DrawBillboard. I have a function which accesses an array of positions and sizes, it calls this method for each particle that is drawn:


GL11.glPushMatrix();

GL11.glTranslatef(p.x, p.y, p.z);

GL11.glRotatef(currCos,0f,1f,0f);


GL11.glBegin(GL11.GL_TRIANGLE_STRIP);


GL11.glTexCoord2f(-.5f,0);

GL11.glColor4f(p.color.r,p.color.g,p.color.b,p.color.a);

GL11.glVertex3f(-1.5f*p.size,-.5f*p.size,0);



GL11.glTexCoord2f(1.5f,0);

GL11.glVertex3f(1.5f*p.size,-.5f*p.size,0);

GL11.glTexCoord2f(0.5f,2);

GL11.glVertex3f(0*p.size,1.5f*p.size,0);


GL11.glEnd();
GL11.glPopMatrix();


You can sumise what i put for BillboardEnd, basically setting lighting to true, blending to false and so on.

Please be aware this is not C++, so the equasions and/or methods may look slightly different. this is Java, but it handles opengl the same way. I know i have done my calculations correctly, don't worry about that

Share this post


Link to post
Share on other sites
maybe this is stupid suggestion. but your debug print code could be really slow if it's put in the wrong place.

Share this post


Link to post
Share on other sites
not a stupid suggestion at all, thanks im sure that will speed something up :)

but it still slows down, is there a way to better optimize, or perhalps set in a more hardware rendering mode?

Share this post


Link to post
Share on other sites
You simply can't draw a ton of huge triangles, create an insane amount of overdraw and waste a ton of fillrate and just expect there to be magical switch to make it go fast. That's like asking for the magical words to make a cripple win olympic gold for 100m. If you can't find a way to prevent each pixel being set a few dozen times that's pretty much it. You can try using your own minimalistic fragment shader, but beyond that there simply is no glQuadrupleFillrate(GL_TRUE) function.

Share this post


Link to post
Share on other sites
That responce really didnt get me anywhere, i was being serious. I understand what you are saying, there is no fix it function or mode, i was just fishing around for advice. I don't know if opengl is taking full advantage of my graphics card or not.

In direct X there is a way to set rendering to software or hardware, is there one in opengl?

Share this post


Link to post
Share on other sites
The only way I know of would be either deinstalling the graphic card drivers (or installing those that came with Windows) or deliberately using a pixel format that isn't supported.

There was also something you can try. Use shaders or programs and let the fragment shader/program do nothing but output a constant color. That will pretty much tell you your upper limit.

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!