# Creating Ground From a Height Map

> Learn how to create ground from a height map in Babylon.js.

Source: https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/ground_hmap

## Ground From a Height Map

When the ground is created using _groundFromHeightMap_, the surface of the ground can be perturbed by a grayscale image file called a height map. Lighter areas are displayed higher than darker areas. This is a way to create hills and valleys on your ground.

## MeshBuilder

Usage:

```javascript
const ground = BABYLON.MeshBuilder.CreateGroundFromHeightMap("gdhm", url_to_height_map, options, scene); //scene is optional and defaults to the current scene
```

| option       | value                                                                             | default value          |
| ------------ | --------------------------------------------------------------------------------- | ---------------------- |
| width        | _(number)_ size of the map width                                                  | 10                     |
| height       | _(number)_ size of the map height                                                 | 10                     |
| subdivisions | _(number)_ number of map subdivisions                                             | 1                      |
| minHeight    | _(number)_ minimum altitude                                                       | 0                      |
| maxHeight    | _(number)_ maximum altitude                                                       | 1                      |
| onReady      | _(function)_ a JavaScript callback function that is called and passed the newly built mesh | (mesh) =\> \{return;\} |
| updatable    | _(boolean)_ true if the mesh is updatable                                         | false                  |

### Examples

The following image is used for the height map in the first examples.

![height map](https://doc.babylonjs.com/img/how_to/HeightMap/heightMap.webp)  
Low subdivisions: [Playground: Create Ground From A HeightMap - Low Subdivisions](https://playground.babylonjs.com/#LQ4LI1) - Simple example of creating ground from a heightmap with low subdivision.
High subdivisions: [Playground: Create Ground From A HeightMap - High Subdivisions](https://playground.babylonjs.com/#LQ4LI1#1) - Simple example of creating ground from a heightmap with high subdivision.

Flat world: [Playground: Create Ground From A HeightMap](https://playground.babylonjs.com/#LQ4LI1#3) - Simple example of creating ground from a heightmap.

## Mesh

Usage :

```javascript
var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", heightMapPath, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReadyCallback);
```
