Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
3ds Max 6 Bible (2004).pdf
Скачиваний:
55
Добавлен:
17.08.2013
Размер:
50.02 Mб
Скачать

1166 Part XIII Max in Action

Select by Channel modifier

After new channels have been created, you can recall them at any time using the Select by Channel modifier. This modifier is found in the Create Selection Modifiers Select by Channel menu command. Using this modifier, you can choose to Replace, Add, or Subtract a given channel from the selection. The available channels for the selection are listed by their channel name in a drop-down list.

Using Vertex Colors

When creating models that are for games, the size of the texture map can be prohibitive. I mean, what model that weighs in at 16 kilobytes or less wants to carry around a 2-megabyte texture map? The solution that much of the gaming world relies on is to apply a single color to a vertex. Having each vertex remember its color (or even several colors) requires very little additional information for the mesh and can create some good shading. Colors are then interpolated across the face of the polygon between two different colors on adjacent vertices.

The results aren’t as clean and detailed as a texture map, but for their size, vertex colors are worth the price.

Assigning vertex colors

Vertex colors can be assigned in the Surface Properties rollout for Editable Mesh and Editable Patch objects, and in the Vertex Properties rollout for Editable Poly objects. They also can be assigned in Face, Polygon, and Element subobject modes using a little rollout section called Edit Vertex Colors. Within this section are two color swatches for selecting a Color and Illumination values. The Alpha value sets the alpha transparency value for the vertex.

Painting vertices with the Vertex Paint modifier

Another, more interactive way to color vertices is with the Vertex Paint modifier. This modifier lets you paint on an object by specifying a color for each vertex. If adjacent vertices have different colors assigned, then a gradient is created across the face. The benefit of this coloring option is that it is very efficient and requires almost no memory.

New

The Vertex Paint modifier has been enhanced for 3ds max 6.

Feature

 

The Vertex Paint modifier lets you specify a color and paint directly on the surface of an object by painting the vertices. The color is applied with a paintbrush-shaped cursor. The modifier can be applied multiple times to an object, giving you the ability to blend several layers of vertex paints together. You can find this modifier in the Modifiers Mesh Editing submenu.

Applying this modifier opens a VertexPaint dialog box called the Paintbox, shown in Figure 50-5. At the top of the Paintbox are four icons that can be used to show the visible results of the painting in the viewports. The options include Vertex Color Display–Unshaded, Vertex Color Display–Shaded, Disable Vertex Color Display, and Toggle Texture Display–On/Off.

Chapter 50 Max and Games 1167

Paint All

Vertex Color

Vertex Color Display – unshaped

Vertex Color Display – shaped

Disabled Vertex Color Display

Toggle Texture Display On/Off

Pick color

New

Condense to a

from object

Layer

Single Layer

Erase All

Delete Layer

Figure 50-5: The Paintbox palette for the Vertex Paint modifier includes a wealth of features.

The Vertex Color icon flyout lets you work on the Vertex Color, Illumination, Alpha, or any one of the 99 available map channels. The lock icon locks the display to the selected channel, or you could be looking at a different channel than the one you are painting.

The large Paint and Erase buttons let you add or remove vertex colors using the color specified in the color swatch. You can also select colors from objects in the viewports using the eyedropper tool, and then set the Opacity.

The Size value determines the size of the brush used to paint. Max supports pressure-sensi- tive devices such as a graphics tablet, and you can set the brush options using the Brush Options dialog box, shown in Figure 50-6. When paining on the surface of an object, a blue normal line appears. This line guides you as you paint so that you know you’re on the correct surface.

Note The Brush Options dialog box is the same dialog box that is used to paint weights for the Skin modifier, which is discussed in Chapter 35, “Rigging Characters.”

1168 Part XIII Max in Action

Figure 50-6: The Brush Options dialog box lets you define the profile curve used to paint vertex colors.

The Paintbox also includes three subobject selection icons. These icons can be used to select certain Vertices, Faces, or Elements to be painted. This limits the painting to the selected subobjects only. You can also select to Ignore Backfacing and use Soft Selection.

The Adjust Color dialog box lets you change all the painted colors applied to an object using HSV or RGB color sliders. The Preview option makes the color adjustment visible in the viewports if selected. Below the Adjust Color icon is the Blur Selected icon that blurs together all the vertex colors based on the designated Amount value.

Colors can be mixed between layers using the various blending modes. Clicking the New Layer button adds a new instance of the Vertex Paint modifier to the Modifier Stack; the Delete Layer button does the opposite. Click the Condense to a Single Layer button to merge all the consecutive Vertex Paint modifiers to a single instance using the selected blending mode.

Note Any files that are opened within 3ds max 6 that have an older version of the Vertex Paint modifier are displayed as OldVertexPaint in the Modifier Stack.

Tutorial: Marking heart tension

As an example of using the Vertex Paint modifier, imagine a doctor who has a 3D model of the human heart. While discussing the results of the latest test with a patient, the doctor can color parts of the heart model to illustrate the various points.

To color on a human heart using the Vertex Paint modifier, follow these steps:

