.. and we get in terrainType.x the ID of the tile (0-15) we need to use for the current pixel. Here's the result in 3D. Since the ID is a small value (0-15), I have multiplied it by 16 to see it ...