开发者

OpenGL - A way to display lot of points dynamically

I am providing a question regarding a subject that I am now working on.

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...

I want to display those points in an OpenGL view. I want to use a threshold value so that depending on it, I can modify the transparency value of a color depending on the value of one point. I want also that the performance doesn't go bad even if I have a lot of points (5 billions in the worst case but 1~2 millions in a standard case).

I am now looking for the effective way to handle this. I am interested in the VBO. I have read that it will allow some good performance and also t开发者_运维百科hat I can modify the buffer as I want without recalculating it from scratch (as with display list). So that I can solve the threshold issue. However, doing this on a million points dynamically will provide some heavy calculations (at least a pretty bad for loop), no ?

I am opened to any suggestions and I would like to discuss about any of your ideas !


Trying to display a billion points or more is generally (forgive the pun) pointless.

Even an extremely high resolution screen has only a few million pixels. Nothing you can do will get it to display more points than that.

As such, your first step is almost undoubtedly to figure out a way to restrict your display to a number of points that's at least halfway reasonable. OpenGL can (and will) oblige if you ask it to display more, but your monitor won't and neither will mine or much or anybody else's.


Not directly related to the OpenGL part of your question, but if you are looking at rendering massive point clouds you might want to read up on space partitioning hierarchies such as octrees to keep performance in check.


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.


If you need to simulate something for the updates, you should consider using CUDA or OpenCL to run the update completely on the GPU. This will give you the best performance. Otherwise, you can use a single VBO and update it once per frame from the CPU. If this gets too slow, you could try multiple buffers and distribute the updates across several frames.

For the threshold, you should use a shader uniform variable instead of modifying the vertex buffer. This allows you to set a value per-frame which can be then combined with the data from the vertex buffer (for instance, you set a float minVal; and every vertex with some attribute less than minVal gets discarded in the geometry shader.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