performance with setShaderAuto


I have a decent framerate of around 60 Hz. I use 1 Spotlight with per-vertex shading. I would really like to use per-pixel shading, but when I switch setShaderAuto on, framerate drops on and off to less than 10Hz in some databases. For a few seconds framerate is 40+ and then it drops to < 10Hz for a second etc. when I move through the database, even with the Spotlight switched off.

I use an NVidia GTX 770 and an i7 processor, so it’s not related to the quality of the hardware. I can’t find a way to solve that. Could it be related to switches in render states or using multple camera’s ?

If you have a lot of objects in your scene then the fixed-function pipeline may be a bit faster, but also it may be that the shader generator needs to generate a shader every time a new node/model is seen on screen for the first time - that takes a few ms, also the driver (or the cg framework?) needs to compile the shader that takes yet another few ms.

Or maybe it’s just the number of meshes/objects you have?

If you connect to pstats, what timings does it show?

It’s probably the number of meshes. So what I did now, is to setShaderAuto only for the floor nodes, so all road and road markings etc that are on the floor. It’s especially these that don’t look good with per vertex shading because the polygons are often not small enough. For all other meshes I use per vertex shading for the Spotlight. And now the framerate is good, so I think this is solved now.