Modeling a Tree in Blender

jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Modeling a Tree in Blender

Post by jlv »

Image
How to make happy little trees and keep your polygon budget happy too!

=== Making the Tree ===
First, make a leaf.
Image

Switch to object mode.

Make a linked duplicate of the leaf. (Object > Duplicate Linked)
You don't want to move the new leaf yet so press ESC to leave it where it is.

Move the duplicate to layer 2. (Object > Move to Layer...)
Switch to layer 2.

Make a bunch of linked duplicates of the leaf.
Scatter them along the Y axis.
Image

Create a cube. (Spacebar > Add > Mesh > Cube)
Rename the cube object to "twig", switch to edit mode and stretch/scale it to fit the leaves.
Switch back to object mode.
Image

Select the twig and all the leaves.
Add them to a new group. (Object > Group > Add to New Group)
In the "Object and Links" panel, change the group name to "twig".
Image

Switch to layer 3.
Duplicate the twig group. (Spacebar > Add > Group > twig)
Move/rotate it.
Add more until you have a good branch.
Select every other twig and move them to layer 4.
Image

Create a cube.
Rename the cube object to "branch" and stretch/scale it to form the main branch
This is going to be shared by both branch planes, so you shouldn't make the twig to branch connections with this object.
Make a linked duplicate and move it to layer 4.
Image

Create a cube. Use this mesh to connect the main branch to the bases of the twigs.
Switch to layer 4 and do the same thing for the other half of the branch.
Image

Switch to layer 3.
Rotate everything around the Y axis by -25 degrees.
Image
Switch to layer 4 and rotate everything around the Y axis by +25 degrees.

Shift+click layers 3 and 4 so they are both visible.
Select everything.
Add it to a new group. (Object > Group > Add to New Group)
In the "Object and Links" panel, change the group name to "branch".
Image

Switch to layer 5.
Add an cylinder and make a tree limb out of it.
Image
Duplicate the branch group. (Spacebar > Add > Group > branch)
Move/rotate it.
Add more until you have a good tree limb.
Select everything.
Add it to a new group. (Object > Group > Add to New Group)
In the "Object and Links" panel, change the group name to "limb".
Image

Switch to layer 6.
Add an cylinder and make the trunk out of it.
Add the limbs and move/rotate them into position. (Spacebar > Add > Group > branch)
If things get too slow, try changing draw type to "Bounding Box".
If it's still too slow, go to layer 5 and remove the branches from their group. (Object > Group > Remove from All Groups)
You should now have a tree that uses a few million faces.
Image

=== Adding the Low Detail Planes ===

Switch to layer 13.
Create a 2 sided plane.
Switch back to object mode, and make layer 3 visible. (Shift+click)
Switch back to edit mode.
Rotate the plane around the Y axis by -25.
Resize it so it fits the branch on layer 3.
Repeat in layer 14 for the branch on layer 4.
Image

Switch to layer 16.
Create a 1 sided plane and fit it to the complete tree on layer 6.
Image

UV unwrap everything but the leaf.
Image

=== Setting Up the Materials ===

Switch to layer 1 and select the leaf.
Select the shading panel.
Change the color to green.
Image

Switch to layer 2 and select the twig.
Add a new material, name it "textured".
Under "Links and Pipeline", enable "ZTransp".
Under "Material", enable "Shadeless".
Set the color to black (col, spec and mir), alpha to 0.
Image

Add a new texture, call it "colormap".
Under "Map Input", choose "UV".
Under "Map To", choose "Color" and "Alpha".
Image
Switch to the textures panel.
Set the texture type to "Image" and open/select your color texture.

Add another texture, call it "normalmap".
Under "Map Input", choose "UV".
Under "Map To", deselect "Color" and select "Nor".
Set the slider labeled "Nor" to 1.0.
Image
Switch to the textures panel.
Set the texture type to "Image" and open/select your normal map texture.
Under "Map Image" select "Normal Map".
Image

Add another texture, call it "x".
In the textures panel, set the texture type to "Blend".
Under "Map Input", choose "Nor".
Disable the y and z inputs.
Under "Map To", choose "Color" and "Neg".
Set the color to red.
Set the texture blending mode to "Add".
Image

Add another texture, call it "y".
In the textures panel, set the texture type to "Blend".
Under "Map Input", choose "Nor".
Set the x input to y.
Disable the x and z inputs.
Under "Map To", choose "Color" and "Neg".
Set the color to green.
Set the texture blending mode to "Add".
Image

