Maps & Terrains

I have interest in building virtual worlds that can be used in games or apps. There was an interesting demo by @wooorldXR that really inspired me into trying my hand in learning how to build a 3D map viewer from scratch. So this repo will contain all the little experiments & prototypes using freely available mapping data to recreate that demo & then some :)

Another purpose of this repo is to develop a collection of examples / prototypes that is feature focused. Ideally this should make it easier for people to pick apart & learn how each bit works as a good starting point. Mind you, nothing here is production ready as things aren't optimized or very well abstracted. Since the goal is for learning, things are kept as bare bones and simple as possible.

Inspiration :
- https://twitter.com/haltor/status/1594166328356704258
- https://twitter.com/tiltfive/status/1597644083828518913
- https://twitter.com/SketchpunkLabs/status/1600487910758907905

Source Code : https://github.com/sketchpunklabs/mapping


Mapping Tile Prototypes
  1. Google Photorealistic 3DTiles - Render tile at LonLat ( API Key Needed )

    Modification from the basic example, this one converts LonLat coordinates of the empire state building to cartesian cords then performs a tree search for the last possible tile to render. It streams down sub tilesets during the tile search in the process. Renders the 3D tile when the location has been found.

  2. Google Photorealistic 3DTiles - Basic ( API Key Needed )

    From scratch with a basic 3D Tiles parser & loader, this example shows how to parse 3D tiles from google, download JSON and GLBs to render two initial tiles in the tileset.

  3. Vector Tiles

    Download PBF data, use protobuf to deserialize binary into JSON. From there turn the points, lines and polygons into meshes that can be rendered with webgl.

  4. Terrarium Heightmap Terrain Tiles

    Download Mapzen's terrarium & normal map tiles along with ArcGIS satellite map tile. Use height map to apply vertex displacement to a grid plane mesh, then render it well with the normals for to handle lighting and satellite image as its texture.

  5. Render 3D Build Tile

    Parse and extrude multiple polygons to build a single building, then scale and place it correctly over a raster tile. Filtering all buildings from the tile except for Empire State Building.

  6. Render Raster Tile

    Download tile image, convert to a texture then render to a quad face mesh.

  7. Slippy Viewer Mechanics

    Scaling and swopping tiles during zoom operation, plus doing tile translations using a floating origin.

  8. Fix Mesh with Floating Origin

    3D tiles that have their vertices far away from origin causes z-fighting like problems caused by floating point errors. This example fixes the mesh into localspace, then uses a ModelViewMatrix in a shader to properly render the tile at extremely large distances from origin with the camera without any strange artifacts.

Procedural Terrain Prototypes
  1. Topographic Contour Lines ( With Bloom )

    Render a procedural terrain tile using a custom shader that draws out the contour lines along with using the composer to apply a bloom post effect. View without bloom

  2. Procedural Heightmap Texture

    Using a material with noise, render to a square text to create a heightmap. Then use that texture for displacement of a grid along with generating normals from the heightmap.

  3. Smooth Contour Lines

    Generating smooth contour lines requires a bit of extra work by doing the noise displacement in the vertex shader (Heightmaps won't work) for smooth height values plus procedurally create the lines as a texture to utilize mipmaps to smooth things out

  4. Height Coloring

    Procedurally generate a heightmap textture then apply colors in relation to the height.

  5. Instanced Cubes with FBM & ColorRamp

    Generating smooth contour lines requires a bit of extra work by doing the noise displacement in the vertex shader (Heightmaps won't work) for smooth height values plus procedurally create the lines as a texture to utilize mipmaps to smooth things out

  6. Displacement Stamp

    Using a heightmap image as a displacement stamping.