Baking Scene Elements Into Textures
 
 
 

Examine the setup:

  1. Load the file tut_texturebake_start.max. This file is in the \tutorials\vertex_color folder.

    The scene consists of a texture-mapped biplane model and a single shadow-casting Omni light. First, you'll see how the scene looks rendered in 3ds Max.

  2. Make sure the Perspective viewport is active. On the toolbar, click Quick Render, or press Shift+Q to render the scene.

    In the rendered image, note the presence of shadows, particularly those cast by the propeller blade and the vertical strut between the upper and lower wings. These shadows however, do not appear in the Perspective viewport.

  3. Close the rendered frame window.
  4. Select the Fuselage object; this is the body of the biplane.

    The Fuselage uses an Unwrap UVW modifier for complex and precise texture mapping. Because this is the only texture-mapped object in the scene, you'll concentrate on it for this lesson. First, you'll take a look at the texture.

  5. Go to the Modify panel, and in the modifier stack display, make sure the Unwrap UVW entry is highlighted.
  6. On the Parameters rollout, click Edit.

    This opens the Edit UVWs dialog. You can see how the texture map is divided into various sections, with different face clusters overlaid on each. These face clusters are UVW mapping coordinates that correspond to different parts of the Fuselage mesh.

  7. Close the dialog.
  8. Press M to open the Material Editor, and note that the fuselage is mapped with a standard material named Fuselage. Close the editor window.

Bake the texture:

  1. From the Rendering menu, choose Render To Texture.

    The Render To Textures dialog opens.

  2. On the Objects to Bake rollout, note that the Fuselage is the only object listed. Also note that the Selected Object Settings group > Enabled check box is on, and All Selected is chosen. This means that Render To Texture will use any selected objects.

    If you like, try selecting different objects in the Perspective viewport, and note that the Objects To Bake list updates dynamically. Finish by selecting only the Fuselage object.

  3. On the Output rollout, click the Add button.

    This opens the Add Texture Elements dialog, with a list of different types of texture elements you can render. Typically, you want to combine all elements into a single texture, so you use CompleteMap.

  4. In the Add Texture Elements dialog list, double-click CompleteMap or highlight it, then click the Add Elements button.
  5. When you use Render To Texture, the software creates a new material. You must specify where in this new material the rendered texture will go. In the Selected Element Common Settings group, click the drop-down list next to Target Map Slot and choose Diffuse Color.

    CompleteMap appears in the Output rollout list, along with the default texture size to be generated: 256x 256. The original texture map is fairly large, so you'll probably want to render it to a bigger size.

  6. Near the bottom of the Output rollout, click the 768x768 button.

    Other sizes are available from the preset buttons, and you can use the Size setting to specify any output size you want.

    This size is lower than that of the original texture; using it will help you see the differences between it and the one that Render To Texture generates.

  7. In the Name field, change the “CompleteMap” text to MyCompleteMap. Press Tab to refresh the dialog.

    The name in the output list changes to reflect your edit, as does the File Name And Type entry.

  8. At the bottom of the Render To Textures dialog, click the Render button.

    Alerts appear briefly, displaying the progress of flattening UVs and baking the texture, then a virtual frame buffer window opens with the newly rendered CompleteMap texture. This image looks similar to what you saw in the Edit UVWs window, but the texture is subdivided differently.

  9. Close the rendered frame window, then close the Render To Textures dialog.