Add another texture, call it "z".
In the textures panel, set the texture type to "Blend".
Under "Map Input", choose "Nor".
Set the x input to z.
Disable the x and y inputs.
Under "Map To", choose "Color".
Set the color to blue.
Set the texture blending mode to "Add".
Image

Now assign that material to all objects except the leaf and the duplicated objects/groups.

You now have all the required objects and materials set up.

=== Converting the Branches to Planes ===
Switch to layer 13.
Select the branch plane choose "Object > Group > Add to Existing Group > branch".
Do the the same in layer 14.
Switch to layer 3, select all and then "Object > Group > Remove from All Groups".
If you go to layer 6 the tree should now have planes instead of branches.

=== Setting Up the Camera ===
Switch to layer 1.
Select the camera and move it to layer 6 and then switch to layer 6.
In the Scene/Format panel, set SizeX and SizeY to fit the billboard area in your texture.
Set the format to PNG and RGBA.
In the Editing/Camera panel, set the camera to Orthographic mode.
Set the scale to the height of the billboard plane.
Bring up the tranform properties window. (Object > Transform Properties)
Set LocX to 0.
Set LocY to -30.
Set LocZ to 1/2 the height of your billboard plane.
Set RotX to 90.
Set RotY to 0.
Set RotZ to 0.
If you did it right, the dotted line that shows the camera border should match the billboard plane.
Image

This is a good time to save.
The next steps are either destructive or create extra junk you don't want saved.

=== Baking the Branch Planes ===
Switch to layer 3.
Select everything.
Choose "Object > Duplicate".
Move the duplicated objects to layer 13.
Switch to layer 13.
Select everything and choose "Object > Clear/Apply > Make Duplicates Real".
Deselect everything and choose "Select > Select All by Type > Empty".
Delete the empties you just selected. (Object > Delete)
Now select everything and make the branch plane the active object.

Switch to edit mode, select all faces and switch to your color texture in the UV/Image Editor.
Switch to the materials panel and uncheck the x, y and z textures.
Image

Switch to the render panel.
Under the Bake tab -
Set the bake type to "Textures".
Enable "Selected to Active".
Set "Bias" to 10.
Disable "Clear".
Now click "Bake" and it should bake the textures for those branch planes.
Image
Repeat the process in layers 4/14.

While in edit mode, select all faces and switch to your normals texture in the UV/Image Editor.
In the Bake tab -
Set the bake type to "Normals".
Set the normal space to "Tangent".
Click "Bake" and it should bake the normals.
Repeat the process for the other branch plane.
Image

=== Fixing Up the Normals ===

If you like, you can now use a paint program to extend the edges of the normal map into the transparent areas of the map. This will keep the flat background from bleeding into the leaves in lower detail mipmaps, which will flatten out the shading.
Image

=== Rendering the Tree Billboard ===
In the Scene/Render panel, make sure "Key" is on.
Image
Click the render button to render the color texture.
Save the rendered image.
In the "textured" material, check the X, Y and Z textures.
Select the "colormap" texture and under "Map To", deselect "Col".
Click the render button to render the normals texture.
Save the rendered image.

Copy the billboard renders into your textures.

=== Exporting the Models ===
We've been working with the Z axis as the up vector instead of the Y
axis like MX Sim uses, so you'll need to rotate 90 degrees around the
X axis before you export.
Export tree billboard like any other model.
For the full detail tree, select everything and make the duplicates real. (Object > Clear/Apply > Make Duplicates Real)
Deselect all and then select the empty objects. (Select > Select All by Type > Empty)
Delete the empty objects. (Object > Delete)
Now select the tree limbs and trunk, with the trunk as the active object.
Join the objects. (Object > Join Objects)
The tree is now ready to export.

=== Smoothing the LOD Transistion ===
To reduce popping you might want to make some extra LOD's to smooth out the billboard to 3d transition.
If your tree is named "tree.jm" and the billboard "tree_lod8.jm",
you want some LOD's just under 8 that progressively have their Z coords flattened out, but keep the original normal values.
To do that, you can use this one liner in a Linux shell, or you could use a spreadsheet to do it.

Code: Select all

(for ((i=1;i<=9;i++)) do awk '{ if (NF == 8) { print $1, $2, $3 * (1-'$i'*.1), $4, $5, $6, $7, $8 } else print}' <tree.jm >tree_lod7.$((50+i*5)).jm ; done)
Which produces these LOD's:

