Building Worlds

Filipe Varela	


filipe.varela@co.sapo.pt
Overview
•
•
•
•
•

Topographic Datasets	

Geometry partitioning	

Tesselating meshes	

Level of Detail (LOD)	

Data struc...
Basics - drawing path
Topography

Normals

Bathymetry

Shaders

Textures
Topography

Shuttle Radar
Topography Mission
(SRTM)
Blue Marble	

Next Generation
(BMNG)
SRTM
Resolution: 90m/pixel	

Coverage: 60ºS to 60ºN Lat, 360º Long	

Samples: 144000x432000, 16 bit	

~115 GiB	

Much high...
Others
Mars: MOLA + Viking	

Moon: LOLA + Clementine	

Mercury: Messenger + Mariner	

Venus: Magellan + Venera	

A couple ...
Back to Basics
432000x144000 samples (not counting poles)	

16bit/sample topography+bathy	

24bit/sample textures (+ 173GB...
Preparing the Data

What exactly do you need to achieve?	

How much effort are you willing to put in?
Terrain Rendering 101
•
•

Data is but height samples - Mesh tesselation	

Too much data to draw everything every frame Le...
Common Methods
•
•
•
•

Realtime Optimally Adapting Meshes	

Geomipmapping	

Chunked Level of Detail (LOD)	

Geometry Clip...
Chunked LOD
Tesselating Meshes
Several options - I picked triangle strips
LOD - Level of Detail
Split each chunk into 4 when LOD increases	

Chunk side vertex count must be 2^n
LOD - Level of Detail
Connect patches by copying:	

left of right to right of left	

new count is (2^n)+1
LOD - Tricks
Optimize patch side vertex count for
performance	

You want few GPU ops with a lot of data	

You don’t want t...
Meet the Quadtree
Quadtree Basics
•
•

vertex buffer object	


•
•
•
•

index [1-4]	


exactly 4 children per node (1-NE, 2-NW, 3-SE, 4SW)	
...
Cylindrical #FAIL
Linear sample density	

Non linear perimeter
6 Gnomonic Projections

Wolfram is your friend	

http://mathworld.wolfram.com/GnomonicProjection.html
Cube to Sphere
Normalize each vertex	

Add altitude

v = normalize(v) * (planet radius + altitude)
So Far
• Dealt with LOD, splitting	

• Found a suitable projection system	

• Triangulated the terrain meshes	

• Each pat...
Redundancy
• Several representations of the same data	

• Increased dataset size, up to 2x	

• No way around for textures	...
EP + 1
EP + 1 Storage
• Reprocess the entire dataset	

• Write all samples as chunks	

• Arrange by LOD levels	

• Don’t write du...
Eye Candy 1 - Lighting

• Normals are crucial	

• Light intensity directly proportional to LoN
Calculating Normals
• Use a single chunk of vertexes	

• Rotate and scale accordingly	

• Attach heightmap as texture	

• ...
Normal Map
Heights stored in 16bit: Red+Green channels

Non spherical coordinate system
Planetary Normals
Get rotation from unit vector to the vertex position

Apply same rotation to normal vector
Water Specular	


•
•

Extract watermask from BMNG	

Single bit, store in blue component of heightmap (24 bit total)
Eye Candy 2 - Atmosphere
• Two types of scattering, Mie & Rayleigh	

• Small molecules, O2, O3, etc - Rayleigh	

• Aerosol...
Atmospheric Shader
Phase function - Amount of scattering for camera angle

Outscattering - Optical depth of ray from entry...
Atmospheric Shader
Atmospheric Shader
Atmospheric Shader
Fractal Noise
Adding in missing detail
Fractal Noise
Adding in missing detail

Height = dataset height + noise heightmap
Fun!
• Add gravity, each object is a node, it’s easy	

• Export from SketchUp to .obj, auto
triangulate + auto normals	


...
Just for Fun
Final Results
Thanks!
Upcoming SlideShare
Loading in...5
×

Building Worlds - Codebits

1,126

Published on

Published in: Technology, Art & Photos
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,126
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Building Worlds - Codebits

  1. 1. Building Worlds Filipe Varela filipe.varela@co.sapo.pt
  2. 2. Overview • • • • • Topographic Datasets Geometry partitioning Tesselating meshes Level of Detail (LOD) Data structures for geometry • • Projections • • • Lighting Efficient Out of Core fetches Shaders Procedural detail
  3. 3. Basics - drawing path Topography Normals Bathymetry Shaders Textures
  4. 4. Topography Shuttle Radar Topography Mission (SRTM) Blue Marble Next Generation (BMNG)
  5. 5. SRTM Resolution: 90m/pixel Coverage: 60ºS to 60ºN Lat, 360º Long Samples: 144000x432000, 16 bit ~115 GiB Much higher resolutions available for limited areas
  6. 6. Others Mars: MOLA + Viking Moon: LOLA + Clementine Mercury: Messenger + Mariner Venus: Magellan + Venera A couple more...
  7. 7. Back to Basics 432000x144000 samples (not counting poles) 16bit/sample topography+bathy 24bit/sample textures (+ 173GB) 24bit/sample normals (+ 173GB) Add specular byte to topo+bathy Totals 3x173 GB = 519 GB @ 90m/sample
  8. 8. Preparing the Data What exactly do you need to achieve? How much effort are you willing to put in?
  9. 9. Terrain Rendering 101 • • Data is but height samples - Mesh tesselation Too much data to draw everything every frame Level of Detail
  10. 10. Common Methods • • • • Realtime Optimally Adapting Meshes Geomipmapping Chunked Level of Detail (LOD) Geometry Clipmaps
  11. 11. Chunked LOD
  12. 12. Tesselating Meshes Several options - I picked triangle strips
  13. 13. LOD - Level of Detail Split each chunk into 4 when LOD increases Chunk side vertex count must be 2^n
  14. 14. LOD - Level of Detail Connect patches by copying: left of right to right of left new count is (2^n)+1
  15. 15. LOD - Tricks Optimize patch side vertex count for performance You want few GPU ops with a lot of data You don’t want the GPU to ‘swap’ from VRAM to RAM
  16. 16. Meet the Quadtree
  17. 17. Quadtree Basics • • vertex buffer object • • • • index [1-4] exactly 4 children per node (1-NE, 2-NW, 3-SE, 4SW) last drawn timestamp vertex buffers for geometry, textures, normals Search: O(n), n = LOD level (follow pointers)
  18. 18. Cylindrical #FAIL Linear sample density Non linear perimeter
  19. 19. 6 Gnomonic Projections Wolfram is your friend http://mathworld.wolfram.com/GnomonicProjection.html
  20. 20. Cube to Sphere Normalize each vertex Add altitude v = normalize(v) * (planet radius + altitude)
  21. 21. So Far • Dealt with LOD, splitting • Found a suitable projection system • Triangulated the terrain meshes • Each patch of terrain - Vertex Buffer Object
  22. 22. Redundancy • Several representations of the same data • Increased dataset size, up to 2x • No way around for textures • EP + 1 for everything else
  23. 23. EP + 1
  24. 24. EP + 1 Storage • Reprocess the entire dataset • Write all samples as chunks • Arrange by LOD levels • Don’t write duplicate samples • Reading a chunk is now fseek+fread
  25. 25. Eye Candy 1 - Lighting • Normals are crucial • Light intensity directly proportional to LoN
  26. 26. Calculating Normals • Use a single chunk of vertexes • Rotate and scale accordingly • Attach heightmap as texture • Morph (planet radius + texture height) • Sample neighboring heights for normal
  27. 27. Normal Map Heights stored in 16bit: Red+Green channels Non spherical coordinate system
  28. 28. Planetary Normals Get rotation from unit vector to the vertex position Apply same rotation to normal vector
  29. 29. Water Specular • • Extract watermask from BMNG Single bit, store in blue component of heightmap (24 bit total)
  30. 30. Eye Candy 2 - Atmosphere • Two types of scattering, Mie & Rayleigh • Small molecules, O2, O3, etc - Rayleigh • Aerosols - Mie (gray when it rains, pollution haze, etc)
  31. 31. Atmospheric Shader Phase function - Amount of scattering for camera angle Outscattering - Optical depth of ray from entry point to camera Inscattering - Amount of light added by scattering on planet surface into camera
  32. 32. Atmospheric Shader
  33. 33. Atmospheric Shader
  34. 34. Atmospheric Shader
  35. 35. Fractal Noise Adding in missing detail
  36. 36. Fractal Noise Adding in missing detail Height = dataset height + noise heightmap
  37. 37. Fun! • Add gravity, each object is a node, it’s easy • Export from SketchUp to .obj, auto triangulate + auto normals • Write a script to convert .obj into a vertex buffer object • Drop in a dead simple shader
  38. 38. Just for Fun
  39. 39. Final Results
  40. 40. Thanks!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×