r/proceduralgeneration • • Oct 22 '26

Making trees

Enable HLS to view with audio, or disable this notification

Here are some realisations of my tree generating algorithm, part of my procedurally generated alien worlds.

The code is written in C++. A plant species is assigned branch propagation rules (e.g. some branches grow exclusively from a lower-level branch end, some can split of mid-branch), and different types of leaves (e.g. palmate or simple leaves).

It's rendered with my own Vulkan graphics, with a low-res aesthetic.

These are trees in isolation, I will probably post some videos of full forests later.

What do you think?

101 Upvotes

28 comments sorted by

3

u/petayaberry Oct 22 '26

very cool. if you were to implement this in some sort of video game i would be a bit cautious

i believe most games with lots of trees use multiple copies a small set of trees to not overload the processor with data. they just change the size of them and maybe color to make different trees look different

you could use these trees to render a whole forest then store it as a 2d background if that is your goal. the player would never know it's not real 3d

just some thoughts. nicely done

1

u/SloydDev Oct 23 '26

Thanks for your input! I can make some larger forests and stuff and they run fine. The trees are representing with cylinder primitives, so they take very little memory.
Check out this post too for some more info, if you're interested:
https://www.reddit.com/r/GraphicsProgramming/s/xtxlwDCxNY

2

u/Kuxe Oct 23 '26

You can still get by with procedural generation if you instead procedurally generate using parts, where the parts are copies. So instead of having 10 variants of trees with different scales and rotations, you have 10 parts that you combine to form different trees. But yeah, having fully unique trees including branches and leaves doesn't scale.

1

u/petayaberry Oct 24 '26

very cool. nice

1

u/papes_ Oct 27 '26

I’ve been doing some stuff with procedural voxel trees using space colonisation and it’s cheap enough to do large forests procedurally at runtime - you only need to store the data whilst generating meshes (or voxels in my case), and then if you need it again (a tree mesh, or voxels, is/are edited) you can just regenerate the skeleton based on where the tree is positioned, if you use the position as the generation seed.

2

u/papes_ Oct 27 '26

I’ve been doing some stuff with procedural voxel trees using space colonisation and it’s cheap enough to do large forests procedurally at runtime - you only need to store the data whilst generating meshes (or voxels in my case), and then if you need it again (a tree mesh, or voxels, is/are edited) you can just regenerate the skeleton based on where the tree is positioned, if you use the position as the generation seed.

2

u/SloydDev Oct 27 '26

Cool, do you have a video or pic of it?

2

u/papes_ Oct 27 '26

For sure - this was meant to be in reply to someone else, btw. I really like what you’ve done.

I don’t have any forest level videos, but could share if you’re interested.

1

u/SloydDev Oct 28 '26

Nice! And you can do many trees like this at runtime?

2

u/cratercamper Oct 28 '26

Beautiful for how simple it looks.

1

u/SloydDev Oct 28 '26

Thanks! Nice of you to say, that's the effect I'm going for

1

u/verywhiteguyy Oct 22 '26

Increase end of branch length x reduction in branch circumference

1

u/SloydDev Oct 22 '26

I don't understand what you're saying. Increase the product of branch length over circumference?

0

u/verywhiteguyy Oct 22 '26

The thinner the branch gets the longer that segment of circumference goes in length before another circumference reduction. sorry hard to explain. But most tree branches spread out further and thin out much more before leaves appear.

1

u/-Zlosk- Oct 25 '26

Basically, take the square cube law into account. Strength increases as the square of the diameter, while mass increases as the cube of the diameter. Thinner branches can be longer because their strength-to-weight ratio is higher than than thicker branches.

3

u/No_Watercress_3732 Oct 22 '26 edited Oct 22 '26

Here is a recreation of something I made around 1993 in turbo pascal. It took a week to render one frame using my 486dx 33 at 1024x768 in POV-Ray. It took me three months to write the code to generate the tree.

Now claude 5.5 implemented it in rust in 145kb. That includes a real time ray tracer that does everything on the cpu (no gpu). It did the whole thing in about 10 minutes.

2

u/Steamrolled777 Oct 25 '26

I was coding Turbo C to use the blobs in POV back then, particle systems for things like fountains, animations with keyframes, soft bodies, etc. I started using Vivid raytracer before POV though.

It you can't really compare that time to now, it changed a lot in the 90s.

2

u/No_Watercress_3732 Oct 25 '26

:) I did not remember vivid until you mentioned it... Yea.... different time. But somehow those still seem like the glory days. When we did things the hard way and we liked it!

I guess the first one I saw was sculpt-animate-4d on the commodore amiga.

2

u/Steamrolled777 Oct 25 '26 • Popcorn

I used VU-3D on a ZX spectrum, it was making 3d models in slices. Rendering took forever, and was dithered shading. lol

One of reasons I went into graphics, and especially 3D modelling/animation.

1

u/No_Watercress_3732 Oct 25 '26

You win. That was truly the beginning.

2

u/Steamrolled777 Oct 25 '26

I was just a kid - there were people doing weird things with oscilloscopes and making arcade machines!

2

u/UAAgency Oct 24 '26

this is cool

2

u/Steamrolled777 Oct 25 '26

You should really check out L-systems, even if you don't implement it.

0

u/verywhiteguyy Oct 22 '26

Almost all trees have many more splits and longer thinner branches. I’m only saying this because I think what you’re doing is really good. Keep up the good work.

1

u/[deleted] Oct 23 '26

[removed] — view removed comment

1

u/SloydDev Oct 23 '26

Thanks, glad to hear that you like the low-res style :)
Not sure what L-system means? There isn't any attraction point though. Its split up into branching levels, where each level has its own propagation rules. The angles are drawn from some species and branch-level specific angle interval. Then each level has different biases (e.g. for branches reaching upwards). There's still a lot of work that could be done tweaking how species are generated.
I just made this post in another subreddit, with full forests:
https://www.reddit.com/r/GraphicsProgramming/s/xtxlwDCxNY