Point rendering, odd GL limitations

· by Steve · Read in about 2 min · (393 Words)

I’ve just been adding some additional point rendering options to OGRE, specifically to allow hardware point sprites as well as more control over point sizes and their attenuation. Firstly, there was the problem that D3D and GL differ on how exactly to specify point sizes, but some creative mapping has resolved that (I decided on pixel size when attenuation is disabled, and viewport-relative size when it’s enabled, which maps nicely to both 3D sprites and to normal points).

The last problem I’ve been banging my head against was a discrepancy between the size of sprites when attenuation is enabled. In GL the sprites just looked far too small compared to what I was getting in D3D. Some considerable time checking the attenuation mapping, point size, min / max sizes etc later I discovered that even with attenuation and point sprites disabled I couldn’t get GL’s point size to increase above a certain value on screen. A quick check of the docs shows that GL_POINT_SIZE_MAX is initialised to the maximum value the implementation supports - and in my case it’s 63. Now, that might seem reasonable for ordinary points, but because GL uses the exact same approach to points and point sprites, it also means that in GL I can never have a point sprite bigger than 63 pixels on screen, which limits the usefulness of point sprites in GL.

What I don’t understand is why this is the case. In D3D there is no limit at all to the point size, and on the same card I can happily render very large point sprites (and regular points, for that matter), so it’s not a hardware issue. GL seems to arbitrarily clamp my point sizes below what it thinks the hardware can perform, meaning only a subset of billboard / particle system setups can benefit from it. So far I haven’t found any significant discussion on the internet about this - people just seem to accept the GL limit without discussion, despite it not being there on D3D. It’s most annoying. 🙁

I guess in practice this isn’t too bad, since the primary use is particle systems where there are a lot of small objects. But is does mean I can’t generalise BillboardSet to use hardware point sprites in all cases where appropriate, since some billboards will need to exceed this clamping size. Hrm.