Link to home
Start Free TrialLog in
Avatar of DBTechnique
DBTechnique

asked on

Displaying lot of points - How ?

Hello experts !
I have an OpenGL view in which I would like to display points.
So far, this is something I can handle ;)

For every point, I have its coordinates (X ; Y ; Z) and a value (unsigned char).
I have a color array giving the link between one value and a color.
For example, 255 is red, 0 is blue, and so on...
The problem is that since I would like that dynamically, I can change a threshold to "hide/show" the points depending on their corresponding value and as I will have lot of points to display (maximum 5 billions but in a standard usage, maybe 1~2 millions), I am worried that the performance will be pretty bad.

So I am now looking for the best way to handle this.
I am interested in the VBO. I have read that it will allow some good performance and also that I can modify the buffer as I want without recalculating it from scratch (as with display list).

1) Do you have other ideas ?
2) With VBO I don't understand how it is possible to select the color of the points in the buffers. How to do that ?

Thanks in advance !
Avatar of Member_2_5069294
Member_2_5069294

1~2 million is a lot of points, no matter how you render them.

VBO's will help because you can store the VBO in graphics memory, saving the time taken to transfer the data across the graphics bus. Also like vertex array and display lists they save the time the program would spend calling gl functions to draw the points.

However, that may not help in this case.  When you modify the VBO, the changes have to be sent across the bus.  There is no real gain if you modify the VBO frequenly.  Also you have so many points that they might not fit in graphics memory anyway.  You might not be able to create VBO's that big, or they may be kept in system memory and transferred across the bus when needed.  I'm certain that 5 billion points is beyond the capacity of any graphics hardware I know of.

The buffer object can be set to stream mode, and that will probably be fast.  However GL gives no guarantee about the speed, only that it will work, as stated here Buffer Object Streaming Reference.  I imagine this is especially true with large VBOs.

You could group the points into 256 VBO's and render only the one that should be visible.  Though in much the same way, you could put them all in a vertex array (sorted by color) and then render parts of it.

Not drawing points that are outside of the view frustrum might be useful.  Assuming the program allows the user to focus on a area, rather than the whole cloud.

Can you use shaders in the context of this program?  The reason I ask is that shaders can modify the colour of the points as they are rendered.  This moves a lot of the update work to the GPU.  If you can use shaders, the problem is sending the vertex data to the card as fast as possible, the color problem is fixed.

When it gets to the 5 billions points range, could you clump them together somehow?  If you have 1000 points in almost the same place, you could probably render that as one slightly larger point.  I'd guess that even with a high resolution display, it's unlikely those 1000 points will be discernable.
Avatar of DBTechnique

ASKER

Hi Satsumo.
Thank you really much for this long and detailed reply :)

I don't have any limitations regarding the tools that can be used.
Hence I am totaly open-minded regarding this question.
Let me give more information about the context around the needed implementation.

I have a 3D space (XYZ).
X and Y have a maximum range of 2500.0 millimeters.
Z has a maximum range of 800.0 millimeters.
Then from a bunch of file, i will read the points' data.
As I said in the first post, the data contain the X/Y/Z coordinates, and an 8 bits value for each points.
From a GUI attached to the display, I have tools and parameters to select which data to display (for example, select one region, set a threshold on the value, ...).
The limitation I have is that the step on XYZ is "minimum" one millimeter.
As you said, anyway there is no need to display everything since the screen doesn't have this kind of resolution.

Regarding the shaders, I am not sure to understand your explanation.
But maybe we can discuss about it later,

So I would like to split my previous question to two different questions.
One is about the way to reduce the number of points and the second would to about how to use the VBO with the previous constraint of huge amount of points theoretically solved with a solution for the first question.

1) How to reduce the number of points to be displayed ?
At first, I can define a bigger step. But I guess that even with this, the points' quantity can still be huge.
Then I can define the step depending on the screen resolution and the zoom applied in the view.
Is there a standard way to implement that on OpenGL ?

2) How to use VBO for this implementation ?
I have posted the same question on StackOverflow
http://stackoverflow.com/questions/5871113/opengl-a-way-to-display-lot-of-points-dynamically/5874553#5874553

The answer that interested me the most was from Kvark :

"Put everything into one VBO. Draw it as an array of points: glDrawArrays(GL_POINTS,0,num). Calculate alpha in a pixel shader (using threshold passed as uniform).
If you want to change a small subset of points - you can map a sub-range of the VBO. If you need to update large parts frequently - you can use Transform Feedback to utilize GPU."

I read some tutorial about the VBO but I am confused about how to use it regarding the colors.
Do you have any code snippet or information about this ?
ASKER CERTIFIED SOLUTION
Avatar of Member_2_5069294
Member_2_5069294

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of ikework
ikework
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial