Jump to content

  • Log In with Google      Sign In   
  • Create Account


fip

Member Since 25 Nov 2012
Offline Last Active Jan 23 2013 05:37 AM
-----

Topics I've Started

dramatic fps drop when using transparent texture

10 December 2012 - 11:27 AM

Hi all,
it's my first post here and i plan to be more participative from now on.
Ill start with a problem i have in one application i did in visual C+GLUT+OpenGL.
As the title states, i have a dramatic drop in frames per second when using a single BMP texture with transparency and i think maybe the problem is that im not using the texture mapping correctly.

Without the displaying of transparent texture i get 50 frames per second which for me is okay. You can notice that the grass has a texture and also the sharks have dotted texture as skin.
Attached File  fps 50.jpg   80.52KB   69 downloads

In the following picture i draw the water walls i want without transparency i get 30 frames per second (20 fps drop) i dont understand why but anyway 30 fps seems to me a good framerate.
Attached File  fps 30.jpg   92.25KB   63 downloads

Now in this third image i add transparency for the water walls you can see the drop to 9 fps!!! And this i can't understand as i know dealing with transparency is one of the hardest things for GPUs but common, im using only one texture in 4 quads!!!!!
Attached File  fps 9.jpg   81.12KB   58 downloads

Here is the code i use:

[source lang="cpp"]void PintarCortinillasAgua(TcajaHueca *recinto, Tcontrol * control){ glMatrixMode(GL_MODELVIEW); glPushMatrix(); if(control->texturas == VERDADERO) { glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, tex_agua.tex_Id); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_POLYGON);//plano Zmax glColor4f(1,1,1,0.4f); glTexCoord2f( 0, 0 + offset_agua); glVertex3f(recinto->min[X], recinto->min[Y], recinto->max[Z]); glTexCoord2f( 5, 0 + offset_agua); glVertex3f(recinto->max[X], recinto->min[Y], recinto->max[Z]); glTexCoord2f( 5, 2 + offset_agua); glVertex3f(recinto->max[X], recinto->max[Y], recinto->max[Z]); glTexCoord2f( 0, 2 + offset_agua); glVertex3f(recinto->min[X], recinto->max[Y], recinto->max[Z]); glEnd(); glBegin(GL_POLYGON); //plano Xmax glColor4f(1,1,1,0.4f); glTexCoord2f( 0, 0 + offset_agua); glVertex3f(recinto->max[X], recinto->min[Y], recinto->min[Z]); glTexCoord2f( 5, 0 + offset_agua); glVertex3f(recinto->max[X], recinto->min[Y], recinto->max[Z]); glTexCoord2f( 5, 2 + offset_agua); glVertex3f(recinto->max[X], recinto->max[Y], recinto->max[Z]); glTexCoord2f( 0, 2 + offset_agua); glVertex3f(recinto->max[X], recinto->max[Y], recinto->min[Z]); glEnd(); glBegin(GL_POLYGON); //plano Zmin glColor4f(1,1,1,0.4f); glTexCoord2f( 0, 0 + offset_agua); glVertex3f(recinto->min[X], recinto->min[Y], recinto->min[Z]); glTexCoord2f( 5, 0 + offset_agua); glVertex3f(recinto->max[X], recinto->min[Y], recinto->min[Z]); glTexCoord2f( 5, 2 + offset_agua); glVertex3f(recinto->max[X], recinto->max[Y], recinto->min[Z]); glTexCoord2f( 0, 2 + offset_agua); glVertex3f(recinto->min[X], recinto->max[Y], recinto->min[Z]); glEnd(); glBegin(GL_POLYGON); //plano Xmin glColor4f(1,1,1,0.4f); glTexCoord2f( 0, 0 + offset_agua); glVertex3f(recinto->min[X], recinto->min[Y], recinto->min[Z]); glTexCoord2f( 5, 0 + offset_agua); glVertex3f(recinto->min[X], recinto->min[Y], recinto->max[Z]); glTexCoord2f( 5, 2 + offset_agua); glVertex3f(recinto->min[X], recinto->max[Y], recinto->max[Z]); glTexCoord2f( 0, 2 + offset_agua); glVertex3f(recinto->min[X], recinto->max[Y], recinto->min[Z]); glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } glPopMatrix();}[/source]
The texture is a BMP image in REPEAT mode with blending set with glColor4f(1,1,1,0.4f).
Also i animate the texture mapping with an offset in the y direction to simulate falling water but this does not affect the fps drop.

What am i doing wrong??

PARTNERS