GLSL performance with per-pixel bump mapping = slow?

another test: when I perform 2 simplistic operations in my shaders:

gl_Position = ftransform();

in the VS and

gl_FragColor = vec4(1.0,0.0,0.0,1.0);

in the FS, I get 3x more FPS than with the full-bump thing (this means 45FPS instead of 15) BUT it’s still 3x less than with fixed function (140-150FPS), so my bump shader needs optimization, but I thing there is something else.

OK my mistake, I just figured out that I was using 2 shaders (one for blinn-phong PPL-specular illumination, the other for bump mapping) and when I disable the blinn one, I get 30-33 FPS with the bump shader (not much optimized, so I think I can gain some more FPS). Maybe I should test one at a time…

Originally posted by hardtop

OK my mistake, I just figured out that I was using 2 shaders (one for blinn-phong PPL-specular illumination, the other for bump mapping) and when I disable the blinn one, I get 30-33 FPS with the bump shader (not much optimized, so I think I can gain some more FPS). Maybe I should test one at a time…

So does that mean that your problem has been solved?

Originally posted by hardtop
[b]
another test: when I perform 2 simplistic operations in my shaders:

code:

gl_Position = ftransform();

in the VS and

code:

gl_FragColor = vec4(1.0,0.0,0.0,1.0);

in the FS, I get 3x more FPS than with the full-bump thing (this means 45FPS instead of 15) BUT it’s still 3x less than with fixed function (140-150FPS), so my bump shader needs optimization, but I thing there is something else.
[/b]

Something is definitely wrong! The compiler should ignore your shader code totally and the entire shader will compile to just one MOV instruction and you should be getting a gazillion FPS on that!

actually the problem is the FPS loss, which in this cas has been partially solved: I’m using 2 shaders, and I think the other one (the blinn/phong illumination one) is being applied to a much larger polygon count. By disabling the blinn shader, my bump one gives me 35 FPS instead of 15. But 35 in regard to 150 is still not satisfactory.

As you said: even with just one instuction in the VS and one in the FS, I get a noticeable perf hit (50/150 FPS) which must not be normal.

I’m not through this issue yet… :frowning: next thing I’ll test is to put a polygon count into my app, sothat I can know on how many polygons my shader is currently being applied.

OK I added polygon count, here are the results:

When I tested the app and gave you FPS, it was in a situation where my BSP tree culling was displaying around 6000 tris. :eek: It seems really weird to suffer such a slowdown with such a small polygon count :confused:

To summarize:


fixed function pipeline - 6000 tris - 150 FPS
bump mapping + blinn - 6000 tris - 15 FPS
bump mapping alone - 6000 tris - 35 FPS
one instr. shader - 6000 tris - 50 FPS

by “one instr. shader”, I mean the shader where I perform just the transformation in the VS and the color to red in the FS.

I have always had better luck with tiny shaders, getting even better performance than the fixed function pipeline. So your performance numbers seem strange to me. Is it possible you are binding the shader too many times? How often do you call glUseProgramObject? That command can hurt performance if you do it a lot.

Indeed I change shaders (from blinn to bump) many times a frame -actually, according to the “user-defined material” currently rendered-.

I tried setting the shader (just blinn for the test) only once for all, and there I got a 25-30% increase. But it’s still 25 FPS instead of 150. And I need to change shaders at least once per frame… I know I’ll have to re-order the way I draw my faces sothat I’ll have to change shaders only once per “material” type, but even then, 25 FPS is still not enough. :eek:

by the way… I know this is a little bit off-topic, but I know we have a friend from Pakistan here. I just wanted to make sure you were all right, after that terrible earthquake which shaked Pakistan and Islamabad.

The damage has been collosal, but things seem to be working out after a lot of support from international and local community. It really is great to see amazing people, selflessly helping others who they don’t know and don’t even share their ideology with. Hats off for them!

OK I finally sorted things out:

[ul][li] I performed a test when choosing which shader to use: now if a shader is already active, I don’t reactivate it… obvious, but I never though to do it.[] I now calculate the attenuation denominator in the VS.[] I put some small-sized, frequently-accessed function as inline[*] I display the polygon count, I usually have 5000-6000 tris per frame[/ul][/li]To render my scene, I switch between 2 shaders: one for the blinn illumination, and one for the bump-mapping.
Without shaders, I had about 140 FPS.
With my shaders and the modifications I made based on your advice, I now have 80 FPS.

Definately a performance increase! I guess it’s normal to get half the FPS when performing per-pixel calculations instead of per-vertex. I know I’ll have to perform much more optimization, but it’s already encouraging. One last note: I perform the tests with a single texture, at 800x600 resolution, windowed-mode. With 1024x768 fullscreen, the results are almost the same.

Thanks a LOT for your help, folks!

HardTop

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.