Displacement mapping in Cryengine

Overview

Displacement mapping is the possibility of create geometry out of a texture. In Cryengine3 that process is called tessellation. It is dependent on the closeness of the camera. This tutorial will explain how to achieve that.

Setting up the correct Displacement Texture

To have our geometry to displace properly it is very important that our displacement map is set up correctly. There are some things that we have to look out for when making our displacement map, since it works differently than a normal map. For a displacement map we don't want fine detail and noise. Since that will create unnecessary geometry and not act the way a displacement map should.

For this example we want the bricks to stick out and have different levels of it. Some should be deeper than others and some should stick out more. To achieve that, the bricks that we want to stick out have to be whiter than the ones who don't. The next thing we should think about it the edges of the brick. As geometry gets displaced by a texture having hard transitions from white to black, will be mirrored by the geometry it'll displace.

To generate a displacement map it is recommended to bake out a height map out of xNormal with geometry build. Then to achieve a good displacement map is eliminating all the noise in the texture. Focus only on the big details. The small details should be taken care of by your Normal map. If you have your height map baked out you already have the values in sticking out bricks, etc. If you feel you need more than make the corresponding sections lighter or darker.

For the transitions from the black gaps to the brick, we need to blur the edges of the bricks a bit. This ensures a smooth displacement of geometry, since the blurring creates different shades of grey's instead of a black to white transition.

Here are some examples of good and bad displacement maps and what it does to the geometry in game:

Setting up the Geometry so it can Displace properly

To have a proper displacement of geometry, we need to set up our geometry for it. This example will follow bricks, since it's the best example for it.

We have a tileable texture applied to a polygon plane.

The first thing is that we have to cut along the bricks seams so the geometry will then displace properly.

As you can see if we just leave it right now and bring it back in the engine we have two big tris that will displace and not match our texture and create single bricks.

So we have to cut our geometry to match our diffuse texture.

After we've done cutting out geometry the geometry is not optimized. So we have to optimize it, retaining our main cuts so it can displace correctly.

Now that our geometry has been set up correctly we can import it to CRYENGINE and tweak our displacement map.

Displacement Map in CRYENGINE

Here are two images to see the difference in CRYENGINE what a displacement map does to our geometry plane.

As you can see in the second image, the bricks are actually being pulled out and extra geometry is created in the engine.

To further see why it is so important to cut the geometry correctly, there are three wireframe images displaying what happens in the engine during the displacement process.