Sci-fi cars in 3ds Max & Marmoset Toolbag 2: Desert Racer Part 2
In this tutorial I will guide you through the process of texturing the vehicle asset we modeled in the previous issue, and exporting it to Marmoset Toolbag 2 to set up a scene for our final renders. If you're not familiar with Marmoset Toolbag 2, it's a real-time physically based rendering (PBR) solution that is a standalone program. It's mainly used in the games industry to display assets for portfolios, but I wanted to show that it can be used with a high-poly model and provide some fantastic-looking images in real-time. It allows us to use physically correct surfaces that, combined with HDR lighting, give us a photorealistic professional end result.
Step 01: UVing the bonnet
In 3ds Max, apply an Unwrap UVW modifier to the asset before the TurboSmooth modifier so we're only dealing with the simplified mesh. I use planar mapping for the top and bottom geometry, and apply the Relax tool to smooth out any folds in the UVs that would cause kinks in the texture. I organize the UV islands to maximize the space used for the most important parts of the asset; in this case, the bonnet top would need more space than the underside, so we can have more texture resolution on the visible geometry.
Step 02: Tire mapping
Tires can be quite tricky to UV map because of the curvature of the wheel. I map the tread of the tire using simple cylindrical mapping and scale it to match the rest of the car. The wall of the tire is more tricky; if you want to apply detail textures to the wall of the tires (such as writing or logos) then we ideally need the wall to be completely flattened out, but the usual projection mapping techniques won't work for us. Instead, we can use the Wrap tools, specifically the Spline Wrap tool. To create the correct shape, use the Edit Poly modifier and select an edge of the wall and loop select to form a circle of selected edges. Then click 'Create Shape' to add a spline that perfectly matches the edge selection.
Now back to the UV modifier. Select the Spline Wrap tool and pick the new spline, use planar mapping, then select and scale the cross-section in the viewport until they just about encompass the wheel. Once you commit the tool, you can then scale and rotate the UV island to fit correctly in the UV space.
Step 03: UVing the shell of the vehicle
Because the shell of the car will be using a paint material, it's best practice to join all these meshes together so they share the same material. This also makes it easier for us to texture on one map later on. Attach all the shell elements that will have the painted material and apply a new Unwrap UVW modifier. You'll probably now have overlapping UVs, so move them all out of the UV space and bring each island back in. Remember to keep the scaling of the outer geometry roughly the same, so that the texture resolution is consistent. Once the UVs are packed into the UV space, continue with the process with the rest of the asset.
Step 04: Separating the asset's ID
In this image you can see I have split the mesh into its individual material IDs, represented here by the different-colored meshes. All the red meshes are going to be the car paint material, purple will be chrome, gray will be the tires, and so on. The reason I've done this is to make the process easier once I'm in Marmoset Toolbag 2. Now when I export this mesh, it's split up and I can apply multiple materials to the asset in Marmoset.
Step 05: Rendering the UVs
With the car paint shell ID selected in the Unwrap UVW window, select Tools > Render UVW template. In the dialog box I change the size to 8192 x 8192 (this is a very large texture in the games industry and should be good enough resolution for our needs). You can adjust this size depending on the element you've selected; I know this element will have text and detail in the texture, so I need it to be higher resolution. Hit 'Render UV Template' and you're presented with an image of the UV space with all our UVs as we unwrapped them. Save this image and we'll bring it into Photoshop as a guide for texturing.
Step 06: Setting up the PSD
Bring the rendered UV template into Photoshop, duplicate the layer and name it UV. Create a new layer and place it between the UV and the background layers - this will be the car paint base layer. Use the Paint Bucket tool to flood-fill this layer with the color you would like the vehicle to be (in this case, a deep red). Select the UV layer and change its layer mode to Screen, which removes all the black from the image, leaving only the white and green wireframe outlines of the UVs. If these lines are still too distracting, change the opacity to get a level you are comfortable with.
Step 07: Completed diffuse texture
Using the UV wireframe as a guide, I'm able to draw in white racing-stripe decals that match the curves of the bodywork. I'm also able to precisely place the number text and logos for the rear of the vehicle. I draw in a simple design for the door to match the concept reference. I add a layer of dust to the bonnet of the vehicle just so it doesn't look too clean. I don't want to go too complicated with the diffuse texture as I want the materials to do a lot of the work for us.
Step 08: Trims diffuse texture
As the trims are mainly a chrome material, the shader will be doing the work, so again it's best not to add too much detail here. I want the exhaust pipes to have a rainbow-colored effect that you sometimes see on sports cars - I thought it would be a nice touch on our vehicle. I add a little dirt and grime on the white suspension caps but keep the detail very subtle. I also add a red trim, just to keep with the color scheme of the vehicle.
Step 09: Tire diffuse texture
The tires' diffuse texture is mainly a dark-gray, but I paint in subtle shade changes to break it up a little. New tires are usually quite clean, so no need to go overboard with the detail as it may become distracting. I add a white line which again reflects the vehicle's color scheme. I add logos to the wall of the tire, which are the same color as the base tire but with an added drop shadow to give a fake ambient occlusion effect and simulate some depth in the texture. I also add some small black lines to show weld points on the tire.
Step 10: Normal map texture
The tires' normal map is created by first converting our diffuse texture into a height map in Photoshop. Remove all the shading detail so we have a flat gray background color, because we don't want the variations in color to affect our normal map; it will be quite a smooth surface, and the shading detail would create weird normal map details that'd look really bad in our renders. I keep the lines and logos in the height map but convert them to white, to indicate that they'll be raised above the main tire surface.
Step 11: Finishing off the normal map
Open the height map in CrazyBump and the software automatically starts to convert the height data into a normal map for us. The default settings aren't what we're looking for, so I turn them all down to zero to begin with. As a further aid, export the wheel from 3ds Max as an OBJ and CrazyBump can import this model so we can see exactly how the normal map will look on our asset. I also apply the diffuse texture. Changing the intensity to 50, 'Fine Detail' to 99 and 'Medium Detail' to 22 gives me the result I want for the tires' surface. I leave 'Larger Details' at 0 because they create edges that are too rounded; they're more used for organic surfaces like rock, but we need a harder edge for the tire details.
Step 12: Importing into Marmoset Toolbag 2
Back in 3ds Max, make sure you have all of your elements and material IDs as separate meshes and have the TurboSmooth modifier enabled. Select all of the meshes and convert to Editable Poly, which makes sure that our mesh has no modifiers applied that won't be read by Marmoset Toolbag 2. It's also best to reset the XForms of the assets so that they're all in the correct positions when we import them into Marmoset. Choose File > Export and select FBX as the format, and export the mesh using the default settings. With Marmoset Toolbag 2 open in a new scene, choose File > Import Assets and select the vehicle FBX file. Sometimes you may have an occasion when the asset you've imported is not to scale. If this is the case, select the asset, navigate to the Transform settings, and increase or decrease the scale value (usually by whole numbers) until you have the correct scale.
Step 13: Creating the materials
The materials window located on the right-hand side is where we can generate our own custom materials or use the preset ones. Click the 'New' button to generate a blank material that we can now plug our textures into. Rename this material to coincide with the element it will be assigned to (in this case, Shell). Plug the albedo/diffuse texture and the normal map. You have the option to use custom gloss and specular maps, but the sliders are just what we need for the car paint. I give the car paint full gloss and a reduced specular, otherwise the diffuse color will be sucked out of the material leaving a more chrome look. You also have the option to plug in ambient occlusion maps which will require baking from 3ds Max. Marmoset has its own screen space AO solution, but if this is not giving the correct results, a baked solution may be better. To apply a material, just drag it onto the desired element (in this case, the body of the car).
Step 14: Paint Deforming the terrain
The terrain was created in 3ds Max using a plane with a high level of subdivisions. In Editable Poly mode, I use Paint Deformation to push and pull parts of the plane to form sand dunes. I don't go too detailed here, as it would be in the background and out of focus - our attentions should be on the vehicle anyway. I use simple planar UV unwrapping, with a little Relax applied to smooth out the UVs, and apply a tileable sandy texture and normal map in Marmoset to finish it all off. I also add two spotlights for the head lights, and two red point lights for the rear brake lights. These help to pick out some of the details on the terrain, but also shine nicely on the rear of the vehicle.
Step 15: Rendering your images
One you're happy that all of the assets now have the correct material setup applied, it's time to render the final images. If you select the camera in the scene explorer, you'll see a lot of options are available to improve the rendered image; the post-process settings are very powerful and can dramatically change how the image looks. I'll go into more detail in the Top Tip about the settings I use for this image. You also have camera-specific settings such as Depth of Field, which is great for focusing the viewer's eye on the detail of the vehicle rather than the less-detailed environment; it also gives a sense of realism to the image. The viewport quality by default is half the resolution it can be for performance reasons, but when we render an image we need to increase the resolution to get the best possible render. Change the viewport resolution to 2:1 so it's now double in the Render tab. Finally select Capture and save the image out.