Thursday, May 31, 2007

Creating Poly Trees in Maya

This is a tutorial/walkthrough on how I created the trees in the VivoCity infographic. I'm using Maya 8.5. Users of Maya 7 should still be able to follow the steps. f you want, you can choose to download Maya 8.5 Personal Learning Edition.

Here are the main lesson points:
- Finding out the goodies inside the Visor
- Quick ambient occlusion
- Compositing the renders


Below's the exact tree I've pulled out from the scene. The leaves are rectangular polygon planes. Since the trees are going to be very small when printed (think less than a centimetre square), this level of detail is enough.

03_kaki_tree_tutorial_merged

1. You need to create a new Maya scene. File->New Scene

2. There are two ways to get the brush needed to create the tree. The first is shown in the figure below. Change the menu set to Rendering (F6). From the menu, choose Paint Effects->Get Brush... That will open up the Visor Window.

The alternative way to access the Visor is from the menu, Windows->General Editors->Visor

04a_getbrush

3. With the Visor window open, you should see a lot of folders on the left. Each folder contains a set of related brushes. Choose the folder named 'tree'. All the tree brushes will load. Choose the keyakiPark.mel brush. Notice the mouse cursor change into a pencil.

05_visor

4. Draw short stroke on the grid. A curve will appear, with the tree 'growing' out form the curve. Press 5 to show the shaded mode, as shown in the figure below.

I've also turned on the Heads Up Display (Display->Heads Up Display->Poly Count). The display will show stuff like number of polygon faces, vertices, etc on the scene. The first column is for the total scene as from the view port. The second column for the selected object. The current face count at 27094 is simply too high. In fact, Maya has become a bit sluggish.

Do a test render. You should notice actual leave textures mapped onto the polygons. If you intend to put a lot of trees in your scene, you must reduce the number of polygon faces. If not, your render will cause Maya to run out of memory and crash Maya.

07_painteffects_rendered

06_shadedtree

Optional step: I've also created a resolution gate to frame the scene. That's the thick green rectangular box. To do that, go the the view port's menu, View->Camera Settings->Resolution gate. The gate might not size correctly the first time and here's how you can change that. From the view port's menu, choose View->Select Camera. At the far left on the Channel Box, look for an attribute called Lens Squeeze Ratio. Reduce by 0.1 until you're satisfied. Now when you render, only stuff inside the gate will be rendered.

5. Right now, the tree is still a Paint Effect controlled by the curve. Select the curve while in the wireframe mode (4). From the Channel Box, under SHAPES, there should be a node called strokeShapeKeyyakiParkn (where n is a number). I've enlarged the Channel Box in the figure below. Click that and a set of attributes will appear below. Reduce the Display Percent attribute to 75. This will visually reduce the number of polygons you have on the view port. But when you render, you still render at 100 percent. This is to make your view port respond faster since there are fewer polygons to display now.

08_lowerdisplay

6. To actually reduce the polygon count. You have to open up the creation node for the tree. Select the curve again and open up the Attribute Editor (Ctrl+A). Look for a tab called keyakiParkn. The important attributes that control how the tree grows are under Tubes, Creation and Growth. Play with the attribute numbers to get the desired shape for the tree you want. Change the numbers and watch the tree update interactively.

09_attributefortree

7. After you're done tweaking, it's time to change the Paint Effects tree into a real polygon. Changing it into a polygon enables you to select the tree by clicking on it instead of always using the curve to select it.

Select the curve. Choose from the menu, Modify->Convert->Paint Effects to Polygon->Options. I've set the Poly limit to have only a maximum of 2000 poly faces. Click Convert.

10_converttopoly

8. Do a render with you new polygon tree.

11_polytree_render

9. Watch the Heads Up Display to notice the changes. Notice that the poly faces didn't actually reduce to 2000. To do that manually, from the polygon rendering menu (F3), choose Mesh->Reduce->Options. Reduce it by 50%.

12_reduceoptions

10. Again, check the Heads Up Display to see the number of poly faces. To further reduce the poly faces, you don't have to open up the Reduce options dialogue box again. Select the object that was just reduced, from the Channel Box, select the command node called polyReducen. Update the reduction Percentage.

13_reducepoly

11. It's time to re-shade the leaves and drop the texture. The leaves texture is not need since the tree is going to be very small when viewed by the readers.

From the menu, choose Windows->Rendering Editors->Hypershade

You can see that I've already created a few shaders.

15_hypershade

12. Create your own leaf shader by clicking on the lambert shader on the left pane. A lambert shader will appear in the work area on the bottom right of the Hypershade Window.

Double click that to open up the Attribute Editor. Click on the Color button (which is gray), and choose a green color from the Color Chooser dialogue. Click Accept after that and you can close the Attribute Editor.

14_createlambert

13. When you converted the Paint Effects tree into a polygon, Maya has conveniently grouped the leaves and tree trunk separately. Just select the leaves, with your Hypershade still open, right click on your leaves shader and choose Assign Material to Selection.

Create another shader for the tree trunk. In my scene, I've also created a simple ground plane for the tree to stand on.

14. Now it's on to the ambient occlusion part. Select all your objects on scene. On the Layer Editor at the far right bottom, click the Render radio button to show the Render Layer. Click the button with a small blue ball.

A new Render layer called layer 1 will appear. Note the 'R' in the square box on the left. That means the layer will be rendered when highlighted.

17_createrenderlayer

15. Right click on layer 1 and choose from the pop up menu, Presets->Occlusion. This will shade all the objects on that layer with a new Surface Shader.

18_occlayer

16. If you click the render button now, you'll get something like the figure below.

19_newtree_occ

17. To render without the ambient occlusion, click on Master layer and make sure that there's an 'R' in the square box on the left. Click render and you'll get something like the figure below.

After you have finished modeling everything, you should clean up the history. Choose from the menu, Edit->Delete All By Type->History. This will make your scene smaller and cleaner.

19_newtree_noocc

18. Open the two images in an imaging software, like Photoshop. Focus on the occlusion image. Open up the Channels palette and Layers palette. Select the Move tool (V) first or else you can't move anything.

Drag the Alpha channel called Alpha 1 over to the coloured image. You'll see the alpha channel loaded. Press Ctrl+` to switch back to the colour channels.

Move back to the occlusion image again and this time drag the Background layer over to the coloured image.

When dragging, make sure that you put the Background image and alpha channel directly on top of the colour image. You can use the arrow keys to position the images 1 pixel at time.

20_mergelayers

19. With your occlusion image on top of your coloured image, you can set the blending mode from Normal to Multiply and lower the opacity to make the occlusion image blend with the coloured image.

In the figure below, I've also created a Curves Adjustment layer to brighten the whole scene a bit.

Optional step: If you don't want the black background, load the alpha channel eariler on into a selection and mask the background out.

21_multiply

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.