• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[3D Art] Creating procedural trees using Blender

In this tutorial, i will be teaching you how to make awesome tree models for Warcraft, procedurally using the Sapling Add-On in Blender! This is an exceptionally fast way of making trees which also supports many different tree shapes. Using the "Normal Edit" modifier, we can also some very fancy smoothing, which can make even round planes look smooth! Add-Ons like Saplings are one of the great advantages of Blender - for 3ds Max, equivalent tools would likely cost a lot of money, but in Blender we get them for free!

For this tutorial, we will need the following tools:

To install the MDL exporter, follow the instructions on the github page. Make sure to restart Blender and then activate it in the Add-On tab in the user settings.

Next, we need to enable the Sapling Tree Gen plugin. It is included in Blender by default, and all you have to do is search for it in the Add-On tab and enable it. While you are in the user settings menu, you might also want to change the primary mouse key to LMB in the Input tab - this makes everything more intuitive to work with. Finally, save your user settings.

Treegen_01_Activate_Plugin.jpg

Next, we need a texture for our tree. Personally, i use a mix of googling for textures and editing in Photoshop. I am including a texture in this thread which you can use, called TreeTexture.tga.

Click and drag one of the corners to split the viewport into two. Press Shift+F10 with the mouse inside the window to change it into an image viewer. Press "Open" and select your texture to view it.

Treegen_021_Split_Window.jpg

Next, we want to delete all the stuff from the startup scene - to this, press A once so that everything is selected, then press X and click to confirm. Now we will create the basis for our branch. Press SHIFT+A inside the 3D viewport and go to Mesh>Plane to create a plane. You can also use the "Add" menu which is marked with an arrow in the image below.

Treegen_02_Add_Plane.jpg

The plane should appear at the center of the viewport. In the bottom left panel (where it says "delete globally" in the above image), you should get a little window where you can change the size (radius) of the plane. Notice that this panel will disappear when you deselect the plane! With the default export settings, 2m corresponds to the height of a regular Wc3 unit, so you might want the plane to be around 0.2-0.3m, since this will be part of a branch on the tree. You also want to check "Generate UVs", since this will create UV coordinates for you.

Next, press TAB to enter edit mode. In the image viewport you created, you will now see the UVs of your plane laid out - make sure to select these and scale/move them so that they fit on top of one of the branches in the texture.

Here is how you control the viewport camera:

Scroll = Zoom
Hold MMB + Drag = Rotate
SHIFT + MMB + Drag = Move
NUMPAD 1, NUMPAD 3, and NUMPAD 7 = Front, Right, and Top camera view respectively.
NUMPAD 5 = toggle orthogonal mode, you should try this out and you will notice the difference.

You use the following hotkeys to edit things in Blender (most work in both the image editor and the 3D viewport):

G = Grab, use this to move something by moving your mouse. You can press X, Y, and Z afterwards to lock movement to any of these axes.
R = Rotate. In the 3D Viewport, things will rotate relative to your camera, so you can use the numpad keys as described above to rotate along these axes.
S = Scale. Scales relative to the center of the selection. There are also options to scale relative to other things, but we won't get into that here. Again, use X, Y, Z keys to lock axis.
L = Island select. This lets you select everything that is connected to the surface your mouse is over.
B = Box select. This lets you draw a selection box.
CTRL+RMB = Lets you paint a selection boundary using your mouse.
A = Toggle selection. Use this to either deselect everything, or select everything. You will be using this a lot.
SHIFT+D = Duplicate. In edit mode, this will duplicate your current selected geometry - move your mouse to move it. Click once to place it at that position.

Use SHIFT+D to duplicate the plane, rotate and move it using R and G, and place it in a ball-like shape like you see in the image below. When you are done, hit TAB again to exit edit mode. Create a material inside the properties menu and name it something appropriate. In your image viewer window, you can now use the little menu marked in the image to swap to the "Node Editor" (you can also use the hotkey SHIFT+F3), which lets you edit how your material will be displayed in Blender. We won't really be rendering too much, but linking the texture to our material here lets us view how the texture looks on the mesh. First though, we need to create an "image texture" node, which you do by pressing SHIFT+A inside the node editor like you see in the image. Click to place the node, then select the texture from the drop-down menu (or using "open"). Drag the color output from the texture node into the yellow input of the Diffuse node. Finally, press ALT+Z to swap to "textured" render mode. You should now see the texture on top of the model inside the 3D viewport.

