Hi everyone! This is my first post, so feel free to “educate” me if I break some sort of etiquette.
I have (among other things) in my application a VBO that contains around 12000 textured triangles. The VBO is rendered without culling (for a reason) and without lighting and I am using the fixed pipeline. The problem is - not a big surprise here - performance: with only 12000 triangles the frame rate should be extremely high, but I only get results between 80 FPS (when camera is facing away from VBO) to 21 FPS (worst-case scenario when camera is viewing the VBO).
First thing I suspected was that am I fill-rate-bound: after all the there are LOTS of overlapping triangles which is not helped by the fact that the texture which is used for the triangles contain lots of holes (alpha channel). I reduced the resolution of the application window from 800x600 to 800x60 and my framerate went to 200+ FPS as I expected.
Not knowing what to do as I can not replace the texture nor the geometry, I tried using a simplified shader to render the VBO just to see how fast it would go with an extremely simplified pipeline. I expected it to be very slow, but to my surprise I got over 60 FPS constantly (only relevant parts of the dummy shader in included here):
void main()
{
// just doing some random stuff with the pixels
if(mod(texture_coordinate.x*100.0,20.0)<5.0){
gl_FragColor=vec4(
texture_coordinate.x,
texture_coordinate.y,
1.0,
1.0
);
} else {
// "simulates" the holes in the texture
discard;
}
}
As that was fast enough for me, the next thing I did was to run the scene with this shader:
void main()
{
vec4 color=texture2D(texture, texture_coordinate);
if(texture_coordinate.y<0.8){
gl_FragColor=vec4(1.0);
} else {
discard;
}
}
I got identical performance (over 60 FPS) but that’s not surprising because I guess that the unused “color=textured2D” gets optimized away. So next thing I tested was:
void main()
{
vec4 color=texture2D(texture, texture_coordinate);
if(texture_coordinate.y<0.8){
gl_FragColor=vec4(color.r,1.0,1.0,1.0);
} else {
discard;
}
}
…and got 21 FPS.
So, texture lookups seem to be slow. If I remove texture lookups (with a simplified shader or using fixed pipeline without TEXTURE_2D) the frame rate skyrockets. As soon as I enable texturing (using only one texture, no multitextring) VBO performs poorly. What could I do to increase the performance? The texture used by VBO is 1024x1024 GL_BGRA,GL_UNSIGNED_BYTE texture with the following:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
I am rendering to FBO but I guess that doesn’t make any difference. My guess is that there’s a really simple basic thingy I’ve missed (perhaps not even texture related)… I posted this to the beginners-section for a reason
Most probably you need to know more, so feel free to ask. Thanks in advance!