CryENGINE 3: Breaking Ground with Sandbox

13 min read
        Read more about this book      

(For more resources on this subject, see here.)

What makes a game?

We saw that majority of the games created on the CryENGINE SDK have historically been first-person shooters containing a mix of sandbox and directed gameplay. If you have gone so far as to purchase a book on the use of the CryENGINE 3 SDK, then I am certain that you have had some kind of idea for a game, or even improvements to existing games, that you might want to make. It has been my experience professionally that should you have any of these ideas and want to share or sell them, the ideas that are presented in a playable format, even in early prototype form, are far more effective and convincing than any PowerPoint presentation or 100-page design document.

Reducing, reusing, recycling

Good practice when creating prototypes and smaller scale games, especially if you lack the expertise in creating certain assets and code, is to reduce, reuse, and recycle. To break down what I mean:

  • Reduce the amount of new assets and new code you need to make
  • Reuse existing assets and code in new and unique ways
  • Recycle the sample assets and code provided, and then convert them for your own uses

Developing out of the box

As mentioned earlier, the CryENGINE 3 SDK has a huge amount of out-of-the-box features for creating games.

Let’s begin by following a few simple steps to make our first game world.

Before proceeding with this example, it’s important to understand the features it is displaying; the level we will have created by the end of this article will not be a full, playable game, but rather a unique creation of yours, which will be constructed using the first major features we will need in our game. It will provide an environment in to which we can design gameplay.

With the ultimate goal of this article being to create our own level with the core features immediately available to us, we must keep in mind that these examples are orientated to compliment a first-person shooter and not other genres. The first-person shooter genre is quite well defined as new games come out every year within this genre. So, it should be fairly easy for any developer to follow these examples.

In my career, I have seen that you can indeed accomplish a good cross section of different games with the CryENGINE 3 SDK. However, the third- and first-person genres are significantly easier to create, immediately with the example content and features available right out of the box.

For the designers:
This article is truly a must-have for designers working with the engine. Though, I would highly recommend that all users of sandbox know how to use these features, as they are the principal features typically used within most levels of the different types of games in the CryENGINE.

Time for action – creating a new level

Let’s follow a few simple steps to create our own level:

  1. Start the Editor.exe application.
  2. Select File | New. This will present you with a New Level dialog box that allows you to do the adjustments of some principal properties of your masterpiece to come. The following screenshot shows the properties available in New Level:

  3. Name this New Level, as Book_Example_1. The name that you choose here will identify this level for loading later as well as creating a folder and .cry file of the same name.
  4. In the Terrain section of the dialog box, set Heightmap Resolution to 1024×1024 , and Meters Per Unit to 1.
  5. Click on OK and your New Level will begin to load. This should occur relatively fast, but will depend on your computer’s specifications.
  6. You will know the level has been loaded when you see Ready in the status bar. You will also see an ocean stretching out infinitely and some terrain slightly underneath the water.
  7. Maneuver your camera so that you have a good, overall view of the map you will create, as seen in the following screenshot:

    (Move the mouse over the image to enlarge.)

What just happened?

Congratulations! You now have an empty level to mold and modify at your will.

Before moving on, let’s talk a little about the properties that we just set, as they are fundamental properties of the levels within CryENGINE. It is important to understand these, as depending on the type of game you are creating, you may need bigger or smaller maps, or you may not even need terrain at all.

Using the right Heightmap Resolution

When we created the New Level, we chose a Heightmap Resolution of 1024×1024. To explain this further, each pixel on the heightmap has a certain grey level. This pixel then gets applied to the terrain polygons, and depending on the level of grey, will move the polygon on the terrain to a certain height. This is called displacement. Heightmaps always have varying values from full white to full black, where full white is maximum displacement and full black is minimum or no displacement.

The higher the resolution of the heightmap, the more the pixels that are available to represent different features on said heightmap. You can thus achieve more definition and a more accurate geometrical representation of your heightmap using higher resolutions. The settings can range from the smallest resolution of 128×128, all the way to the largest supported resolution of 8192×8192 . The following screenshot shows the difference between high resolution and low resolution heightmaps:


