By: Elyse                Categories: BooksGamesGeneral

The following is an excerpt from 3ds Max Modeling for Games: Insider’s Guide to Game Character, Vehicle, and Environment Modeling: Volume 1, 2e by Andrew Gahan. This edition is packed with  tutorials that enhance your modeling skills and pump up your portfolio with high-quality work. Here, Gahan teaches you how to create and use alpha maps/channels.

We are going to look at the most common methods of creating various forms of vegetation used in the games industry. As creating foliage and leaves still relies heavily on alpha maps or a texture with an alpha channel, I’ll start off with a brief explanation. An alpha map is a black -and-white or grayscale image, which controls the transparency of a surface when it’s applied to a mesh using a shader. In the example pictured in Fig. 4.1, the alpha map is on the left, the diffuse texture is in the middle, and the final result applied to the mesh is on the right.

Figure 4.1

This works because the shader is interpreting values of 100% white as being fully opaque, and values of 100% black as being fully transparent. Any gray tones between 100% black and 100% white will be transparent. Now that we know what an alpha map is, let’s look at how we go about creating them.

The first step is always the source image for the diffuse. Whether it is hand painted or taken from a photo, you’ll need to have this first before you create the alpha map. I’ll use the previous example to demonstrate. This was initially taken from a photo and then modified using a mixture of Photoshop’s blending modes hand painting.

Figure 4.2

Initially, I “extracted” the leaves I wanted from the original photo and then used them to create the alpha channel.

There are a few ways to do this.

I could simply create an alpha channel and start painting white around the leaves I want visible using the standard brush tool, but this takes time and also means the background will remain. I wanted to remove this.

I started by creating a 512 × 512 image fi le. I then copied the source image into this fi le and scaled it to fi t into the square texture page (Ctrl + T). I then used the Lasso tool to create a selection around the area I wanted to keep. I then inverted the selection by going to Select > Inverse on the menu bar. I then deleted the highlighted pixels. In a few key strokes, a large chunk of the unwanted image has been removed.

For the remaining pixels around the leaves, you could either use the eraser or manually paint the pixels out or you could use the magic wand tool to make pixel selections and delete them. The magic wand works best when the background is a different colour to the leaves, for example, a blue sky. In this instance, it also works as there is a decent level of contrast in the image, but the tolerance needs to be kept low as the image is mainly green.

Figure 4.3

I decided to use the magic wand to quickly remove chunks of the image. I then finished up by using the eraser to manually tidy up the final few stray pixels. I also adjusted the levels and hue and saturation on the final version before starting work on the diffuse texture.

Figure 4.4

Now, we have separated out the piece of vegetation. We can quickly use this to create the alpha channel or at least a good starting point. With the layer that the leaves are on selected, hold Ctrl + A and then select the small thumbnail image on the left of the layers name. This will select all pixels on the currently selected layer.

Figure 4.5

With this selection active, click on the channels tab. Go to the bottom right and click on the new layer icon highlighted in Fig. 4.6. This will create a new alpha channel in the texture fi le. Next, select the standard brush tool at 100% opacity and paint the selected area. The result is fairly good, but there are a few gray and white pixels around that will need painting over with 100% black (RGB 0,0,0).

Figure 4.6

When the alpha channel has been cleaned up, we can preview the results in Photoshop over the RGB image.

Do this by turning on the RGB channels by clicking on the box to the left of the RGB channel at the top of the channels list. This will show or hide these channels. The same applies to the alpha channel. When the alpha channel is displayed over the RGB channels, it will only show pixels under the white pixels of the alpha channel. In the next image, all the purple area represents the black values of the alpha channel.

You can change the color and opacity of the alpha channels appearance by double-clicking on the alpha channel.

It’s worth noting that you can still paint and edit the alpha channel while viewing all the channels at once.

Figure 4.7

The last step would be to save out the final texture (once the diffuse map is complete) with the alpha channel, so it can be used in 3ds Max. There are two ways to get the alpha channel or map displaying in real time in the viewport.

The diffuse texture can be saved with the alpha channel in the same fi le with a format that stores the alpha information. Some formats are BMP, PNG, TIFF, TGA, and .DDS.

This texture, which will contain the diffuse and alpha channel, will need to be assigned to both the diffuse and opacity slot in a material. When it is assigned to the opacity slot, the bitmap parameters will need adjusting. By default, the Mono Channel Output is set to RGB Intensity. It needs to be changed to Alpha.

Figure 4.8

In the second method, I saved out the alpha channel as a separate texture. This can be done by pressing Ctrl + A over the selected alpha channel to highlight it, Ctrl + C to copy the selection, and then Ctrl + V in the RGB channels in the layers tab to paste it as a new layer. Then save the fi le as a separate texture after flattening the image.

Then just assign it to the opacity slot in the 3ds Max material and assign the diffuse texture into the diffuse slot.

Both methods should display the diffuse map working with the alpha map in the viewport once Show Standard Map in Viewport is turned on in the material and the following display mode selected main menu > Views > Show Materials in Viewport as > Standard Display with Maps is also on.

Excerpt from 3ds Max Modeling for Games: Insider’s Guide to Game Character, Vehicle, and Environment Modeling: Volume 1, 2e by Andrew Gahan © 2011 Taylor & Francis Group. All Rights Reserved. 3ds Max can be purchased Amazon.comBN.com, and wherever fine books can be found

No Comments

No Comments

Tell us what you think!