Skip to content

Commit c23240d

Browse files
authored
[Height map] Add a tiny documentation (#292)
1 parent 15eb21a commit c23240d

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Details
3+
---
4+
# Height map extension
5+
6+
This extension allows to build a terrain with hills where objects with the 3D physics behavior can stand.
7+
8+
9+
## Create a height map from a 3d model
10+
11+
3D modelers like [Blender](https://www.blender.org/) can be used to render a model height into a grayscale image. The model should only contain the terrain. Decorations like trees or buildings must be removed for this process.
12+
13+
14+
## Generate a realistic terrain
15+
16+
[WGEN](https://github.com/jice-nospam/wgen) is a free and open-source height map generator. It can produce grayscale images that can be used with this extension.
17+
18+
19+
## Generate an endless terrain
20+
21+
Basic terrains can also be generated directly inside GDevelop using the [noise extension](/gdevelop5/extensions/noise).
22+
23+
[Open example in GDevelop](https://editor.gdevelop.io/?project=example://3d-endless-terrain){ .md-button .md-button--primary }
24+
25+
[![](endless-terrain.png){ width="320" }](https://editor.gdevelop.io/?project=example://3d-endless-terrain)
26+
27+
28+
## Avoid stairs-like height maps
29+
30+
The extension can only read images as 8 bits per channel. This can lead to terrain moving up like stairs. To avoid this issue, a 16 bits grayscale image can be converted into a 8 bits RGB image that uses red and green channels.
31+
32+
```Python
33+
import numpy as np, cv2
34+
35+
src = cv2.imread("greyscale-height-map.png",cv2.IMREAD_UNCHANGED)
36+
h,w = src.shape
37+
dst = np.zeros((h,w,3), np.uint8)
38+
39+
dst[:,:,1] = (src & 0xff00) >> 8
40+
dst[:,:,2] = src & 0x00ff
41+
42+
cv2.imwrite("red-and-green-height-map.png",dst)
43+
```
44+
45+
This is a slightly modified version of the [original script](https://gist.github.com/companje/85e94ea96629ddaf1219f137b225fd69) written in [Python](https://www.python.org/).
46+
47+
48+
## Reference
49+
50+
All actions, conditions and expressions are listed in the [Height map reference page](..).
53.2 KB
Loading

0 commit comments

Comments
 (0)