Scaling your level with Meters Per Unit

If the Heightmap Resolution parameter is examined in terms of pixel size, then this dialog box can be viewed also as the Meters Per Pixel parameter . This means that each pixel of the heightmap will be represented by so many meters.

For example, if a heightmap’s resolution has 4 Meters Per Unit, then each pixel on the generated heightmap will measure to be 4 meters in length and width on the level.

Even though Meters Per Unit can be used to increase the size of your level, it will decrease the fidelity of the heightmap. You will notice that attempting to smoothen out the terrain may be difficult, since there will be a wider, minimum triangle size set by this value.

Keep in mind that you can adjust the unit size even after the map has been created. This is done through the terrain editor, which we will discuss shortly.

Calculating the real-world size of the terrain

The expected size of the terrain can easily be calculated before making the map, because the equation is not so complicated. The real-world size of the terrain can be calculated as:

(Heightmap Resolution) x Meters Per Unit = Final Terrain Dimensions.

For example:

  • (128×128) x 2m = 256x256m
  • (512×512) x 8m = 4096x4096m
  • (1024×1024) x 2m = 2048x2048m

Using or not using terrain

In most cases, levels in CryENGINE will use some amount of the terrain. The terrain itself is a highly optimized system that has levels of dynamic tessellation, which adjusts the density of polygons depending on the distance from the camera to the player. Dynamic tessellation is used to make the more defined areas of the terrain closer to the camera and the less defined ones further away, as the amount of terrain polygons on the screen will have a significant impact on the performance of the level.

In some cases, however, the terrain can be expensive in terms of performance, and if the game is made in an environment like space or interior corridors and rooms, then it might make sense to disable the terrain. Disabling the terrain in these cases will save an immense amount of memory, and speed up level loading and runtime performance.

In this particular example, we will use the terrain, but should you wish to disable it, simply go to the second tab in the RollupBar (usually called the environment tab) and set the ShowTerrainSurface parameter to false , as shown in the following screenshot:


Time for action – creating your own heightmap

You must have created a new map to follow this example.

