Matthew Trevelyan Johns explains step-by-step how to create a canyon environment in ZBrush...
The use of ZBrush within the console and PC gaming industry has become common practice. In the past, ZBrush may have been seen as a program with which an artist can only create extremely high-detail models that are simply too costly to render within a real-time application - but in fact, this is not always the case.
In the following tutorial, you will discover how ZBrush can be used to generate meshes suitable for use in a real-time engine, using varied sculpting methods and the employment of custom brushes as well as the built-in procedural optimization and UV unwrapping features that are now a valuable addition to the software.
You will also learn how to prepare this mesh for the CryEngine using 3ds Max, as well as how to create the advanced textures required to drive CryEngine's powerful shader effects.
Finally, this tutorial will cover CryEngine's brand new, experimental lighting feature 'Voxel-Based Global Illumination', as well as how to render a screenshot before applying adjustments and filmic effects in Photoshop to make sure the image is presented as nicely as possible. So let's get started!
Step 01: Gathering suitable and informative reference
Gathering suitable reference is one of the most important preliminary steps when beginning any project. I'm careful to ensure that my reference images are all of relevant subject matter and haven't already been subject to distracting post-process effects (like additional contrast or hue changes) that might mislead me when I come to sculpting the rocks in ZBrush. I also look for images where the lighting is as natural as possible, so that I have a clearer idea of the material surfaces when I create my textures.
Some choice examples of my collected reference images, courtesy of Dollar Photo Club
Step 02: Blocking out in 3ds Max
The following steps are applied to the canyon wall mesh as an example, from modeling through to texturing and shader setup. Once happy with the processes involved, I'll apply all of these same steps to the sandy floor in my canyon scene.
So now it's time to create block-out versions of the canyon wall and floor meshes. Before I do this, I set my units to be in meters to ensure that I'm using an accurate scale. I do this by going to Customize > Units Setup and setting the Metric Scale drop-down box to meters.
Next, I'll start with a simple cube primitive and then divide the geometry evenly across the mesh. Entering the vertex sub-object mode, I can then use soft selection to push and pull the mesh into a desirable rough shape.
The basic block-out mesh in 3ds Max
Step 03: Preparing to sculpt in ZBrush
I'm happy with my block mesh of the canyon wall, so I export it as an .OBJ file ready to be brought into ZBrush. Inside of ZBrush, using the import function, I load my mesh and draw it onto the canvas. Pressing P in ZBrush enables perspective in the viewport, and the angle of view can be increased or decreased using the slider found in the Draw menu. I like to use perspective when sculpting large organic objects; in this instance it will help me visualize how the final asset might look when we render it in the CryEngine later.
Setting the angle of view in ZBrush
Step 04: Sculpting with DynaMesh
At this stage I still want to be very loose with my sculpting. Using DynaMesh will help me to sculpt the mesh and change its shape drastically without worrying about my topology. With my mesh drawn onto the canvas, I enter the Geometry tab and expand the DynaMesh menu. Leaving the resolution at 128 and pressing the DynaMesh button, the topology on the model is instantly updated while still retaining its original shape. I can now continue to sculpt, and when I wish to DynaMesh again, I'll simply hold Ctrl and drag in an area of the canvas outside of the model to update the topology.
DynaMesh can change the topology of your model at the click of a button
Step 05: Refining the sculpt
I find the most useful brushes in the early stages of sculpting are the Clay Tubes, Smooth, and Move brushes. With the mesh still at a low DynaMesh resolution, I use Clay Tubes to make large grooves in the mesh while trying to establish some of the major forms that are present in my reference images. As I sculpt, I occasionally use DynaMesh to ensure the topology remains even across the model as described in the last step.
When I'm happy with my initial shape, I turn off DynaMesh by clicking again on the icon in the Geometry tab. Now I'm ready to divide and sculpt some further detail into my mesh. It's worth remembering at this stage that the sculpt will be used to create a real-time mesh, so it doesn't have to be super detailed; so long as the major forms are there, it will work just fine.
While still very low detail, the sculpt is starting to take shape
Step 06: Custom brushes for easier sculpting
The rock formations that exist in Antelope Canyon were carved by fast-moving, debris-carrying flood waters that, over great periods of time, created the flowing grooves in the rock surface. With this in mind, I think a brush with a few additional settings will help me to sculpt the rock and simulate this effect more easily. I'll create a custom brush by first selecting the standard brush, freehand mode and choosing BrushAlpha 48. I'll set the brushes focal shift to -100, and in the Brush menu, under the AutoMasking menu, I'll just tick on BackFaceMask. With this done, I will be able to sculpt some smooth flowing grooves with sharp edges in just one sweep.
With a little smoothing and varying intensities and sizes, the custom brush can do a lot of the work
Step 07: Using ZRemesher and Clay Polish
Having used my custom brush to good effect, I'm now happy with the rocks and am ready to create a low-polygon version with a polygon count that is more suitable for a real-time application. Clicking the Geometry menu and expanding the ZRemesher tab, I'll set my Target Polygons Count to 80. This is the amount in thousands, so a value of 80 will give us an 80,000-polygon mesh. That may seem high for a real-time asset, but since this will be one of only a few meshes in the scene, it is perfectly suitable. If you wish, you can choose a far lower polygon count; ZRemesher is very flexible in this respect.
After hitting the ZRemesher button, the result appears a little soft at first, but using Clay Polish with a Sharp value of 20 and an RSharp value of 2 will recreate the sharper creases that our sculpt had previously.
The result of using ZRemesher and Clay Polish on the mesh
Step 08: Unwrapping with UV Master
The model now needs UVs before I can export it and load it into the CryEngine. I'll use UV Master for this, located in the Zplugin menu. Clicking Work On Clone makes a clone of the mesh and applies a white material to it for easy viewing. Now I'll Enable Control Painting and press the Protect button, which allows me to paint all areas of the mesh that I want to avoid having UV seams on. This is visualized with bright red coloring on the mesh.
Next I'll click the Attract button and paint the rest of the mesh, before finally pressing Unwrap. This will take a few moments and, when complete, I can check the UVs by clicking Flatten (UnFlatten to return to the mesh). If the UVs are suitable and have no seams in places that I do not want them, I'll export the mesh as an .OBJ ready to import in to 3ds Max.
The bright colors indicate areas that will remain seamless (red) and those areas that will attract the mesh seams (blue)
Step 09: Exporting from 3ds Max into CryEngine
Having imported my rock wall into 3ds Max, I'll create a dummy node at the world space co-ordinates 0, 0, 0. I'll then parent the rock mesh to it using the Select and Link button. Next I'll need to create a Multi/Sub-Object material with at least two slots: one for the floor, which will be sand, and one for the rock material. I can add more if I need them for other materials that I may create for the scene later. I'll now select each material and set the shader type to be a Crytek Shader before saving the scene in the CryEngine directory. My file path looks like this, though you may need to create your own 'objects' folder: CRYENGINE\gamesdk\objects\antelope_canyon.
Next, with the CryEngine running in the background and my material selected in the 3ds Max material manager, I press Create Material in the CryENGINE3 exporter. I'll be prompted to save my material inside the folder directory I just created. Next, before I export my rock mesh, I must assign the correct polygon ID to its faces. I have the rock set as material ID 2, and so I select all of the polygons on the rock mesh and assign those to polygon ID 2 also. I can now add the mesh node to the CryENGINE3 exporter and hit Export Nodes. After a few moments, it's now possible for me to load my mesh, with the correct shader applied (but no textures yet) from the Brush tab in CryEngine.
Setting the material type to be a Crytek Shader is very important at this stage, as it?s the format that the engine understands
Step 10: Creating rocky texture maps
For the rock to convey the type of surface detail that I'd like, I'll need to create a variety of texture maps to drive the CryEngine material. I'll start with the diffuse map, sometimes called an albedo map. Using cgtextures.com I am able to source a variety of images that will help the process. I set my background layer as a mid-gray, then use simple Photoshop layer modes like Overlay and Multiply in conjunction with the opacity slider to quickly create a subtle rock texture effect.
Finally I use a Hue/Saturation adjustment to ensure the overall diffuse color matches my reference as closely as possible. When I'm happy with my diffuse texture I save two versions: the original and another with a subtle Hue/Saturation adjustment. Eventually I'll set up the CryEngine shader to blend between the two.
The next map is a specular map. This is the easiest map to create: it should be a simple gray tone with RGB values ranging from 53 to 61 to represent the non-metal quality of stone/rock.
Then I create the gloss map to define how rough or smooth the rock material appears. For this I begin with another photo and remove the color from it using the Desaturate function, found in Image > Adjustments > Desaturate. Then, using a Levels adjustment, found here in Image > Adjustments > Levels, I increase the contrast slightly to emphasize the light and dark tones within the texture.
I like to keep all of my textures in a single .PSD file, each grouped under their own folders, which will help when we export the textures later.
Organizing your Photoshop files with groups makes saving individual textures much easier
Step 11: Creating the height and normal maps
For this step I'll be using a program called CrazyBump. You can download a free demo from the CrazyBump website, or there are many great alternative free programs that allow the procedural generation of these textures.
In order to feed the program a good base to start with, I duplicate my diffuse texture, desaturate and increase the contrast using the Levels adjustment once again. In order to emphasize the striations in the rock, I create a new layer and use a low-opacity black brush to manually paint some horizontal lines. CrazyBump will interpret the dark and light values in this texture as varying levels in height and will create normal maps and height maps accordingly. I save this texture and load it in to CrazyBump, where I can use the sliders to fine-tune the resulting normal and height maps. Once I'm happy with my results, I'll bring the textures back into Photoshop and add them to their own groups in the .PSD.
There are certain guidelines for saving textures for use in the CryEngine, all of which are detailed further in the official CryEngine documentation online at docs.cryengine.com. The main ones to remember are that the gloss map must be placed in the alpha channel of your normal map and saved with '_ddna' at the end of the filename; your heightmap must also be placed in the alpha channel of a blank texture and saved with '_displ' at the end of the filename.
CrazyBump allows the creation of various textures within minutes
Step 12: Setting up the CryEngine shader
Switching to the CryEngine once more and pressing 'M' to bring up the Material Editor, I'll first set the Diffuse and Specular Color values to white and the Smoothness value to 100; this will ensure that my textures are the only components driving these values in the shader. Next I'll simply plug each texture into the corresponding slot in the shader.
Currently the CryEngine shader does not support displacement mapping or the Blend Layer function by default, so I'll need to tick these features on in the Shader Generation Params tab. Once this is done, I'll have access to more options in the Shader Params tab. I'm going to use the same normal, specular and height maps as I have already, but in the Second Diffuse Map slot, I'll input the alternative version of my diffuse texture that I created earlier. Finally I'll select a blending map; for this I'll use the grayscale map that I used to create my normal and height maps with CrazyBump in the previous step.
The blend layer is controlled with three inputs: the Blend Factor slider, the Blend Falloff slider, and finally the alpha values stored in the vertices of the mesh itself. Switching back to 3ds Max, I apply a VertexPaint modifier to the rock mesh. Under Channel, I select Vertex Alpha, and with my brush set to black with a low opacity setting and large brush size, I can now paint some areas where I would like the blend layer to be visible. Once happy I'll re-export the mesh and hopefully will be able to see the effects of my blend layer in action.
The CryEngine shader dialogue box, showing the texture inputs in their appropriate slots
Step 13: Lighting in the CryEngine
The latest version of the CryEngine comes complete with an experimental lighting feature called Voxel-Based Global Illumination. It will attempt to accurately simulate the bounce light effect that gives the canyons the soft lighting and shadows present in the reference photos. First I'll enable the advanced options for the feature in the Tools menu > Experimental Features > Lighting - I just tick the checkbox by Total Illumination. With my rock mesh loaded into the scene and the correct material applied, I'll now make a few duplicates and position them end to end to create the feeling of a long, thin canyon environment. Next I'll open the Environment tab in the Rollup bar, scroll to the Total Illumination v2 tab and make sure it's active, before finally setting the Integration mode to 2, which will enable full Global Illumination. Finally I alter the Time of Day and the sun direction sliders that can be found via the Terrain menu > Lighting.
The Total Illumination settings, located at the bottom of the Environment tab
Step 14: Using console commands to capture an image
Once I'm happy with my sunlight adjustments and the shadows are playing nicely off the surface of the rocks, I think I need to soften the edges of the shadows a little. I go to View > Console and double-click in the gray bar of the window that pops up to open the Console Variables menu. In here I type 'r_ShadowJittering' and raise the value from the default to something more suitable. Next I remove the statistics that are on by default in the top-right corner of the screen; again in the console window I type 'r_DisplayInfo' and set the value to 0.
Finally, I type 'capture frames' in the console and change the value from 0 to 1. After a few seconds I change this value back to 1 again, and during that period of time all frames per second will have been captured and placed in the 'captureoutput' folder located in my CryEngine directory.
The console allows us access to a variety of settings and functions
Step 15: The final touches
Finally I open my captured image in Photoshop. I duplicate the base layer and apply Filter > Other > High Pass to it at a low value, then change this layer's blending mode to Hard Light, which creates a nice sharpening effect across the whole image that can be controlled with the opacity slider. Next I add a vignette and two black 'letterboxing' bars to create a cool widescreen movie effect.
The next step is to adjust the colors to better suit my reference images. My render was a little yellow and lacked some contrast, so I use Color Balance, Exposure, Brightness/Contrast, Hue/Saturation and Curves adjustments, found in the Image > Adjustments menu, playing with the sliders until I achieve the look I'm after. Finally, all that's left now is to sign the artwork and the image is complete!
Using color correction and other subtle effects can really transform the image
Head over to Matthew's ArtStation
Grab a copy of Sculpting from the Imagination: ZBrush