Examine the results:

  1. Take a look at the modifier stack display, then look at the biplane in the Perspective viewport.

    A second modifier, named Automatic Flatten UVs, has been added to the Fuselage. This is an Unwrap UVW modifier, but it was created and applied automatically by the Render To Texture function.

    The Fuselage object is still mapped accurately, but the cast shadows now appear in the viewport. For example, if you move the light source, you can see that the shadows cast onto the fuselage from the propeller don't change with as the light source moves, because they're baked into the texture.

    You can also see that the texture map as applied to the fuselage in the viewport is of lower quality, but if you render the image, the texture is of its original high quality. In the next few steps, you'll see why.

  2. Open the Material Editor once again. Click the first material, which was previously named Fuselage.

    The software has renamed the material orig_Fuselage.

  3. Scroll down to find an unused sample sphere, click it, then click the Get Material button.
  4. From the Material/Map Browser dialog > Browse From group, choose Selected.

    A single material now appears in the list. Its name is Fuselage (from the object it's applied to), and the type, Shell Material, appears next to the name. This material was generated automatically by Render To Texture, then applied to the Fuselage object.

    Basically, a Shell material lets you combine two materials into one; you can see one material in the viewports while rendering with the other. When Render To Texture generates a Shell material, it uses the original material for rendering, and the baked material for displaying in the viewports.

  5. Double-click the texture in the list to add it in the Material Editor. Close the Material/Map Browser dialog.

    You can find the scene to this point in tut_texturebake_finish.max.

    This material has only one rollout: Shell Material Parameters. It shows that the original material (orig_Fuselage) is to be rendered with, while the baked material (baked_Fuselage, generated by Render To Texture) is to be visible in the viewports.

  6. Click the Original Material button, and then, on the Material Editor toolbar, click the Show Map In Viewport button.

    This step lets you see the material in the viewport in the next step.

  7. Return to the top level of the material, and on the Shell Material Parameters rollout, under Viewport, click the top radio button (next to Original Material).

    In the Perspective viewport, the Fuselage returns to its previous appearance, and the shadows go away.

  8. Try moving the light source, then render with the baked texture.

    The original shadows remain where you baked them. Depending on where you position the light source, you might see an additional set of shadows, cast by the light during the rendering.

  9. In the shell material, return viewport display to the baked material.

Render other elements:

Besides the CompleteMap, you can render individual elements, one or more at a time.

  1. Open the Render To Texture dialog and on the Output rollout, delete the MyCompleteMap element, then add a ShadowsMap element. Set Target Map Slot to Diffuse Color.
  2. Click Render.

    The new material is unshaded, except where the shadows fall. You can use this type of texture if your target rendering engine supports compositing multiple textures.

    Note that the rendered frame window still shows the CompleteMap, even though Render To Texture didn't save one. This is always the case, no matter which types of elements you render. You can turn off the automatic display of the frame window on the General Settings rollout.

  3. On the Render To Textures dialog, delete the ShadowsMap texture element then add, at the same time, DiffuseMap and LightingMap elements.

    They appear in that order in the list. With multiple textures in the list, you can specify output settings for each by clicking its list entry.

  4. In the list, click the DiffuseMap entry, then set Target Map Slot to Diffuse Color.
  5. Click Render. When the Missing Map Targets alert appears, click the Continue button.

    The Missing Map Targets dialog shows any texture elements that aren't assigned to target map slots.

    The new Shell material is created for the first element in the list only, as shown in the Perspective viewport. However, all textures are saved in the target directory. You can see the LightingMap texture in the viewport by deleting the DiffuseMap.

  6. Delete the DiffuseMap list entry, set the LightingMap's Target Map Slot to Diffuse Color, then click the Render button.

    Render To Texture generates a new material and applies it to the Fuselage, so it is now visible in the viewport. The LightingMap element includes all shading and shadows, but no diffuse coloring.

    NoteOnly one texture element at a time can be set to any given target map type. Also, if you add a texture element that was previously assigned a target map type, the software automatically assigns the most recent target map type that it used, if no other active texture element is already using that target map type. If another active texture element is using that target map type, the target map slot for the newly assigned texture element is blank.

Summary

Render To Texture is a versatile tool that can save you time in generating texture maps for real-time applications. In this tutorial you learned how to bake different types of textures, and how to work with the Shell material that Render To Texture generates. Try generating other texture elements, then export them to your real-time 3D engine.