Treegen_07_Add_Material.jpg

Another thing you want to make sure of is that the branches originate from the pivot of our branch object. The pivot is the place where the arrows appear when the object is selected. This is the point where the "ball" will be attached to the branches of the tree, so it can't be in the center of our ball. You can enter edit mode and move the whole mesh to fix this. Now that we can see our texture, you might also want to make sure that the root of the branch in the texture looks like it is coming out of the right place. Rotate some of the planes if you need to. You can also change the UVs of some of the planes so that they are mapped to the second branch, for some variation.

Next, we can use a special trick to make our branch look round. Go to the "Modifiers" tab in the properties window, and press the "Add Modifier" menu and select "Normal Edit" - you will find it in the first column. Make sure to press the "Smooth" button and to check the "Auto Smooth" box as the image shows. Press "Apply" on the modifier once you are done with all these steps.

Treegen_08_Smoothing.jpg

Now, we are finally ready to use the Sapling plugin! Press SHIFT+A to open the "Add" menu, go to "Curve, and press "Sapling Tree Gen". Watch the magic happen.

Treegen_09_Create_Sapling.jpg

Again, make sure to not deselect your new tree, or you will no longer be able to edit it!!!
In the same place where you edited your plane's properties, you can now edit those of your tree. Be aware that there are a few submenus here (you will start off in the "Geometry" submenu), and there are many sliders to pull to get a nice result. See the image below for some tips.

Treegen_10_Geometry.jpg

To add some leaves to our tree, press where it says "Geometry" and change it to "Leaves". Change "Leaf Shape" to DupliVerts, and "Leaf Object" to our object (should be named "Plane" unless you changed it). Your tree will suddenly be covered in copies of our ball! What DupliVerts does is that it copies the leaves onto ALL vertices of the model, which sounds much, but in this case it is just the outer control point of the underlying curve objects. Regardless, we want to decrease the leaf count to 1, to get 1 per branch. Depending on the settings you chose, you might want to use "DupliFaces" instead of "DupliVerts", or have more leaves. You can also play around with leaf distribution.

Note: In order for the leaves to show, the "Show Leaves" box must be checked!

Treegen_12_Leaves.jpg

Let's do a test render with what we have! Press SHIFT+Z to toggle preview render (or use the menu marked in the below image). You can use ALT+Z to swap back to texture view when you're done.

Play around some with the other settings - for instance, "Branch Growth" lets you control in which direction the branches grow, and how much they reach towards the sun. "Branch Splitting" can let you split the base into two (increase split angle to make this more pronounced), and you can also control in which direction each consecutive split is made. "Levels" controls how many times each branch splits, though you want to keep this at 2 to keep polycount manageable.

Note: in hindsight, the resolution of these branches were a bit high for Warcraft. This could have easily been fixed by changing the "curve resolution" in the Geometry tab.

Treegen_13_Preview.jpg

You may notice that our trunk appears white. That is because it has no material yet! Select the trunk and go to the material menu - use the dropdown menu with the red ball (next to "new material") and select your tree material. When you feel absolutely done with the sapling settings, select the leaves and press ALT+C>Mesh from Curve/Meta/Surf/Text. The leaves will now become a mesh, and you will no longer be able to edit your tree parameters.

Select the trunk and press ALT+C again, choosing the same option, to convert it to a mesh too. You can now also remove the original branch we used for the DupliVerts generation.

Treegen_16_Trunk_To_Mesh.jpg