Having sufficiently beaten the terrain system to death through explanation, let’s get on with what we are most interested in, which is creating our own heightmap to use for our game:

  1. As discussed in the previous example, you should now see a flat plane of terrain slightly submerged beneath the ocean.
  2. At the top of the Sandbox interface in the main toolbar, you will find a menu selection called Terrain; open this. The following screenshot shows the options available in the Terrain menu.
  3. As we want to adjust the terrain, we will select the Edit Terrain option. This will open the Terrain Editor window, which is shown in the following screenshot:
  4. (Move the mouse over the image to enlarge.)

  5. You can zoom in and pan this window to further inspect areas within the map. Click-and-drag using the right mouse button to pan the view and use the mouse wheel to zoom in and zoom out.
  6. The Terrain Editor window has a multitude of options, which can be used to manipulate the heightmap of your level. Before we start painting anything, we should first set the maximum height of the map to something more manageable:
    • Click on Modify.
    • Click on Set Max Height.
    • Set your Max Terrain Height to 256. Note that the terrain height is measured in meters.
  7. Having now set the Max Height parameter, we are ready to paint!
  8. Using a second monitor:
    This is a good time to take advantage of a second monitor should you have one, as you can leave the perspective view on your primary monitor and view the changes made in the Terrain Editor on your second monitor, in real time.

  9. On the right-hand side of the Terrain Editor , you will see a rollout menu named Terrain Brush. We will first use this to flatten a section of the level.
  10. Change the Brush Settings to Flatten, and set the following values:
    • Outside Radius = 100
    • Inside Radius = 100
    • Hardness = 1
    • Height = 20
  11. NOTE: You can sample the terrain height in the Terrain Editor or the view port using the shortcut Control when the flatten brush is selected.

  12. Now paint over the top half of the map. This will flatten the entire upper half of the terrain to 20 meters in height. You will end up with the following screenshot, where the dark portion represents the terrain, and since it is relatively low compared to our max height, it will appear black:

    (Move the mouse over the image to enlarge.)

    Note that, by default, the water is set to a height of 16 meters. Since we flattened our terrain to a height of 20 meters, we have a 4-meter difference from the terrain to the water in the center of the map. In the perspective viewport, this will look like a steep cliff going into the water.

  13. At the location where the terrain meets the water, it would make sense to turn this into a beach, as it’s the most natural way to combine terrain and water. To do this, we will smoothen the hard edge of the terrain along the water. As this is to become our beach area, let’s now use the smooth tools to make it passable by the player:
    Change the Type of brush to Smooth and set the following parameters:
    • Outside Radius = 50
    • Hardness = 1

    I find it significantly easier to gauge the effects of the smooth brush in the perspective viewport.

  14. Paint the southern edge of the terrain, which will become our beach. It might be difficult to view the effects of the smooth brush simply in the terrain editor, so I recommend using the perspective viewport to paint your beach.
  15. Now that we have what will be our beach, let’s sculpt some background terrain. Select the Rise/Lower brush and set the following parameters:
    • Outside Radius = 75
    • Inside Radius = 50
    • Hardness = 0.8
    • Height = 1
  16. Before painting, set the Noise Settings for the brush; to do so, check Enable Noise to true. Also set:
    • Scale = 5
    • Frequency = 25
  17. Paint the outer edges of the terrain while keeping an eye on the perspective viewport at the actual height of the mountain type structure that this creates. You can see the results in the Terrain Editor and perspective view, as seen in the following screenshots:

    (Move the mouse over the image to enlarge.)

    (Move the mouse over the image to enlarge.)

  18. It is a good time to use the shortcut to switch to smooth brush while painting the terrain.
    • While in perspective view, switch to the smooth brush using the Shift shortcut.

    A good technique is to use the Rise/Lower brush and only click a few times, and then use Shift to switch to the smooth brush and do this multiple times on the same area. This will give you some nice terrain variation, which will serve us nicely when we go to texture it.

  19. Don’t forget the player’s perspective:
    Remember to switch to game mode periodically to inspect your terrain from the players level. It is often the case that we get caught up in the appearance of a map by looking at it from our point of view while building it, rather than from the point of view of the player, which is paramount for our game to be enjoyable to anyone playing it.

  20. Save this map as Book_Example_1_no_color.cry.

What just happened?

In this particular example, we used one of the three different techniques to create height maps within the CryENGINE sandbox:

  1. The first technique, which we performed here, was manually painting the heightmap with a brush directly in the sandbox.
  2. The second technique, which we will explore later, is generating procedural terrain using the tools provided in sandbox.
  3. Finally, the third technique is to import a previously created heightmap from another program.

You now have a level with some terrain that looks somewhat like a beach, a flat land area, and some mountains. This is a great place to start for any outdoor map as it allows us to use some powerful out of the box engine features like the water and the terrain. Having the mountains surrounding the map also encourages the illusion of having more terrain behind it.

Have a go hero – using additional brush settings

With the settings we just explored, try to add some more terrain variation into the map to customize it further, as per your game’s needs. Try using different settings for the brushes we explored previously. You could try adding some islands out in the water off the coast of your beach or some hills on the flat portion of the map.

Use the Inside Radius and Outside Radius, which have a falloff of the brushes settings from the inner area having the strongest effect and the outer having the least.

To create steeper hills or mountains, set the Inside Radius and Outside Radius to be relatively similar in size. To get a shallower and smoother hill set the Inside Radius and Outside Radius further apart.

Finally, try using the Hardness, which acts like the pressure applied to a brush by a painter on canvas. A good way to explain this is that if the Hardness is set to 1, then within one click you will have the desired height. If set to 0.01, then it will take 100 clicks to achieve an identical result.

You can save these variations into different .cry files should you wish to do so.


Please enter your comment!
Please enter your name here