tree.jm
tree_lod7.55.jm
tree_lod7.60.jm
tree_lod7.65.jm
tree_lod7.70.jm
tree_lod7.75.jm
tree_lod7.80.jm
tree_lod7.85.jm
tree_lod7.90.jm
tree_lod7.95.jm
tree_lod8.jm

Download the blend file and textures/exported models here.

A couple of things you might want to try now:
- Make the tree go to planes at the twig level instead of the branch level. This will look better but use a lot of extra geometry.
- Use more than one material for the leaves to vary the color more.

If there's anything in here that's hard to understand, let me know and I'll try to improve it.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
HUN.HOUSE.MAFFIA
Posts: 115
Joined: Tue Aug 24, 2010 5:07 pm

Re: Modeling a Tree in Blender

Post by HUN.HOUSE.MAFFIA »

its harder than mathematics... :')
Image
ShackAttack12
Posts: 3131
Joined: Fri May 09, 2008 1:51 am
Location: San Diego, CA

Re: Modeling a Tree in Blender

Post by ShackAttack12 »

LMFAO at the first picture!!!! :lol: :lol: :lol: :lol:
ShackAttack12
| 2010 Supercross Champ | 2011 Supercross Champ | 2019 Supercross Champ |
MX196
Posts: 2263
Joined: Thu Feb 11, 2010 1:02 am
Team: Privateer

Re: Modeling a Tree in Blender

Post by MX196 »

I love the first picture.

How long did this take JLV?
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Modeling a Tree in Blender

Post by jlv »

Too long! It's real easy to spend hours in Blender trying to figure out what's canceling out the button you just pressed.
ShackAttack12 wrote:LMFAO at the first picture!!!! :lol: :lol: :lol: :lol:
Bob Ross had mad skillz!
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
ShackAttack12
Posts: 3131
Joined: Fri May 09, 2008 1:51 am
Location: San Diego, CA

Re: Modeling a Tree in Blender

Post by ShackAttack12 »

My sister and i used to watch his show every morning before elementary school when we were little. :lol:

ShackAttack12
| 2010 Supercross Champ | 2011 Supercross Champ | 2019 Supercross Champ |
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Modeling a Tree in Blender

Post by DJ99X »

Finally put this tutorial to use. Cheers JLV :D

Image
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Modeling a Tree in Blender

Post by jlv »

I'm glad someone finally used the longest tutorial ever! It looks like you did a nice job of mixing up the branch orientations. In the tutorial tree I didn't mix it up enough in the upper branches and wound up having the low detail normal map be dominated by one color there.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Modeling a Tree in Blender

Post by DJ99X »

Just a note to anyone who does this in Blender 2.6. Turn 'Color Management' off under Shading in the Render menu. Makes everything too bright, which screws up the normal map. Took me ages to figure out what was causing that problem
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Modeling a Tree in Blender

Post by jlv »

2.6 has the normals flipped too. (Or not flipped depending on how you look at it.)
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Modeling a Tree in Blender

Post by DJ99X »

I just found a problem which I didn't notice with my last trees. Blender renders double-sided, which is why my LODs have never matched up neatly. Is there a way to render single sided?
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Modeling a Tree in Blender

Post by jlv »

I'm sure there used to be an option for that but I can't find it anywhere now on 2.62.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Modeling a Tree in Blender

Post by DJ99X »

Well I solved that problem. It was so simple too. I just did a border select of all the visible faces from the camera angle, then hid the faces that weren't selected. Now the normal map actually matches up with the model better
yzmxer608
Posts: 15352
Joined: Mon Dec 29, 2008 4:30 am
Team: SYS
Location: Wisconsin, U.S.A

Re: Modeling a Tree in Blender

Post by yzmxer608 »

jlv wrote: === Fixing Up the Normals ===

If you like, you can now use a paint program to extend the edges of the normal map into the transparent areas of the map. This will keep the flat background from bleeding into the leaves in lower detail mipmaps, which will flatten out the shading.
Image
How did you do this step? I can't seem to figure out a way to expand the last layer of pixels outward.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.
jlv
Site Admin
Posts: 14912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Modeling a Tree in Blender

Post by jlv »

I used value propagate in Gimp. Not sure what the Photoshop equivalent is.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Post Reply