To make the texture appear on our trunk, press TAB to open edit mode. If all faces aren't already selected, press A. If you don't already have the image viewer open in the right window, open it to show our UVs. Sapling generates branch UVs horizontally, and our trunk is vertical, so start by rotating it 90 degrees. Scale the UVs and place them over the trunk. You can also stack the UVs on top of themselves by selecting a part and pressing Y to separate it, then G to move it down. This lets you make the texture tile with itself, making it look more detailed.

Treegen_17_2_Unwrap_Trunk.jpg

In order to make some simple animations to our tree, we are going to need bones. Bones are basically handles we use to control how larger parts of the geometry move. The MDL exporter uses empty objects as bones (it also supports Armatures, but this is more advanced). To create one, hit SHIFT+A again, go to "Empty", and select "Plain Axes".

Treegen_18_Create_Bone.jpg

Press SHIFT+D to duplicate the bone and move it up a bit to where you want the tree to later be cut. Name the bottom bone "Bone_Root", and the top one "Bone_Tree", or whatever fits your fancy - as long as it starts with "Bone_". Next, select first the topmost bone, then shift-select the bottom one, and press CTRL+P>Object to parent the top one to the bottom. It will now follow it wherever it moves.

Treegen_19_Parent_Bones.jpg

To make our "Death" animation, where the tree is felled, we need to separate about half of the tree. Hit TAB with the trunk selected, use B to box select, and select the top of the mesh. See the image for complete instructions.
Treegen_20_Separate_Top.jpg

Since we separated the mesh into two, there will now be holes where the cut should be. To fix this, select the vertices of each cut and press F to fill with a polygon, and U to unwrap it, so that you can map it to the "cut" area in the texture. Follow the instructions in the below image.

Treegen_21_Fill_Cut.jpg

Treegen_23_Unwrap_Stump.jpg

Notice how the meshes need to be parented to the correct bones. If you were to move the bones now, the mesh would follow! We are now ready to animate. Drag open a small window at the bottom of your 3D viewport and make it into a timeline viewer. Follow the instructions in the below image.

Treegen_24_Add_Keyframes.jpg

Select both bones, make sure that the timeline cursor is at frame 1 (or 0 also works), and press I to insert a keyframe. Select "Rotation". We need this for our swaying animation. You also need a key at the last frame of the animation, since the tree will be swinging back to its original position.

Next, put the timeline cursor in the middle of the two keyframes, rotate the tree a little bit to the side, and press I to add another rotation key there. ONLY do this for the root bone!

Treegen_25_Animate_Movement.jpg

Now you have a swaying animation! One could call it quits there, but we already made the stump and rigged the model, so we might as well make a death sequence. Just follow the instructions below.

Treegen_26_Animate_Death.jpg

Once you are happy with your animation, the only thing left is to set up our material for export. Go to the material editor, and look at the MDL Material Settings. Press the '+' icon to create a new layer, and set the texture path to "TreeTexture.blp". Set filter mode to transparent. We don't want our material to be two-sided if we can help it, because backfaces of polygons appear dark. One neat trick to make the leaves look good from a distance is to add an extra material layer with the same texture path, but with filter mode set to "Blend". Try it!

go to File>Export>Warcraft MDL. Use the MDLX converter to convert it to MDX, and use Warcraft 3 Viewer to convert the .tga file to .blp. Import the files into Wc3 and make sure that the path in the editor import window matches what you put in the MDL material editor.

Congratulations, you now have an awesome animated tree!
 

Attachments

  • Treegen_14_Duplicates.jpg
    Treegen_14_Duplicates.jpg
    221.3 KB · Views: 166
  • Treegen_15_Make_Single_User.jpg
    Treegen_15_Make_Single_User.jpg
    297.2 KB · Views: 170
  • Treegen_17_Mark_Seams.jpg
    Treegen_17_Mark_Seams.jpg
    241.9 KB · Views: 194
  • Treegen_22_Unwrap_Stump.jpg
    Treegen_22_Unwrap_Stump.jpg
    595 KB · Views: 242
  • TreeTexture.tga
    256 KB · Views: 123
  • Treegen_27_Material_Edit.jpg
    Treegen_27_Material_Edit.jpg
    60.3 KB · Views: 173
Last edited:
Top