1 / 28

Procedural Graphics with DirectX 11

Procedural Graphics with DirectX 11. James Reid. Meshes. A mesh is what all the textures are laid on. Meshes are deformed to give us the nice terrains seen in games today using height maps or procedural methods. More vertices require more GPU power!

jaafar
Download Presentation

Procedural Graphics with DirectX 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Procedural Graphics with DirectX 11 James Reid

  2. Meshes • A mesh is what all the textures are laid on. • Meshes are deformed to give us the nice terrains seen in games today using height maps or procedural methods. • More vertices require more GPU power! • Goal: reduce number of vertices in a mesh without sacrificing quality.

  3. Height Maps • Advantages: • Easily modeled by an artist. • Easily implemented. • Normal maps can be paired for lighting. • Use far less memory than meshes. • Easier on the CPU/GPU. • Disadvantages: • Only able to show 256 distinct heights in grayscale. • Can quickly consume hard disk space when having to store height/normal/tangent/etc maps. • Image: The Elder Scrolls V: Skyrim

  4. What is Procedural? • From Wikipedia: “content generated algorithmically rather than manually” • Content is created at run time, not compile time or stored in file. • Most games use height maps and models. • Image: The Elder Scrolls III: Morrowind

  5. Why Use Procedural? • Memory usage is far less on both the hard disk and in RAM. • Size limitations are much larger than those involving height maps. • Allows games to be released on a single CD/DVD. • Makes downloadable games more manageable. • Image: Minecraft

  6. Basis For Procedural • Noise algorithms. • Perlin • Voronoi • Can be implemented in different dimensions. • 1D • 2D (used for terrain/clouds) • 3D (used for clouds the user can fly through)

  7. How Noise Works • Summing up of static maps generated with pseudorandom numbers. • Basic Algorithm: double t = 0; double amplitude = 1; double freq = m_dFrequency; for(inti = 0; i < m_nOctaves; i++) { t += GetValue(x * freq + m_nSeed, y * freq + m_nSeed) * amplitude; amplitude *= m_dPersistence; freq *= 2; } return t;

  8. Using Perlin Noise • Start with a mesh. • Generate a height field using Perlin Noise. • Assign the coordinate for each pair in the mesh. • Result:

  9. Scalability • Makes very convincing terrain. • Issues: • High number of vertices. • Static meshes can’t adapt to camera’s view. • Solution: • Use a quadtree structure to store the data.

  10. Quadtree Structure • Similar to binary trees, but has 4 nodes instead of 2.

  11. Quadtree Mesh

  12. Uses For The Quadtree • View frustum culling. • Level of detail (LOD). • Collision detection. • Grid location. • Reducing total vertices.

  13. View Frustum • Field of view the camera has. • Used in culling and LOD.

  14. Frustum Culling • Removing of primitives that are not seen from the graphics pipeline to increase performance. • More types: • Backface • Contribution • Occlusion

  15. Level of Detail (LOD) • The amount of detail shown being based on the camera’s view point. • Where DirectX 11 makes a difference. • Use of the geometry shader.

  16. Vertex Interpolation Error • When changing LOD the new vertices may cause popping. • Several solutions to this, most common is to just take the midpoint of both vertices.

  17. Texture Morphing • LOD can cause textures to not line up and varying levels of detail. • Solution: Use texture blending to hide the effect.

  18. Vertex Reduction • Use minimum number of vertices based on slope of terrain. • Image: Shamus Young (Twenty Sided) • Top right: no optimization • Bottom left: optimized grid, removed about two-thirds of total vertices (Huge performance increase!)

  19. Tessellation • Started in DirectX 10 – can be controlled by user with DirectX 11 • Take a mesh and add more primitives to smooth it out.

  20. Putting It All Together • Use CPU to determine LOD and any culling to be done based on view frustum. • Use noise algorithm in real time on the GPU to generate height field. • Remove any unwanted vertices based on slope of terrain (e.g. flat areas will use two triangles instead of filling up the mesh). • Morph the textures at the LOD breaks. • Tessellate the mesh in high detail locations.

  21. Examples • http://www.youtube.com/watch?v=rL8zDgTlXso • Start at 3:20 • http://www.youtube.com/watch?annotation_id=annotation_790483&feature=iv&src_vid=OiGADgezjC8&v=oUSdSjnDB_E • Start at 0:49 • http://www.youtube.com/watch?v=uzXB0m3_MHQ • Start at 0:25

  22. References • Schneider, J., & Westermann, R. (2006). Gpu-friendly high-quality terrain rendering., Computer Graphics and Visualization Group, TechnischeUniversitätMünchen, Munich, Germany. • Yusov, E., & Turlapov, V. (2007). Gpu-optimized efficient quad-tree based progressive multiresolution model for interactive large scale terrain rendering., Department of Computational Mathematics and Cybernetics, Nizhny Novgorod State University, Nizhny Novgorod, Russia. • Perlin, K. (2001). Improving noise., Media Research Laboratory, Dept. of Computer Science, New York University , New York City, NY, . • Verts, W. T., & Hill, Jr., F. S. (1989). Quadtree meshes, COINS Department, ECE Department, University of Massachusetts, Amherst, MA, . • Olsen, J. (2004). Realtime procedural terrain generation., Department of Mathematics And Computer Science (IMADA), University of Southern Denmark, . • Bernhardt, A., Maximo, A., Velho, L., Hnaidi, H., & Cani, M. (2011). Real-time terrain modeling using cpu–gpu coupled computation., INRIA, Grenoble Univ., Univ. Lyon 1, IMPA, France, Brazil.

More Related