dramatic fps drop when using transparent texture

Started by
38 comments, last by 21st Century Moose 11 years, 4 months ago
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.
[attachment=12710:fps 50.jpg]

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.
[attachment=12709:fps 30.jpg]

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!!!!!
[attachment=12708:fps 9.jpg]

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??
Advertisement
Okay i can say that i forgot to disable the GL_DEPTH_TEST and enable it at the end
[source lang="java"]glEnable(GL_BLEND)
glDisable(GL_DEPTH_TEST);

(draw stuff)

glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);[/source]

I have ordered the drawing of the walls, first the 2 walls from the back and at last the 2 walls from the front, and apparently it works.....
[attachment=12717:fps 26 front.jpg]

... if it wasnt by the fact that i can rotate around Y axis and this is what happens:
[attachment=12716:fps 25 rotation problem.jpg]

now my back walls when i rotate around vertical Y axis the grass appears because it is rendered AFTER the back walls.


1. - What can i do to solve this problem? I can't find the correct draw order.
2. - If i dont disable GL_DEPTH_TESTING i get the correct behaviour but i get 9 fps!!!!
3. - I dont have anymore 9 fps but 25fps, why is this if i had at the beginning without the walls 55 fps? Why such difference in performance?
What sort of graphics card are you using, and what sort of resolution and anti-aliasing setup is there?

The only explanation I can think of is that you're woefully fill rate bound, but I can't see how this scene could possibly cause that situation on a desktop graphics card (maybe an iPad1, but not anything else).

Plus a quick stupid question - you're not accidentally rendering the transparent quads multiple times are you?
Your fps will always be garbage in intermediate mode, try using a draw list or vbo.
In addition to the above, you shouldn't measure performance in FPS - measure in milliseconds or microseconds. FPS measurements can be deceptive; an increase from 55 FPS to 60 FPS (a gain of 1.5 ms a frame) is not the same increase as from 60 FPS to 65 FPS (a gain of 1.2 ms a frame).
Can you post the output of glGetString(GL_VENDOR) ? If it is Microsoft, then you are running on some kind of emulation and need to install the drivers for your graphics card.
Why are you using GL_POLYGON? you seem to be using just quads replacing GL_POLYGON with GL_QUADS should be faster. Also get rid of those extra glbegin/glend's in between each face.

Can you post the output of glGetString(GL_VENDOR) ? If it is Microsoft, then you are running on some kind of emulation and need to install the drivers for your graphics card.


Ahh that's it!! i got "microsoft corporation" for GL_VENDOR and "GDI generic" for GL_RENDERER query!!.

Now, im running the app in a laptop Dell XPS17 with integrated graphics card and an Nvidia GT555m card, maybe the problem is im not choosing the right graphics card for running the app.

Now how the heck i do that?


Why are you using GL_POLYGON? you seem to be using just quads replacing GL_POLYGON with GL_QUADS should be faster. Also get rid of those extra glbegin/glend's in between each face.

Yeah you re right ill change it, thanks.

Your fps will always be garbage in intermediate mode, try using a draw list or vbo.


Display lists seem interesting ill dig into that. This was my first attempt messing with OpenGL

Your fps will always be garbage in intermediate mode, try using a draw list or vbo.


No no no no no.

Immediate mode is slower than the other methods for sure, but it's not that much slower. You don't get such dramatic framerate drops from it, particularly with such a simple scene (as polycounts really ramp up it's expected, but with basic scenes it's performance is roughly equivalent to the others). Remember - Quake used immediate mode and didn't suffer overly much from it.

Please don't recommend VBOs (or display lists) as a "solution" every time you see immediate mode code - the real cause of the problem may very well be elsewhere (as, indeed, it was in this case).

I'm not advising that it's OK to use immediate mode here, by the way; I am recommending that you should properly diagnose the problem before recommending a solution, rather than jump to conclusions.


Now how the heck i do that?


You should have an option to select the GPU to use in your NVIDIA control panel. It's also worthwhile downloading updated drivers for your machine as the absence of a proper OpenGL driver for the integrated card suggests that you're on an OEM driver; visit http://www.nvidia.com/Download/index.aspx?lang=en-us to get a proper updated driver.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


[quote name='Kaze' timestamp='1355167357' post='5009164']
Your fps will always be garbage in intermediate mode, try using a draw list or vbo.


No no no no no.

Immediate mode is slower than the other methods for sure, but it's not that much slower. You don't get such dramatic framerate drops from it, particularly with such a simple scene (as polycounts really ramp up it's expected, but with basic scenes it's performance is roughly equivalent to the others). Remember - Quake used immediate mode and didn't suffer overly much from it.

Please don't recommend VBOs (or display lists) as a "solution" every time you see immediate mode code - the real cause of the problem may very well be elsewhere (as, indeed, it was in this case).

I'm not advising that it's OK to use immediate mode here, by the way; I am recommending that you should properly diagnose the problem before recommending a solution, rather than jump to conclusions.
[/quote]

Graphics card makers only optimize their hardware for vbo's these days so its not unreasonable to assume legacy functions can cause all sorts of performance problems.

This topic is closed to new replies.

Advertisement