Blue Mars Tree Creation

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article


To create custom trees for Blue Mars use the following guidelines and instructions to ensure that your trees work well in the engine and keep the established look.

Installing the Leaf Generator

First unzip to the Scripts\startup folder in your 3DSMax Directory. To access it: go to utilities and click the MaxScript button (if you don't have one click the Image:utilitybuttons.jpgbutton, increase the number Total Buttons: then find MAXScript under MAX STANDARD in the Utilities List box on the left. Now drag the MAXScript Text onto your new blank button on the right. Click OK.) In the drop down box select Leaf Generator (if it's not there you put it in the wrong directory or need to restart Max, the alternative is to click Run Script, find where you copied it and run it). The Leaf Generator will help you create geometry for your canopy. We'll come back to it in a bit.

The things we'll be creating are:

  • A Trunk with branches
  • Leaves
  • Collisions
  • LOD's
  • A multisub that contains at least 3 materials
    • Physics Proxy
    • Trunk
    • Leaves
    • (optionally) Branches

Initial Setup

Now you need to create a good Trunk for your tree. NatFX can help you decide how your tree should look and even generate your trunk, you'll want to keep an eye on your tri count however as NatFX makes very expensive and inefficient trunks. Houdini makes really nice trunks, personally I prefer them, just make sure you export material coordinates to the .obj. However you create your trunk you want your LOD0 to be around 1000 triangles and 1 material ID.

If you use the NatFX method you can start by using a hybrid tree, choose the tree you want, assign a trunk deformer to get a nice real looking trunk, then click somewhere. Switch to the modify tab, select the + next to the plant object in the stack. That will give you access to the branches rollout, now select a few nice branches, convert them to 3D and delete the rest. This is where the poly count can quickly get out of hand. Deleting the leaves here will take a little work, the trick is to just keep the largest branches. Now you have a clean trunk with maybe 5-10 branches. You can duplicate this object and reduce the LOD level in the plant rollout to create trunks for your LOD's, I've had mixed results with this, it mostly works but sometimes you get anomalies. Now make a simple physics proxy, for Blue Mars we can use a simple box around the trunk. The collision proxy should encompass anything that goes below 2 meters.

Now create a plane with a few segments (I usually use 2X2), the size depends on what kind of tree you're making but I've found that bigger is usually better. Convert to editable poly, then deform the poly, it doesn't matter how but the more exaggerated the better it works I've found. I usually just pull the 4 corners up to make a cup. Now apply an Unwrap UVW modifier and edit it. A good guideline here is to tile your material between 1 and 4 times in both directions (total of 4-16 tiles). I've found that the more times I tile it the better, but try to keep your material in the correct proportions to the environment. The final step for this geometry is to decide where you want the normals to point for your tree, and rotate your object so that is the case. I generally make the outside of my cup the front of my geometry (normals point out from it), then rotate it so it looks like an average leaf would on the tree. Put it at the origin and reset transforms. Image:leafobject.jpg

  • A note on normals: The Leaves option of the vegetation shader will allow you to take advantage of back facing so that you can have variation to the back of your object. It determines this by assuming that you want the way the normals are facing to be the front and the opposite to be the back (sounds logical to me). What this means to us is that if your normals are all backward your tree will seem flat and improperly lit. If you get them right you'll have a very voluminous tree. In general I try to point my normals away from the trunk. If you are making a conical tree you'll want them to face parallel to the ground, orchard trees should be facing lots of different directions but mostly facing away from the branches, and tropical plants will want to be facing mostly up. We'll talk about these options more later, but for now just use these basic guidelines.

Textures Speaking of the material we have a few places to get it from. First we can use the textures created from NatFX. NatFX will save them out when you save your .max file (you'll need to change the directory where they are saved in the NatFX menu in Max) then you'll need to find them in explorer, convert them and their normal maps to CryTif and fix the MultiSub in max to only have 3 materials. Apply the first material to trunk, second to the leaves and set the 3rd up for the physics proxy (you can add another material for branches if you decide to have clip map branches).

Second you can make your textures from scratch, if you do try to start with a good picture of a branch of the type of tree you are making, if you don't have access to a picture you can paint it. The branch should be of the thinnest sort that the tree has, the one that the actual leaf stalks are attached to. The best ones are branches that have leaves all the way down them and the leaves don't overlap. This way you can create variation in the normal map. If your tree type tends to have clumps of trees you'll have to create different normals for each leaf in your normal map. If you have to do this (I don't envy you) then take your diffuse texture into Photoshop, create 2 layers on top of it. On one layer paint different values of red on random leaves. Make sure you are using pure red, no other colors mixed in, just in different values. Now on the other layer paint different values of green on random leaves. Again make sure its pure green. Now you want to set those layers to linear dodge (add). The idea here is just to get some variation, don't worry too much about getting too much detail in here since you won't see most leaves up close.

