Your SlideShare is downloading. ×
Building Worlds - Codebits
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Building Worlds - Codebits

1,068
views

Published on

Published in: Technology, Art & Photos

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Building Worlds Filipe Varela filipe.varela@co.sapo.pt
  • 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. Basics - drawing path Topography Normals Bathymetry Shaders Textures
  • 4. Topography Shuttle Radar Topography Mission (SRTM) Blue Marble Next Generation (BMNG)
  • 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. Others Mars: MOLA + Viking Moon: LOLA + Clementine Mercury: Messenger + Mariner Venus: Magellan + Venera A couple more...
  • 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. Preparing the Data What exactly do you need to achieve? How much effort are you willing to put in?
  • 9. Terrain Rendering 101 • • Data is but height samples - Mesh tesselation Too much data to draw everything every frame Level of Detail
  • 10. Common Methods • • • • Realtime Optimally Adapting Meshes Geomipmapping Chunked Level of Detail (LOD) Geometry Clipmaps
  • 11. Chunked LOD
  • 12. Tesselating Meshes Several options - I picked triangle strips
  • 13. LOD - Level of Detail Split each chunk into 4 when LOD increases Chunk side vertex count must be 2^n
  • 14. LOD - Level of Detail Connect patches by copying: left of right to right of left new count is (2^n)+1
  • 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. Meet the Quadtree
  • 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. Cylindrical #FAIL Linear sample density Non linear perimeter
  • 19. 6 Gnomonic Projections Wolfram is your friend http://mathworld.wolfram.com/GnomonicProjection.html
  • 20. Cube to Sphere Normalize each vertex Add altitude v = normalize(v) * (planet radius + altitude)
  • 21. So Far • Dealt with LOD, splitting • Found a suitable projection system • Triangulated the terrain meshes • Each patch of terrain - Vertex Buffer Object
  • 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. EP + 1
  • 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. Eye Candy 1 - Lighting • Normals are crucial • Light intensity directly proportional to LoN
  • 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. Normal Map Heights stored in 16bit: Red+Green channels Non spherical coordinate system
  • 28. Planetary Normals Get rotation from unit vector to the vertex position Apply same rotation to normal vector
  • 29. Water Specular • • Extract watermask from BMNG Single bit, store in blue component of heightmap (24 bit total)
  • 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. 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. Atmospheric Shader
  • 33. Atmospheric Shader
  • 34. Atmospheric Shader
  • 35. Fractal Noise Adding in missing detail
  • 36. Fractal Noise Adding in missing detail Height = dataset height + noise heightmap
  • 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. Just for Fun
  • 39. Final Results
  • 40. Thanks!