What kinds of geometry are suitable for rendering tree branches

I am recently doing a project for rendering trees.
At my first thought, I chose a cylinder to represent one small branch. But I have seams as a result:
enter image description here

Then I look at the famous " SpeedTree " tree modeling software , it runs pretty smoothly between the two branches:

enter image description here
And I saw its main wireframes as below:

enter image description here

So I am wondering what geometry does SpeedTree use to represent branches ? It doesn't seem to be using a cylinder because the two faces are not parallel. And is it difficult to implement such geometry in Opengl?


Update:
I decided to use a spline as the main skeleton of a branch like SpeedTree, but which splines are best for this purpose?

+3


source to share


2 answers


A geometry shader can be used to create a tree mesh . You could "paint" each branch as GL_LINE_STRIP_ADJACENCY

, and then let the geometry shader generate a triangular stripe, which would be a quasi-cylinder for each branch segment.



The reason this approach helps with seams is because you can tweak where the edges of the cylindrical object are based on the angle / location / radius of the previous branch segment. It would also allow the radius of the cylinder to vary from end to end: as the branch becomes thinner, the transition will occur smoothly, instead of each segment quickly dropping in radius along the seams.

0


source


OpenGL simply displays groups of triangles. You must indicate how they connect. Most likely, SpeedTree calculates vertex positions without the help of any rendering API like OpenGL.

From the wireframe you posted, it looks like SpeedTree generates the centers and radius of tree branches at different positions along their length. Each of these data points appears to become a ring of n vertices, which is then connected to the previous control point with a strip of triangles.



For efficiency reasons SpeedTree probably packs all vertices into one VBO / IBO pair for rendering.

0


source







All Articles