Download presentation
Presentation is loading. Please wait.
Published byViolet Montgomery Modified over 9 years ago
1
1 Further Terrain Rendering and Level of Detail Lecture 8 - Week 4 Advanced Programming for 3D Applications CE00383-3
2
22 Fractal Terrain Based on subdivision of a course polygon mesh Based on subdivision of a course polygon mesh Each subdivision adds detail to the mesh in a random way Each subdivision adds detail to the mesh in a random way Algorithm (starting with a triangular mesh): Algorithm (starting with a triangular mesh): –Split each edge, and shift the new vertex up or down by a random amount –Subdivide the triangles using the new vertices –Repeat Also algorithms for quadrilateral meshes Also algorithms for quadrilateral meshes http://www.gameprogrammer.com/fractal.ht ml http://www.gameprogrammer.com/fractal.ht ml
3
33 Subdivision Method No 1 Note: Works on any triangular mesh - does not have to be regular or have equal sized triangles.
4
44 Subdivision Method No 2 Generates a triangle bintree from the top down Generates a triangle bintree from the top down Useful for LOD, Useful for LOD, Ideally, works for right- angled isosceles triangles Ideally, works for right- angled isosceles triangles
5
55 Subdivision Method No 3 Assume quadrilateral meshes Assume quadrilateral meshes
6
66 Rendering Terrain Coarser Finer
7
77 Rendering Terrain Adaptive Representation Bilinear Patch
8
88 Rendering Terrain Adaptive Representation T-Junction
9
99 Triangle Bintrees Binary trees in which: Binary trees in which: –Each node represents a right-angled isosceles triangle –Each node has two children formed by splitting from the right angle vertex to the midpoint of the baseline –The leaf nodes use vertices from the original height field Another way to build a spatial partitioning tree, but particularly well suited to simplification algorithms Another way to build a spatial partitioning tree, but particularly well suited to simplification algorithms –Easy to maintain neighbor information –Easy to avoid T-vertices
10
1010 1 2 3 4 6 5 87 1013 14 1112 9 21 3456 7891011121314 Triangle Bintree Example
11
1111 Bintree Data Structure Parent and child pointers Parent and child pointers Neighbors Neighbors –A left neighbor, a right neighbor, and a base neighbor –Note that the base and right angle give us a way to orient the triangle –Neighbors are not necessarily at your own level Later, error bounds that say how much variation in height there is in your children Later, error bounds that say how much variation in height there is in your children
12
1212 1 2 3 4 6 5 87 10 9 21 3456 789 11121314 Cuts
13
1313 87 10 9 Neighbors 5: left neighbor 6, right neighbor 9 5: left neighbor 6, right neighbor 9 6: left neighbor 8, right neighbor 5 6: left neighbor 8, right neighbor 5 7: left neighbor 8, base neighbor 10 7: left neighbor 8, base neighbor 10 8: base neighbor 6, right neighbor 7 8: base neighbor 6, right neighbor 7 9: base neighbor 5, left neighbor 10 9: base neighbor 5, left neighbor 10 10: base neighbor 7, right neighbor 9 10: base neighbor 7, right neighbor 9 Note that 8 is 6’s left neighbor but 6 is 8’s base neighbor Note that 8 is 6’s left neighbor but 6 is 8’s base neighbor –If you are someone’s left/right/base neighbor they are not always your right/left/base neighbor In other words, neighbors need not come from the same level in the tree In other words, neighbors need not come from the same level in the tree 6 5
14
1414 1 2 3 4 6 5 87 10 9 21 3456 789 11121314 Cuts Are Not Always Equal Note the T-vertex - causes cracks in rendering
15
1515 Generating Cuts Cuts are generated by a sequence of split or merge steps Cuts are generated by a sequence of split or merge steps –Split: Drop the cut below to include your children –Merge: Lift the cut up above two children To avoid T-vertices, some splits lead to other, forced, splits To avoid T-vertices, some splits lead to other, forced, splits An LOD algorithm chooses which steps to apply to generate a particular triangle count or error rate An LOD algorithm chooses which steps to apply to generate a particular triangle count or error rate
16
1616 21 3456 7891011121314 A Split A split cuts a triangle in two by splitting its base edge A split cuts a triangle in two by splitting its base edge –If the base edge is on a boundary, just split, as shown –If the base edge is shared, additional splits are forced Add a new triangle to the mesh Add a new triangle to the mesh 6
17
1717 Forced Splits Triangles are always split along their base Triangles are always split along their base Hence, must also be able to split the base neighbor Hence, must also be able to split the base neighbor –Requires neighbors to be mutual base neighbors –If they are not base neighbors, even more splits are needed –Simple recursive formulation
18
1818 87 10 9 Merges A diamond is a merge candidate if the children of it’s members are in the triangulation A diamond is a merge candidate if the children of it’s members are in the triangulation –The children of the 7-10 diamond below are candidates –Look for parents of sibling leaf nodes that are base neighbors or have no base neighbors Reduces the triangle count Reduces the triangle count 21 3456 7891011121314
19
1919 Refinement LOD Algorithm Start with the base mesh Start with the base mesh Repeatedly split triangles until done Repeatedly split triangles until done –Stop when a specific triangle count is reached, or … –Stop when error is below some amount To guide the split order, assign priorities to each split and always do the one with the highest priority To guide the split order, assign priorities to each split and always do the one with the highest priority –After each split, update priorities of affected triangles –Sample priority: High priority to splits that will reduce big errors What is the complexity of this? (Roughly) What is the complexity of this? (Roughly) A similar algorithm works by simplifying the mesh through merge operations. Why choose one over the other? A similar algorithm works by simplifying the mesh through merge operations. Why choose one over the other?
20
2020 Fractal Terrain Details The original mesh vertices don’t move, so it defines the overall shape of the terrain (mountains, valleys, etc) The original mesh vertices don’t move, so it defines the overall shape of the terrain (mountains, valleys, etc) There are options for choosing where to move the new vertices There are options for choosing where to move the new vertices –Uniform random offset –Normally distributed offset – small motions more likely –Procedural rule – eg Perlin noise making patterns from pseudo- random numbers making patterns from pseudo- random numbers If desired, boundary vertices can be left unmoved, to maintain the boundary edge If desired, boundary vertices can be left unmoved, to maintain the boundary edge
21
2121 Fractal Terrains Very jagged terrain
22
2222 Populating Terrain Coloring terrain: Coloring terrain: –Paint texture maps –Base color on height (with some randomness) Trees: Trees: –Paint densities, or randomly set density –Then place trees randomly within regions according to density Rivers (and lakes): Rivers (and lakes): –Trace local minima, and estimate catchment areas (more later…)
23
2323 Terrain Generation Trade-Offs Control vs Automation: Control vs Automation: –Painting gives most control –Fractal terrain next best control because you can always specify more points –Random methods give little control - generate lots and choose the one you like Generate on-the-fly: Generate on-the-fly: –Random points and fractal terrain could be generated on the fly, but fractal terrain generation is quite slow –Tilings can also be generated on the fly
24
2424 Static LOD Depending on the roughness of the terrain and the application, 5%-50% of the vertices and triangles can be removed Depending on the roughness of the terrain and the application, 5%-50% of the vertices and triangles can be removed –With 536.805.378 triangles still more than 200.000.000 triangles to draw in best case. Frustum culling further reduces number of triangles to draw Frustum culling further reduces number of triangles to draw In most cases we still draw the terrain at full resolution near the far plane In most cases we still draw the terrain at full resolution near the far plane
25
2525 View-Dependent Dynamic LOD Dynamic simplification of visible part of the terrain Dynamic simplification of visible part of the terrain A mountain observed from a distance of 10 km requires a higher tessellation than when observed from a distance of 100 km A mountain observed from a distance of 10 km requires a higher tessellation than when observed from a distance of 100 km The quality of the tessellation can be changed at run time to achieve constant frame rates The quality of the tessellation can be changed at run time to achieve constant frame rates Terrains can be altered at run time Terrains can be altered at run time
26
2626 Terrain LOD Terrain poses problems for static LOD methods Terrain poses problems for static LOD methods –Must have high resolution in the near field, and low resolution in the distance, all in one model Dynamic LOD methods are the answer Dynamic LOD methods are the answer –All based on the idea of cuts through a tree of potential simplifications ROAM algorithm is a good example ROAM algorithm is a good example –Other continuous LOD algorithms are similar in style An alternative is to create fixed LODs for sub- regions and figure out how to join them together An alternative is to create fixed LODs for sub- regions and figure out how to join them together
27
2727 Terrain LOD Algorithms Triangle bintree based Triangle bintree based –‘ROAMing Terrain: Real-time Optimally Adapting Meshes’ – Duchaineau et al. Quad tree based Quad tree based –E.g. ‘Real-Time, Continuous Level of Detail Rendering of Height Fields’ – Lindstrom et al. Progressive mesh based Progressive mesh based –E.g. ‘Smooth View-Dependent Level-of-Detail Control and its Application to Terrain Rendering’ – Hoppe Geo Mipmapping Geo Mipmapping –‘Fast Terrain Rendering Using Geometrical MipMapping’ – de Boer
28
2828 Rendering Fractal Landscapes Alternative methods: Alternative methods: –Polygon rendering using graphics hardware Tesselate the height field Tesselate the height field Draw each triangle separately or Draw each triangle separately or Perform adaptive level-of-detail rendering Perform adaptive level-of-detail rendering –Ray-tracing A) Tesselate the height field and trace the triangle mesh A) Tesselate the height field and trace the triangle mesh B) Directly trace the fractal (QEAB) B) Directly trace the fractal (QEAB) Check out http://www.vterrain.org/
29
2929 Rendering Fractal Landscapes Polygon rendering Polygon rendering –Tesselation is given implicitely or can be generated A height field over a rectangular domain, values are given at discrete sample points
30
3030 Rendering Fractal Landscapes Rendering lit and textured triangles Rendering lit and textured triangles –Vertices, colors, texture coords, normals Textured onlyTextured and shaded
31
3131 Rendering Fractal Landscapes Rendering triangles using graphics hardware Rendering triangles using graphics hardware –Render triangle strips: v 0,v X,v 1,v X+1,v 2,v X+1,... Triangle defined by new point and previous two points Triangle defined by new point and previous two points Each vertex is rendered only once Each vertex is rendered only once –Still have to send every vertex even in smooth regions –Popping artefacts where triangles below pixel size V0V0 V2V2 V1V1 V3V3... V X-1 VXVX V X+2 V X+1 V X+3
32
3232 Rendering Fractal Landscapes LOD-Rendering LOD-Rendering –Adaptively refine the mesh with regard to the current view
33
3333 Rendering Fractal Landscapes LOD-Rendering LOD-Rendering –Top-down or bottom-up approach –Hierarchically partition the mesh –Start with coarse resolution and adaptively refine until desired level-of-detail is reached –Start with original mesh and successively merge triangles –Consider world space and/or screen space deviation –Re-build mesh for every frame
34
3434 Rendering Fractal Landscapes ROAM: Real-Time Optimally Adapting Meshes ROAM: Real-Time Optimally Adapting Meshes –Exploits triangle bintree structure: split along base edge –Valid triangulation has to be guaranteed Two triangles have no overlap Two triangles have no overlap Overlap at common vertex/common edge Overlap at common vertex/common edge Critical case
35
3535 Rendering Fractal Landscapes The recursive split operation The recursive split operation –Triangle to be split has coarser base neighbor Force split of base neighbor first Force split of base neighbor first Recursively force further splits until diamond is found Recursively force further splits until diamond is found Diamond can be split without further splits Diamond can be split without further splits
36
3636 Rendering Fractal Landscapes Error criterion for split operation Error criterion for split operation –Deviation in world space Difference between height value at center vertex and average of left and right vertex Difference between height value at center vertex and average of left and right vertex Recursively pull deviation values from bottom to top Recursively pull deviation values from bottom to top –Deviation in screen space Determine upper bound for screen space length of world space difference vector (0,d,0) Determine upper bound for screen space length of world space difference vector (0,d,0)
37
3737 Rendering Fractal Landscapes Ray-Tracing Ray-Tracing –Ray-tracing triangle meshes Trace rays until a triangle is hit Trace rays until a triangle is hit Implicit occlusion culling Implicit occlusion culling
38
3838 Rendering Fractal Landscapes Ray-Tracing - performance issues Ray-Tracing - performance issues –Mesh data structure has to be stored –Hierarchical representation necessary for improved intersection test Octree or kD-tree Octree or kD-tree max/min(H) Store max/min heights within subregion Skip regions below minimal height of ray Employ ray coherences
39
3939 Rendering Fractal Landscapes Rendering polygonal models – analysis Rendering polygonal models – analysis –Aliasing due to undersampling of small features –No exploitation of the fractal lod-nature © Images K. Musgrave
40
4040 Other Issues Terrain Texturing Terrain Texturing Terrain Lighting Terrain Lighting Camera Animation and Fly-through Camera Animation and Fly-through SkyBox SkyBox Terrain following (a form of collision) Terrain following (a form of collision) –Maintaining characters and objects on top of Terrain
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.