Sign in to follow this  

ARB_point_sprite & ARB_point_parameters

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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);
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f);

The point sprite always has the GL_POINT_SIZE_MIN size: 2.0

Share this post


Link to post
Share on other sites
Quote:
Original post by Dizzy_exe
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.


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by xinvar
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...


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 this post


Link to post
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 size
for-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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this