# ARB_point_sprite & ARB_point_parameters

This topic is 4875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I wanted to visualize my particel system using ARB_point_sprites. This works quite fine, except for the fact, that the point has always the same size, given by glPointSize, no matter what distance the partical has to the camera/eye. To implement distance attenuation I'm trying to use ARB_point_parameters but somehow I can't make the point change it's size. Are there any known problems with those two exentsions working together? Am I doing something wrong? Any hints, tutorials, explanations? Thank you, ZMaster

##### Share on other sites
how did you set the GL_DISTANCE_ATTENUATION_EXT parameter?

##### Share on other sites
For testing I set it up like this:

float fAtten[4] = { 0.0f, 0.0f, 0.01f };
glPointParameterfARB(GL_POINT_SIZE_MIN, 2.0f);
glPointParameterfARB(GL_POINT_SIZE_MAX, 60.0f);
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, fAtten);

The point sprite always has the GL_POINT_SIZE_MIN size: 2.0

##### Share on other sites
Try to replace float fAtten[4] = { 0.0f, 0.0f, 0.01f };
with float fAtten[4] = { 0.01f, 0.01f, 0.01f }; and see if there is a difference.

##### Share on other sites
Quote:
 Original post by Dizzy_exeTry to replace float fAtten[4] = { 0.0f, 0.0f, 0.01f };with float fAtten[4] = { 0.01f, 0.01f, 0.01f }; and see if there is a difference.

Thank you, but unfortunatelly this didn't change anything. The sprite still stays same size...

##### Share on other sites
In this paper: Hardware Accelerated Point Rendering of Isosurfaces ( http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=1786 ) Bærentzen introduced a method that changes the point size based on the distance from the point to the viewer. You might want to use his program (the last page on the paper). His method definitely should work. If not, maybe you could post your program so that people could see if there's anything wrong with the code. Good luck.

##### Share on other sites
Quote:
 Original post by xinvarIn this paper: Hardware Accelerated Point Rendering of Isosurfaces ( http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=1786 ) Bærentzen introduced a method that changes the point size based on the distance from the point to the viewer...

Thanks alot! It helped. Now it works, and it works pretty well. The paper also showed the exact calculations to do perspecitve correct distance attenuation which safed me a great amount of time!

There's another small problem I ran into. Since I may have different sizes for each particle I have to call a pair of glBegin and glEnd with each particle. This might eat the performance boost I gain with rendering the particles as hardware point sprites. I can't use vertex arrays either, because of the same problem. Is there another way to do a fast rendering?

##### Share on other sites
A few options come to mind for best peformance. Fastest option would probably be to use Vertex Arrays for rendering, and vertex attribute array to store each point's scale. Then in a vertex program you can do the scaling. This might not be feasible, though, as I haven't tried vertex programs with point sprites before. I think second best option would be to sort your particles by size, then follow this pseudo-code:

Sort particles by sizefor-each particle:  if (this particle size is different then last particle size):    glEnd();  // be sure not to call end if it hasn't begun (i.e. for first particle)    glPointSize(newsize);    glBegin();  glVertex3f(p.x, p.y, p.z);

This way, given an arbitrary size array of different sized particles, it would use the absolute least number of glBegins/Ends/PointSizes as possible.

Edit: Some problems with the example, like it won't call glEnd() after the last particle, but I hope it's at least enough to inspire you :)

##### Share on other sites
ZMaster, yeah that's a very neat paper. Is the point size totally like random? If there's an equation for the pointsize, maybe we can figure out one way to incooperate it into glPointParameter.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 14
• 46
• 22
• ### Forum Statistics

• Total Topics
634054
• Total Posts
3015274
×