1. The Terrain of Angel Cunado Lead Engine Programmer
2. Kingdom Under Fire IIMMO3rd Person ActionReal Time StrategyMMOARTS
3. Kingdom Under Fire IITerrain requirements 3rd person camera (close view, high detail) RTS camera (large, instant displacements) Large continuous world (streaming) Direct3D 9 class HW with ps3
4. AgendaGeometryTexturingStorage, Streaming and Synthesis (overview)
5. Terrain Geometry
6. Terrain Geometry
7. Terrain GeometryHeight map based8Km x 8Km terrain patch around the cameraGeometry resolution down to 12.5cmBrute force rendering → 8,589,934,592 tri.
8. Terrain GeometryIts all about finding the right LOD techniqueWe use “Geometry Clipmaps” “Geometry clipmaps: Terrain rendering using nested regular grids.” Siggraph 2004, F. Losasso, H. Hoppe “Terrain rendering using GPU base geometry clipmaps.” 2005, A. Asirvathan, H. Hoppe, GPU Gems 2
9. Geometry ClipmapsNested regular grids (2n-2)2 quads eachRoughly centered aroundthe cameraGrid meshes must beprogressively updated asthe camera moves
10. Geometry Clipmaps
11. Geometry ClipmapsKUFII World Terrain n = 8, 254x254 quads, 129.032 triangles each clipmap 8 Geometry clipmaps – From 32m x 32m with 12.5cm resolution – To 4km x 4km with 16m resolution Total: 774.192 triangles
12. Frustum CullingSplit each clipmapinto 12 nearly squarepatches4 different indexbuffers 2n-2-1 x 2n-2-1, 2n-2-1 x 2n-2 2n-2 x 2n-2-1 2n-2 x 2n-2
14. Geometry ClipmapsGeomorphing needed to avoid gaps betweenconsecutive clipmaps.Geometry Clipmap update This is the tricky part... Store vertex elevations in a texture Incremental texture updates as the camera moves Please check the reference docs for details...
15. Normal Map
16. Normal ClipmapNormals stored intexture clipmapsGenerated atruntime fromelevation data.8 LODs8192m x 8192m1024 x 1024 texels3cm details
17. Normal clipmapStored in a volume texture.One clipmap LOD → onevolume slicePS calculates the right sliceand UVs Based in distance to camera and derivativesCompressed to DXT5
19. TexturingThis a 20km x 20kmsection of KUFIIterrain.Texture details downto ~3mmEquivalent to 26,000,000 texels.
20. Texture SplattingClassical terrain texturing methodCombine 2 repeating tiles using a lowerresolution blend map.Use multipass render..or multitexturing. x
21. Texture Splatting4096 x 4096 blend map for a 20Km x 20Kmresults in ~5x5m per texel.KUFII art team wanted ~0.1x0.1m per texel
22. Texture Splatting4096 x 4096 blend map for a 20Km x 20Kmresults in ~5x5m per texel.KUFII art team wanted ~0.1x0.1mEasy... just use a texture clipmap for the blendmap!
23. Blend Clipmap
24. Texture SplattingWhat if we want to use 64different tiles?We need 63 blendchannels...16 passes with 4 texturetiles each?!
25. Texture SplattingWhat if we want our tilesto also support bumpmapping?Too many passes, toomany texture fetches.
26. Conventional solutionSplit the terrain into smaller sections that use areasonable number of tiles.
27. Conventional solutionTradeoff between number of sections andnumber of tiles in each sectionTerrain artists need to be careful to disguise theseams between adjacent sections
28. Conventional solutionTradeoff between number of sections andnumber of tiles in each sectionTerrain artists need to be careful to disguise theseams between adjacent sectionsAnd most important: Geometry Clipmaps treatterrain as it was continuous!!! No easy way to divide in sections using independent draw calls each.
29. Texture Splatting Revisited Splatting with up to 256 tiles!What if we consider each texel in the blendclipmap as a separate terrain section using upto 2 tiles? Reminder: One blend texel in KUFII → ~10x10cm.
30. Texture Splatting Revisited Splatting with up to 256 tiles!What if we consider each texel in the blendclipmap as a separate terrain section using upto 2 tiles? Reminder: One blend texel in KUFII → ~10x10cm.Assign an index to each tileStore 2 indices and one alpha value per texel ofthe blend clipmapPack all the tiles in a texture Atlas.
31. Splatting with 2 indexed color tiles... ID1 ID2 f x
32. ...and 1 bump tile. ID1 ID2 f +
33. Texture Splatting RevisitedA total 6 texture fetches required: Blend ClipMap: 1 Normal ClipMap: 2 Color Atlas: 2 Bump Atlas: 1
34. Blend Clipmap FormatThe tile with the highest weight goes in ID1 Bump map uses only ID1 Blend weight range is 0.5 to 1.0Two possible formats 5551 RGBA => 32 tiles and 64 blend steps 8888 RGBA => 256 tiles and 512 blend stepsIf weight == 0 then make ID2 = ID1 to optimizetexture bandwidth
35. Blend Map Filtering
36. Blend Map FilteringProblem: HW texture filtering makes no sense.We need to filter in the PS Fetch the Blend clipmap 4 times Fetch the Color Atlas 2 x 4 = 8 times Fetch the Bump Atlas 4 times Do bi-linear filtering by interpolating in the PS
37. Blend Map Filtering
38. Layer Map Filtering18 texture fetches needed!So how expensive is it?...
39. Layer Map Filtering18 texture fetches needed!So how expensive is it?...…not that much actually Blend Map fetches are always 4 neighboring texels Atlas fetches usually end up sampling the same tile (and UV coords) several times E.g. The 8 color fetches very rarely correspond to more than 2 or 3 actual different tiles.~ 25% perf. decrease compared to the non-filtered version.
40. PS Dynamic Flow Control
41. PS Dynamic Flow ControlThere are big areas in the Blend Map whereID0 and ID1 dont change across several texels. Green areas in the previous slide.In those areas HW bi-linear filter works just fine.Use dynamic flow control to skip PS bi-linearfilter.Pre-compute the condition expression and storeit in the blend map alpha channel.
42. Texture Memory Requirements888RGBX Blend Clipmap: 24 MB 6 slices x 1024x1024 Covering 128m to 4096m Closest clipmap texel size = 12.5cmDXT5 Normal Clipmap: 8MB 8 slices x 1024x1024 Covering 32m to 4096m Closest clipmap texel size = 3.125cmTotal: 32MB
43. Low Quality Settings Texture Memory Requirements888RGBX Blend Clipmap: 7 MB 7 slices x 512x512 Covering 64m to 4096m Closest clipmap texel size = 12.5cmDXT5 Normal Clipmap: 2.25MB 9 slices x 512x512 Covering 16m to 4096m Closest clipmap texel size = 3.125cmTotal: 9.25MB
44. Low Quality Settings
45. Low Quality vs High Quality Settings
46. Texturing Terrain SlopesTextures are mapped to the terrain by a planarprojection along the Y axis.In steeply sloped areas this causesunacceptable distortion.
47. Texturing Terrain Slopes
48. Texturing Terrain Slopes
49. Texturing Terrain Slopes
50. Texturing Terrain SlopesSolution: Selectable projection axis and scaleper texture tileAdds one extra level of indirection: “Layer Table” Tile Axis Scale X 1.5 ID1 ID2 f Z 1
51. Texturing Terrain SlopesTwo layers can share the same texture tile,while having different projection axis/scale.Blend clipmap now contains layer ID. Tile Axis Scale X 1.5 ID1 ID2 f Z 1
56. Storage, Streaming & SynthesisTerrain divided into rectangular sectionsFor each section LOD chains of the elevationand layer data are stored independently.Section LODs are streaming on demand.The synthesis process can fill the gaps whensome LOD is temporally unavailable.Procedural synthesis is also use to generateextra high frequency detail.
57. Without Procedural Detail
58. With Procedural Detail
60. We are Hiring!Programming all engine areas Graphics, Animation, Physics and Tools.All levels of experience Junior, Senior, Lead...