3d graphics 1
play

3D Graphics 1 Simulation Engines 2008 Chalmers University of - PowerPoint PPT Presentation

3D Graphics 1 Simulation Engines 2008 Chalmers University of Technology Markus Larsson markus.larsson@slxgames.com 08-11-17 Simulation Engines 2008, Markus Larsson 1 3D Graphics 08-11-17 Simulation Engines 2008, Markus Larsson 2


  1. 3D Graphics 1 Simulation Engines 2008 Chalmers University of Technology Markus Larsson markus.larsson@slxgames.com 08-11-17 Simulation Engines 2008, Markus Larsson 1

  2. 3D Graphics 08-11-17 Simulation Engines 2008, Markus Larsson 2

  3. Questions ? 08-11-17 Simulation Engines 2008, Markus Larsson 3

  4. Once again...  Real-time 3D graphics is all about triangles.  Properties of a renderable triangle.  Vertices  Normals  Vertex order  (Tangents)  (Binormals/Bitangents)  (...)  3D graphics is the art of coloring triangles. 08-11-17 Simulation Engines 2008, Markus Larsson 4

  5. 3D Graphics is also about...  Vectors  Matrices  Quaternions  Loads and loads of mathematical operations on the above.  If you feel that you are shaky on vector algebra, take a look in your old math books. You will thank yourself later. 08-11-17 Simulation Engines 2008, Markus Larsson 5

  6. Categorization of 3D entities  Static  Objects that are immutable  Good candidates for extreme optimization  Dynamic  Moves or changes over time  Harder to optimize  Animated  Could be either static or dynamic  The vertex object can not be locked 08-11-17 Simulation Engines 2008, Markus Larsson 6

  7. Spatial data structures  Demands on real-time graphics grow rapidly.  Modern graphics hardware is:  Fast  Programmable  Has plenty of memory  However...  ”The fastest polygon to render is the one never sent down to the accelerator's pipeline.” 08-11-17 Simulation Engines 2008, Markus Larsson 7

  8. Words of wisdom "25k batches/s @ 100% 1GHz CPU" (i 60fps, 417 batches) 08-11-17 Simulation Engines 2008, Markus Larsson 8

  9. Spatial data structures  A spatial data structure:  Orders geometric data by its location  Is often hierarchic, which allows O(log n) searches and rapidly discarding irrelevant data.  Spatial data structures can be expensive to construct. Construction is often preprocessed.  Separate structures for static and dynamic data. 08-11-17 Simulation Engines 2008, Markus Larsson 9

  10. Bounding volume hierarchies  In general: better fit = more memory and more expensive intersection algorithm.  Axis-Aligned Bounding Boxes (AABB)  The simplest type of bounding box.  Enclosed by a model's minimum and maximum values along the x-, y- and z-axis.  Ordinarily described by a center and the distance from the center to the edge along each axis. 08-11-17 Simulation Engines 2008, Markus Larsson 10

  11. Bounding volume hierarchies  Oriented Bounding Boxes (OBB)  Similar to AABB's, but rotated to fit the model more tightly.  Ordinarily described by a center, three normalized vectors and the distance from the center to the edges.  Discrete Oriented Polytope (k-DOP)  Consists of k/2 normalized plane-normals associated with two scalars. Together they describe the volume between the two planes:  The k-DOP is the volume enclosed by all planes. min : n i ⋅ x  d i min = 0 max : n i ⋅ x  d i max = 0 pi i pi i 08-11-17 Simulation Engines 2008, Markus Larsson 11

  12. Outdoor scenery  Outdoor scenery is rarely represented in the same fashion as indoor scenery  The main problem is the scale of outdoor scenery  Outdoor scenery often needs special considerations for optimization  Continuous level of detail 08-11-17 Simulation Engines 2008, Markus Larsson 12

  13. Heightfields  The most common representation of a terrain  Generally stored in a grayscale 2D texture  Often divided into several smaller objects and rendered as series of triangle strips 08-11-17 Simulation Engines 2008, Markus Larsson 13

  14. Cracks in the terrain  Beware of cracks in the terrain when rendering with non-uniform tessellation  Different levels of detail  Limited numerical accuracy in 3D card or API  Can be avoided by drawing “skirts”  Multiple techniques for this... 08-11-17 Simulation Engines 2008, Markus Larsson 14

  15. The ROAM algorithm The Realtime Optimally Adapting Meshes algorithm was designed as  a high-performance, flexible terrain rendering algorithm with continuous LOD Uses a special data structure called a “triangle bintree” and two  priority queues that drive the split and merge operations of patches in the height-field based on the location of the camera 08-11-17 Simulation Engines 2008, Markus Larsson 15

  16. Trends in terrain rendering  On modern hardware, algorithms like ROAM use unnecessarily much CPU-power  Fill rate and triangle-drawing capabilities on modern 3D hardware are very good  Nowadays, terrain rendering is mostly done by grouping blocks of terrain patches into vertex buffer objects of just a few detail levels, and culled using only view frustum culling 08-11-17 Simulation Engines 2008, Markus Larsson 16

  17. Volumetric terrain rendering  Uses voxels (volume pixels)  Can be used with 3D scans  Can be used to render height-maps  Potentially very high resolution  Used in Comanche: Maximum overkill, 1992  No hardware support 08-11-17 Simulation Engines 2008, Markus Larsson 17

  18. Skyboxes and skydomes Used to render the background of 3D scenes   Waste of resources to draw small background objects as meshes Drawn in the following way   Clear depth and color buffers  Apply camera transformation  Disable the depth buffer test and writes  Draw the skybox or skydome  Enable depth buffer test and writes  Draw the rest of the scene 08-11-17 Simulation Engines 2008, Markus Larsson 18

  19. Indoor scenery  Data is organized in a very different manner than for outdoor scenery  Very different scales than for outdoor scenery  The existence of enclosing walls and ceilings give excellent opportunities for culling  Thanks to the smaller scale, requirements on detail are much greater than outdoors  Tim Sweeney estimates that we have a factor of 10.000 to 40.000 to go before we are able to render photo-realistic indoor environments 08-11-17 Simulation Engines 2008, Markus Larsson 19

  20. Uniform grids  The world is split into uniformly sized voxels (in 3D) or squares (in 2D).  Very easy to implement.  Relatively efficient with ray-grid- intersection tests, therefore often used for ray-tracing http://www.cs.yorku.ca/~amana/research/grid.pdf   Useful for dynamic data. 08-11-17 Simulation Engines 2008, Markus Larsson 20

  21. Binary space partitioning trees  Have been popular since they were used in DOOM.  Was originally designed to solve depth sorting in the late 60's.  Sorts geometry by splitting along planes.  Axis-aligned  Also known as KD-tree.  Ordinarily built by alternating the splitting axis.  Polygon-aligned  The most commonly used variant in games 08-11-17 Simulation Engines 2008, Markus Larsson 21

  22. Quad trees  Two-dimensional representation.  Similar to KD-trees, but always split in the middle.  Useful for representing outdoor environments which are represented with height- maps. 08-11-17 Simulation Engines 2008, Markus Larsson 22

  23. Octtrees ● Like quad trees, but in 3D. ● Efficient for large three- dimensional spaces. ● Often have criteria for how many children are needed in a voxel before splitting it as well as how many levels of hierarchy are allowed. ● Structures where the voxels do not necessarily have the same size are called loose octtrees/quadtrees. 08-11-17 Simulation Engines 2008, Markus Larsson 23

  24. Culling  Culling is the act of removing polygons that do not need to be rendered.  Can be done by either the CPU or the GPU.  Culling on CPU generally saves bandwidth.  Culling on GPU (probably) saves CPU-time.  Modern hardware stores geometry in vertex buffers, and encourages culling per object instead of per polygon, because that allows reusing of vertex buffer objects. 08-11-17 Simulation Engines 2008, Markus Larsson 24

  25. Software vs. Hardware culling GPU CPU Viewport clipping View frustum culling Z-buffer testing Occlusion culling Backface culling Backface culling 08-11-17 Simulation Engines 2008, Markus Larsson 25

  26. Backface culling  Ordinarily done in the geometry stage of the pipeline. All data is sent to the GPU, but only visible pixels are rasterized.  A polygon is backfacing if n·v < 0.  The amount of rendered triangles is normally reduced by 50%. 08-11-17 Simulation Engines 2008, Markus Larsson 26

  27. View frustum culling  Culls objects that are outside of the view frustum.  The view frustum is volume enclosed by six planes that is visible from the camera.  Very efficient when used on a hierarchic spatial data structure. 08-11-17 Simulation Engines 2008, Markus Larsson 27

  28. Example: View frustum culling over an octtree  The view frustum is represented by six planes that point to the inside of the enclosed volume.  Recurse over the following algorithm for voxels in the octtree, beginning with the voxel that contains the entire tree:  If the voxel is outside of any of the planes, do not draw it.  If the voxel is inside all of the planes, draw all of its contents.  If the voxel intersects any of the planes, perform this test for all of its children. 08-11-17 Simulation Engines 2008, Markus Larsson 28

Recommend


More recommend