O'Reilly logo

OpenGL ES 3.0 Cookbook by Parminder Singh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing terrain with displacement mapping

The displacement map technique modifies the surface of a geometric shape using procedural texture or texture image. This recipe uses the texture image called height maps to implement a geographical terrain surface on a 2D plane. A height map is a grayscale image where each texel stores the elevation information in the range of 0.0 to 1.0 (white is mapped to 1.0 and black is mapped to 0.0). The 2D plane is represented by a set of vertices arranged in a grid fashion; the elevation information for each vertex in this 3D grid space is read from the height map. This recipe uses another texture image, which is used to map the grass texture on the generated terrain, to make it more realistic.

How to do it... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required