Leaf Generator Plugin

Now select your leaf object and run the Leaf Generator script (following the directions at Installing the Leaf Generator)


Now let's go through the options on this rollout.

  • Random Seed - the random number generator in max will output the same series of numbers every time you restart MAX (it works ok if you never exit and restart). So to get different results you need to put in a number here to work as the random seed. Keep it between 1-100, other values may work, but you really don't need them.
  • Instances - This is how many instances of your leaf object you want to create. You might want to play with this for your tree but think of it in terms of how it relates to how many times you tiled your UVs. if you tiled them 4 times 100 is probably fine for a big orchard tree. If you only have 1 tile on your leaf object you'll want this up somewhere around 400. Personally I find going with the bigger leaf object with multiple tiles and only 100 instances works out the best.
  • Tree Type - Right now there are 3 tree types which will duplicate your leaves in different ways. The rest of the options work differently for each type so I'll explain them separately.


    • Conical - This will basically make a cone of your leaves. This makes nice cypress or pine type trees. Might want to stick to the lower tiling smaller leaf objects for this one and crank it up instances to like 300. The following is a description of how to use the options for Conical.
      • Inner Radius - This will determine the interior radius of your cone, this will also be the size of the point at the top
      • Outer Radius - This is how large the largest part of the foliage will be. This will be the radius of the base of the cone.
      • Z Offset - The cone of leaves will be generated using the existing leaf object as the center point. So this number is HALF the total size of the foliage.
      • Rotation - These values are the axis to be rotated about. To keep the normals facing away from the trunk I used the rotation of the Z axis to determine XY position values. X and Y rotation values will just rotate your foliage in place on their respective axis (in most cases keep these 0-15, anything more can end up turning your normals wrong).


    • Orchard - This will make a big canopy of leaves over your tree shaped like a parachute, this is a little harder to control but once you get used to how to use some of the hidden functions you can make a large variety of trees, from banyan to oak to juniper. You can get very good results with very big leaf objects with lots of tiling on these trees, or if you are doing a special case (like a bonsai scene or really gnarly tree) you can use the smaller leaves and just dump hundreds of instances into it. This has some slightly different options.
      • Offsets - Again I used the leaf object as the center of the canopy so the offsets are all amount in any 1 direction to offset from the leaf object. There is one slightly hidden effect you can get with the orchard tree. If you move you leaf object from the origin you can change the radius of the curvature of the canopy. Basically this will create a parachute shaped canopy, perfect for tropical deciduous trees. If you want a tight dense canopy put the leaf object closer to the origin. I highly suggest you play around with this as you can get some really nice effects.
      • Rotation - Since the orchard type tries to make a ball of leaves we need a way to limit how much of the ball is used. Rotation is the way to do that. X and Y Rotation determine how many degrees in each direction the ball will be generated, Z determines how much variation our leaves will have in the direction they are facing. 0 means they will uniformly face away from the trunk, 180 means they will face in lots of different directions. Note that they will still tend toward facing away from the trunk so if you want them to face down or in, you should change the normals to face that direction.


    • Modified - This was a test that ended up working out pretty well for something, I just don't know what yet. Basically you just get a little more variation in the depth of the canopy. Note that this option will tend to create a box of the canopy.

Final Steps Depending on where you created your canopy (right on the origin or a little way up the tree or whatever), you may need to move it to where it belongs on the tree. You now have a bunch of objects in your scene you should be able to move them about. The leaf generator is a good tool to get you close, but don't get lazy, use your artistic eye to move leaves around so they seem to naturally follow branches etc... The point here is that you should move these guys around before you merge them all. Once your tree looks how you want select your trunk, then use the use attach list to attach all the leaves. Personally I leave my original leaf object separate in case I want to make more variations.

If you decide your tree could do with some dead branches or other ornaments just create another plane with your branch mapped on it and copy it around where it belongs. Then attach it to your trunk just like you did with the leaves.

A note on vertex colors here. I've found that for most tree types you want to leave all of the vertex colors white on your leaves. If you use branches you might want to change their vertex colors to black. White verts will act like leaves, black verts will act like branches.

If you didn't create any LOD's before you'll want to at least duplicate your tree and put an optimize modifier on it. Delete some of the interior leaves and branches. Whatever, but try to keep the same general shape and thickness. Name this tree to $lod1, link it to your original tree. You should make a few more of these, reducing the number of polies as much as possible without changing the overall shape of your tree, by $lod3 you should be at 300 polys. Don't worry about reducing the number of material ID's, just try to make the transition from one LOD to the next as seamless as possible. You really should work between the engine and max to get this right.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools