Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing a 3D tree structure in WebGL

I am working on drawing large directed acyclic graphs in WebGL using the gwt-g3d library as per the technique shown here: http://www-graphics.stanford.edu/papers/h3/

At this point, I have a simple two-level graph rendering:

enter image description here

Performance is terrible -- it takes about 1.5-2 seconds to render this thing. I'm not an OpenGL expert, so here is the general approach I am taking. Maybe somebody can point out some optimizations that will get this rendering quicker.

enter image description here

I am astonished how long it takes to push the MODELVIEW matrix and buffers to the graphics card. This is where the lion's share of the time is wasted. Should I instead be doing MODELVIEW transformations in the vertex shader?

This leads me to believe that manipulating the MODELVIEW matrix and pushing it once for each node shouldn't be a bad practice, but the timings don't lie:

https://gamedev.stackexchange.com/questions/27042/translate-the-modelview-matrix-or-change-vertex-coordinates

like image 360
Jonathan Schneider Avatar asked Nov 16 '12 15:11

Jonathan Schneider


1 Answers

Group nodes in larger chunks instead of rendering them separately. Do background caching of all geometry with applied transformations that most likely will not be modified and store it in one buffer and render in one call.

Another solution: Store nodes(box + line) in one buffer(You can store more than you need at current time) and their transformations in texture. apply transformations in vertex shader based on node index(texture coordinates) It should be faster drastically faster.

To test support use this site. I have MAX_VERTEX_TEXTURE_IMAGE_UNITS | 4

Best solution will be Geometry Instancing but it currently isn't supported in WebGL.

like image 145
JAre Avatar answered Oct 14 '22 01:10

JAre