Is fog supposed to be this expensive?

I’m rendering 250000 points - just raw unindexed vertices, no colour-per-vertex or anything else.
Without fog I get >100fps
With simple linear fog, I get <65fps

This is on a geforce3 ti500 with latest detonators.

Does this sound reasonable? It doesn’t to me - surely it’s just a single mult by a scalar that it’s already has to calculate anyway (z distance)…

Are you sure it’s the transform? It could be the final combiner running slower, perhaps? Try CullFace( FRONT_AND_BACK ) and see if you’re raster bound.

So you’re getting 25 Million points per second without fog, that sounds very high, what CPU do you have?

My particle system peaks at 9 Million points per second. Fog makes no difference. I am only sending vertices (no colour) and I’m certain I am not fill rate limited or CPU limited. I only have AGP2x though, that could account for our difference in performance.

If I make my app fill rate limited by increasing the point size, fog still makes no difference.

Do you want to send me your app? So I can try it out on my Geforce 4600? or I can send you mine?

[This message has been edited by Adrian (edited 07-14-2002).]

Actually I get 27 million verts per second (without fog) - I just increased the point count to 300,000 and get 90fps.
I’m writing a screensaver, so because Win32 is controlling when my draw function gets called, so I can never get above 100hz (it seems to call it 100 times a second).
jwatte, they’re points! there’s not much to fill!
Adrian, bear in mind I’m not touching the point data at all, after initialisation - this probably accounts for me getting better throughput. I’m using VAR too.
My CPU is an Athlon 1.3ghz. AGP is 4x, I think (I hope, more like).

Originally posted by jwatte:
Are you sure it’s the transform? It could be the final combiner running slower, perhaps? Try CullFace( FRONT_AND_BACK ) and see if you’re raster bound.

CullFace( FRONT_AND_BACK ) won’t prevent points or lines from being drawn.

BTW, the AGP speed is not relevant anyway, as I’ve allocated video memory with VAR, not AGP.

Another BTW, using AGP memory and VAR with 300,000 points, I get 86fps. Using video memory I get 90fps. Just in case anyones interested.

[This message has been edited by knackered (edited 07-14-2002).]

Maybe you could take the VAR stuff out (temporarily), see if you get the same kind of performance drop with fog. If you do, get someone with an ATI to try it out and see if they get the same kind of performance drop with fog. That will tell you whether its a var thing, driver specific thing or just ‘the way it is’.

I can’t say for certain what you are seeing, but it doesn’t sound that surprising to me. I think the math is a bit more than you had expected.

Think of the math as if you had done it in a vertex shader, as it ought to give you a rough idea of how much the ops cost.

I believe that fog was mentioned as just a single scalar multiply. Assuming that the points drawn with out fog are transform only, this only requires 4 dot products. A single additional multiply is an extra 20%. That said, I believe that linear fog takes at least 2 ops. ( a subtract and a multiply) This is 50% more instructions, and is getting pretty close to your reported perf. Also, remember that fog is based on eye distance, so it might need to do an extra dot product to get the eye z coord. Finally, remember that GL actually recomends using eye-space distance rather than eye z for fog, so it might be doing even more work.

All in all, I don’t think the drop you are reporting is unreasonable at all.


Mmm, yes that does sound reasonable. I’d have to dot the object space z component with the row of the modelview matrix to convert it into eye space before putting it into the fog coord output.

You could also try changeing the fog computation formula (eye plane vs eye radial) with the NV_fog_distance extension.

If switching between the two has a noticeable impact, then you’ll know you are definetely transform-bound, otherwise… mystery anew.

Yes, I also experienced that fog meight cost much. When I switched between radial and linear fog my framerate fell from 210 fps downto 180. Without any fog at all I’ve around 230. Well, if your points are drawn “randomly” there is not much you can optimize. I’ve got boundingboxes with radius and centerpoint information, so I do a rough check, if it’s fogged or not and if not disable the fog, which increased the FPS at least a bit again.