I have some problems getting my point-sprites behave like I want them to. Essentially I want to replace some quads by point-sprites.

The list of quads is defined by the mid-points and the edge-size (real quads, not rectangles), always facing the viewer. Now I’m trying to figure out a glPointParameter configuration so I can takes those two values for point-vertex and point-size, and get a “compatible” output using point-sprites. Of course taking perspective projection into account.

And that’s the problem: I can’t figure out what to feed into glPointParameter(GL_POINT_DISTANCE_ATTENUATION,…) to get that working.

Any hints are welcome. Thanks!

To get perfectly the same results you have with quads you’d better use vertex shader to change the point size.

yes, if I could. I’m on an iPod touch with OpenGL ES 1, so no shaders available.

For a proper projection, an object that is twice as far away appears half as big in each dimension, so what you want is the size in pixels being the quad size multiplied by some constant, divided by the view space distance:

size’ = size * C / D

C is the size in pixels of an object of size 1 at distance 1 in view space, and usually equals the (0,0) component of the projection matrix multiplied by half the screen width.

The formula used for the attenuated point size is

size’ = size / sqrt(a + b * D + c * D²)

with (a, b, c) being the point distance attenuation parameters. With a = b = 0 you get this:

size’ = size / (sqrt© * D)

So what’s left to do is to figure out the value of c.

C = 1 / sqrt©

c = 1 / C²

And, as mentioned above, C is the first component of the projection matrix multiplied by half the screen width.

Thanks a lot, Xmas! That’s exactly the explanation I was looking for!