tilezen / joerd

Joerd can be used to download, merge and generate tiles from digital elevation data
MIT License
324 stars 50 forks source link

Add normal maps #34

Closed zerebubuth closed 8 years ago

zerebubuth commented 8 years ago

This adds normal maps as a 3rd type of output. Currently it shares a lot of code with the Terrarium tiles, but hopefully we can factor that out in the future.

This is what the tiles look like:

Normal map RGB components Normal map alpha component

That's the RGB channels on the left and alpha as greyscale on the right, to make it easier to see. With R, G, B, A = X, Y, Z, H where X, Y, Z are the respective components of the normal, scaled with (-1.0, 1.0) mapped to (0, 255) with 0.0 mapped to 128. The A = H component is mapped to a table having:

Note that the indices count from 255 (for -11,000m) down to 0 for 8,800m. This is so that the more common heights near sea level have more opaque alpha values suitable for viewing in a web browser.

Connects to #31.

@rmarianski could you review, please?

rmarianski commented 8 years ago

:+1: