This tutorial will guide you through the initial steps of creating a level with the CRYENGINE Sandbox.
Because there are many steps involved, we will only skim the surface of these steps but you will find links to articles with more detail on these topics as we go.
Step 1 - Level Creation
Open the CRYENGINE Sandbox Editor and you will be greeted with the Welcome screen.
Click on "New Level" to get started with a new level. See the Creating a New Level article for additional information.
This will open the New Level dialog where you can set some initial settings for your level:
Type in a name for the level, remember to use standard English characters and numbers, without spaces.
Take a moment to consider the level size and what you want to achieve. The smaller the level you use, the better it will perform (less terrain to render) and consume less memory. For this example we'll use 512m @ 1m/unit.
Once you click OK, Sandbox will begin to create the level files. Give that a second or two and then you will be asked to Generate the Terrain Textures:
This appears because by default, the Terrain comes already painted with the default material, textures and settings you will see shortly.
Leave the settings as they are for now and click OK.
Give that another second or two (depending on the size of the level you created and your system specs) and then you should see your new level:
One thing you should get used to doing during development is saving often! So go ahead and hit CTRL+S to save and CTRL+E to Export to Engine.
Congratulations, you've now successfully created your first level and are ready to start building it up!
Step 2 - Terrain Building
Now that we've got our level created, we can notice two basic elements that are in the world, Ocean and Terrain.
The Ocean can be set at a specific height, by default it's at 16m (from the lowest point of the heightmap, which is 0m).
The Terrain also sets itself at a default height of 32m, this is a new change to CRYENGINE 3.6 and gives you quick access to new levels without having to modify terrain or the ocean first.
There are several ways you can work with terrain in CRYENGINE. You can import a heightmap such as a greyscale texture or from a dedicated application like World Machine, you can sculpt it manually with the built-in terrain tools or import it from another level but for this example we'll use the built in Terrain Generation tool to give us some quick and easy results.
Open the Terrain Editor from the Toolbar or View -> Open View Pane -> Terrain Editor.
Click on the Generate Terrain button in the toolbar or Tools -> Generate Terrain.
Keep the default settings for now and click OK.
You'll notice the heightmap shows the terrain height variance:
It looks like the terrain has gotten very large in scale now as the camera is now sitting inside the terrain.
Close the Terrain Tool and pan the camera around to get a better overview:
Use WASD to move the camera, hold Right Mouse Button inside the viewport and move the mouse to pan the camera.
Ok this is definitely way too large in scale, so we'll bring down the maximum terrain height.
Open the Terrain Tool again and click Modify -> Set Terrain Max Height. Set it to 128 (meters). By default it's 1024m.
You can see it's chopped off the existing terrain, up to 128m high, which can actually be a pretty neat way to make canyon-type terrain:
Now lets Generate the Terrain again which is going to give us much more suitable (scaled down) results with the new maximum height set:
Step 3 - Terrain Textures Setup
Now that we've got a basic terrain setup, lets add some textures. We'll start with just one grass layer for now. For more information on Terrain Texture setup, see: Painting Terrain.
Open the Terrain Texture Tool from the Toolbar or View -> Open View Pane -> Terrain Texture Layers.
You'll see the default layer that was mentioned earlier in this article which is generated on level creation.
You have the option to overwrite the existing layer texture/material, but its advised to create a new layer and delete the default one afterwards.
Click on Add Layer in the left column. Double click on "NewLayer" text where you can type in a new name for the layer to make it easily recognizable:
After you've named the layer, click on Change Layer Texture above the texture preview image in the left column.
This should open the file dialog in the
GameSDK\Textures\defaults folder. Select the grey.dds texture in there.
That's the Texture down, now we'll change the Material by clicking on the material for our layer. This will open the Material Editor:
In the Material Editor, navigate to Materials/terrain/grass_4 and select the material in the list:
Now, back in the Terrain Texture Layers tool, with our new layer selected, click Assign Material in the left column.
You should see the linked material update to the grass_4 material:
Great, now you've got your first terrain layer setup! You can repeat these steps to add other layers in order to give your terrain variation and more realistic results.
Step 4 - Painting Terrain
For the sake of speed, we're going to use a feature which was added in CRYENGINE 3.5.5 which is the "Flood" tool.
Depending on how much space you've got on screen, it might be a good time to close the Material Editor and Terrain Tools to give you some more room.
Now open the Terrain tools in the RollupBar and click on Layer Painter:
In the bottom section you'll see our two existing layers and the reason behind naming your layers appropriately.
Select the Grass layer and then click Flood at the bottom of the tool.
You'll notice the results don't look very convincing with the default settings.
This is because the only color its getting is from the very limited amount of green in the high-passed texture in the grass_4 material.
We should be getting most of the color for our terrain from the base texture (grey.dds). Because it's a grey texture though, we're going to add some green through the layer painter tool.
Click on Reset above the Color tool to reset the default brightness then click on the Color tool to open it.
See the image below for a recommended starting point, but this will of course require tweaking and testing to suit your level and scene.
Start with something fairly dark and fairly desaturated as we already have quite a bit of green showing by default.
With our new color/brightness set, click Save Layer to save the settings, otherwise they'll be reset if you deselect the layer/tool.
Now repaint the terrain with the Flood tool. You can see from the new settings we're getting a bit closer:
Don't be too concerned about the lighting yet, it is a balancing act between various elements and we'll start balancing that out a bit later on.
Step 5 - Adding Content
Prepare An Area
Before we can add content though, we should flatten out an area which we can start to build in. It's a good rule of thumb to try keep in powers of two (such as our max terrain height of 128, our ocean height of 16, etc).
With that in mind, open up the Terrain Tools in the RollupBar and click on Modify, the Flatten tool should be selected by default.
The area we want to work with is roughly around 60m so lets bump it up to 64m to keep in power of two. Set 64 in the Height part of the Flatten tool and you should see something like this:
Now, with the left mouse button, click in the viewport and you'll start to flatten out the terrain to a height of 64m. Create a reasonably large play area to start with.
It's easy to misinterpret what scale you're working with, so it's a good idea to place an object in to check.
That looks ok for a first area to work with, now lets start adding in some common objects to get us started.
SkyDomes are a relatively new approach which Crytek uses in its games to simulate the sky. They're cheap to render and can give excellent results with some high quality texture work. Plus, they can be manipulated through flowgraph for dynamics.
Open up the Objects Tab in the RollupBar and click on GeomEntity. Now navigate to
Objects/sky/forest_skydome and drop that into the level.
If your level was 512x512@1m like this level, move the skydome's pivot to 256,256,0 so that its directly in the center of the level. Then Scale it to 3x larger, otherwise it might look at bit fake as the player moves around, if its too small.
You can easily move any object to exact world coordinates via the tools marked above!
With CRYENGINE 3.6 and Physically Based Shading, there's a heavy reliance on Environment Probes to get both cubemap reflections and ambient lighting represented in the level.
Let's start with a 'Global' Environment Probe, which differs in setup a little since CRYENGINE 3.5. Now, instead of setting the radius to 100,000, you simply set the box size to cover the entire level and also set AttenuationFalloffMax to '0'.
Center the probe in the level at 256,256 but we need it to be above the terrain so set the Z axis above it, in this case '96' worked well. Now set the box size to 512,512,512. Click Generate Cubemap and then Activate the probe.
|Probe Enabled||Probe Disabled|
As you start to build up different areas, you can start to play additional 'Local' probes to offer more accurate lighting information for that area.
Next, add in a SpawnPoint entity from Entity -> Others -> Spawnpoint and place it somewhere in your new game area.
A common misunderstanding is that you need to add spawnpoints to flowgraph in order for them to work, this is not true. The engine will automatically spawn the player at the oldest spawnpoint placed in the level.
Save and Export your level once that is placed and lets go check it out in the launcher!
Step 6 - Launcher Setup
Start the Launcher and click on Singleplayer.
You'll notice that the level shows as "@ui_MyFirstLevel" or whatever you named it. This @ui_ prefix comes from the Localization System and indicates you haven't added the level to your localization files. We'll get to that in a bit. For now, load up the level.
First thing you'll notice when the level loads is we forgot to generate the terrain texture after we painted the level!
We also don't have a minimap, so let's fix that while we're back in the Editor. Close down the Launcher and head back into the Editor (remember you can leave the Editor open and run the Launcher at the same time, but Exporting will require the level not be loaded in Launcher).
Generate Terrain Texture
Click on the File menu and then click Generate Terrain Texture and you'll see the dialog we saw when we first created the level.
Because we're only using a single terrain layer with one color, that's going to mean our generated texture will be extra sensitive to compression artifacts, so set the Terrain Color Multiplier to '8' to compensate, then click OK.
We also want to generate a minimap texture so that we can see where we are on the radar. Click on the Terrain tab in the RollupBar then click Mini Map.
By default you probably won't see anything (because the terrain is either underwater or smaller than the box radius), so just left click in the map and you'll see a blue square targeting area.
If you bring the Camera Height down to 128, you should see a larger green box. Imagine the blue square aligns a camera looking downwards and the green square represents the camera's total field of view.
The idea is to setup the minimap tool to cover the playable area of your level (with a bit of extra around the edges so the level doesn't disappear on their radar as they near the edge). Line it up and click Generate Minimap:
You'll notice the screen quickly tiles along the level and stitches together the minimap image which is output to your level folder.
Note that vehicle entities don't show up (they're intended to move in the level and shouldn't put drawn into the minimap texture) so some brushes and a river were added.
It also creates the level XML file (because it stores the minimap coordinates information inside it) which can be used to add additional information to such as gamerules, but for now its fine as is.
Open the XML up in Microsoft Excel and add an entry in for your level. Take note that the middle column "Original Text" is not displayed in game. You can name your level something different to its filename, if you like.
Save the XML file and lets check the Launcher again.
And there you have it! If you've made it this far, you have successfully created a basic level in CRYENGINE!
To recap, you've just learned how to:
- Create a new level.
- Modify terrain and create a small play area.
- Paint terrain textures.
- Add in some commonly used objects.
- Generate a minimap for the level.
- Setup localization for your level name.
Now you should start adding in some game logic to give the player something to do inside the level!