Just wanted to show you what I ported to Unity in a day.
Two “trees”
I wrote the original code a couple of years ago in C++
and back then it took me at least a week to write and debug. It is hard for an old assembler-coder to admit this, but this GUI-scripting thingamabob is really cool.
I can think of lots of things to improve about the trees, but I just wanted to show you anyway.
Those look like good ol’ L-system trees which would be code generated… (am I right? do I win anything? :P) Good stuff, keep us posted on how things progress!
@Moldorma:
Yes generated from code. I make them in the Start() function by creating a new mesh. And I call mesh.Optimize() on them, which makes them run quite smoothly on my 1Ghz G4
@HiggyB:
I had not heard of L-trees before. But now that you mentioned them I googled them and found the math behind it to be very similar. I basically reinvented the same thing.
So maybe you win the honor of knowing more about the subject that me
L-systems are a great way of doing procedural elements like this and it’s awesome that you (Carsten) managed to stumble upon the same recipe on your own. Good stuff! And I definitely recommend that you share your thoughts with the Unitree folks as Targos hinted at, it would seem you have some good insight to offer given that you’re going through some similar exercises.
I was thinking that it would be really awesome to get a unity tree making script that let you create trees in the Unity editor and save as .obj for later use.
This would be a first step in achieving that goal.
@Targos:If by recipe, you mean the code, you can have what I have done so far. There are installation instructions in the header
It still needs lots of improvements before it is useful in practice, but you can play around with the controls in the inspector, to get a feel for how it works. Be careful about setting recursion level too high.
@HiggyB
Joachim Ante knows that I am doing this. It was his suggestion, that I ported my this to Unity. I believe he is one of the main persons behind UniTree?
Anyway I am not going to join the UniTree project right now, I may still improve the tree generator, but I also have to get back to my main project, which doesn’t really need large landscapes or trees. At least I haven’t thought of where they would fit in yet
Naturally we all understand that you have other commitments to handle first (your main project), we were just making the suggestion to join the UniTree project in case it struck your fancy. Either way, thanks for sharing your work!
I made an updated version with support for texturing. You can specify (to some degree) how the the texture in the first material should be mapped onto the tree. The second material is assumed to be something that looks like a leaf, and is simply mapped onto a little rectangle. As you can see from the example, I have room for improvement in the texture drawing department.
New version of script included.
About the wiki - well when I get less lazy, i might figure out how to do that. (No, don’t tell me, I just need to get less lazy)
That looks really cool! I had in my head a long time ago an idea that one could create a system that lets you create a structure for the tree eg. I first make a procedural trunk and specify parameters for it, then I add on small alpha channel branches on points specified before (the ends of solid geometry branches) then I add leaf polygons onto those alpha mapped branches (probably the alpha mapped branches are prefabs with transform children for positions and rotations at which the leaves should be instantiated) then the whole thing is cleaned up and combined into one mesh.
Not asking you to make such a system but just putting forth the idea I had. This looks like a great start as far as procedural tree generation !
The idea is basically, generate trunks, generate branches, then it places leaves based on a prefab you provide.
It isn’t perfect, it takes about 5-10 trees before you get one you like, but it allows you to redo any phase, or start over, and its pretty fast.
Here is an oak tree I made in about 30 minutes (most of that time was remaking iterations of trees)
I’m not sure if any of this code would be useful, but maybe it is worth looking at. Sadly I can’t take credit for this amazing script, but maybe you can improve on it
Here is the venerable L-System script (in a Blend file) to which Higgy and Yoggy and others have referred: http://greenpriest.com/lsystem.blend Brian, you might find this useful, if you ever find yourself w/out Maya at hand But hopefully Carsten will adapt some of the techniques expand his awesome script: stem and branch curvature and spin, multipoint leaves, overall LOD, etc… It’s python, I think, but still.
I can’t wait to see how this thing evolves. The Unitree goals LOD and animation might be easier to accomplish using this script as a basis; i.e. gen multiple versions w/ different recursion values, and use culling or something to show the right one, depending on distance. I’m also wonder if there’s a way to use the techniques in the grass script w/ these procedural prefabs, to “paint” a distribution of them.