1.Open the Vertex paint on heart.max file from the Chap 50 directory on the CD-ROM. This file includes a heart mesh created by Viewpoint Datalabs.

2.Select a portion of the heart model, and choose Modifiers Mesh Editing Vertex Paint to apply the Vertex Paint modifier.

3.In the Paintbox that opens, select the red color and then click the Paint button. Then drag the mouse over the surface of the Perspective view.

Figure 50-7 shows the resulting color.

Chapter 50 Max and Games 1169

Figure 50-7: The Vertex Paint modifier can apply color to an object by assigning a color to its vertices.

The Assign Vertex Color utility

The Assign Vertex Color utility works a little differently. It converts any existing material colors to vertex colors. To use this utility, select an object, choose a Channel, choose a Light Model (either Lighting, Shaded, or Diffuse), and click the Assign to Selected button.

Rendering to a Texture

When working with a game engine, game designers are always looking for ways to increase the speed and detail of objects in the game. One common way to speed game calculations is to pre-render the textures used in a game and then to save these textures as a texture map. The texture map takes more memory to save, but can greatly speed the rendering time required by the game engine. This process of pre-rendering a texture is called texture baking.

Caution

If you bake a texture into an object and then render it with the rest of the scene, the object

 

gets a double dose of light.

1170 Part XIII Max in Action

Texture baking can be accomplished in Max using the Rendering Render to Texture menu command (or by pressing the 0 key). This opens the Render to Textures dialog box. In several ways, the Render to Textures dialog box resembles the Render Scene dialog box, including a Render button at the bottom edge of the interface. The interface also includes an Unwrap Only button. This button can be used to flatten the UVW Coordinates for the selected objects and to automatically create a map channel.

New

The Render to Textures dialog box has been enhanced in 3ds max 6.

Feature

 

General Settings and Baking Objects

If the Automatic Unwrap Mapping option in the General Settings rollout, shown in Figure 50-8, is enabled, then the object to be baked has the Unwrap UVW modifier applied using the Flatten mapping type. For this type, you can set the Threshold Angle (which is the difference between the normals of adjacent faces; if the angular value is greater than the Threshold Angle value, then a hard edge is created between the faces), the Spacing (which is the amount of space between different map pieces), and whether map pieces can be rotated and used to fill in holes of larger map pieces. The Clear Unwrappers option removes any previous Unwrap UVW modifiers from the object.

Figure 50-8: The General Settings rollout of the Render to Textures panel includes settings for all objects.

For the render pass, you can use the Production or Draft render settings, or you can select and use a Rendering Preset. The Setup button opens the Render Scene panel, where you can change the render settings.

In the Objects to Bake rollout, you can select exactly which channels are included in the rendered texture. You can select to bake an Individual object, All Selected Objects, or All Prepared Objects, which are all objects with at least one texture element. Texture elements are added using this rollout.

Chapter 50 Max and Games 1171

Output Settings

The Output rollout, shown in Figure 50-9, can be different for different selections. The Enable option can disable the settings for the selected object. By default, unwrap mapping uses channel 3, but you can change this channel if you wish. If a different mapping uses channel 3 and you don’t change this, the new mapping replaces the old one. The Edge Padding defines the overlap in pixels of the texture.

Figure 50-9: The Output rollout of the Render to Textures panel includes settings for specific objects.

Clicking the Add button lets you select the type of texture maps that you can render. You will want to use different maps depending on the purpose of the map, and you may want to render several at a time. The available types are CompleteMap, SpecularMap, DiffuseMap, ShadowsMap, LightingMap, NormalsMap, BlendMap, and AlphaMap. Elements that are added to the list can be disabled using the check boxes to the left. You can also change the map size or use the Automatic Map Size option, which bases the map size on the object size. Some map elements present a list of components to include in the map. These components appear in another rollout.

The size of the texture map depends on the size of the object, but you can set a Scale value for greater resolution and set Min and Max values to keep the maps within reason. By default, maps are saved to the /images directory, but you can select a different directory if you prefer.

The Clear Shell Materials button removes the Shell materials for the baked objects and restores their original materials.

1172 Part XIII Max in Action

Tutorial: Baking the textures for a dog model

To practice baking textures, we bake a complete map of just the dog’s head. Now I need to find a game engine to run it in.

To bake a dog’s head texture, follow these steps:

1.Open the Doberman.max file from the Chap 50 directory on the CD-ROM. This file includes a dog model created by Viewpoint Datalabs.

2.Select Rendering Render to Texture (or press the 0 key) to open the Render to Textures panel.

3.Select the dog’s body object. In the Render to Textures panel, set the Threshold Angle to 75, and make sure that the Rendered Frame Window option is set. In the Output roll-

out, click the Add button and double-click the CompleteMap option. Set the Map Size to 512×512, and click the Render button.

Figure 50-10 shows the resulting texture map. If you look in the Modify panel, you’ll see that Automatic Flatten UVs modifier has been applied to the object. If you look at the material applied to the object, you’ll see that it consists of a Shell material.

Figure 50-10: A texture map created with the Render to Textures panel