1. ## make point-sprites quad compatible

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!

2. ## Re: make point-sprites quad compatible

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

3. ## Re: make point-sprites quad compatible

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

4. ## Re: make point-sprites quad compatible

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(c) * D)

So what's left to do is to figure out the value of c.
C = 1 / sqrt(c)
c = 1 / Cē

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

5. ## Re: make point-sprites quad compatible

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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•