3. Kingdom Under Fire II
Terrain requirements
3rd person camera (close view, high detail)
RTS camera (large, instant displacements)
Large continuous world (streaming)
Direct3D 9 class HW with ps3
7. Terrain Geometry
Height map based
8Km x 8Km terrain patch around the camera
Geometry resolution down to 12.5cm
Brute force rendering → 8,589,934,592 tri.
8. Terrain Geometry
It's all about finding the right LOD technique
We 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 Clipmaps
Nested regular grids
(2n-2)2 quads each
Roughly centered around
the camera
Grid meshes must be
progressively updated as
the camera moves
11. Geometry Clipmaps
KUFII 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 Culling
Split each clipmap
into 12 nearly square
patches
4 different index
buffers
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 Clipmaps
Geomorphing needed to avoid gaps between
consecutive 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...
16. Normal Clipmap
Normals stored in
texture clipmaps
Generated at
runtime from
elevation data.
8 LODs
8192m x 8192m
1024 x 1024 texels
3cm details
17. Normal clipmap
Stored in a volume texture.
One clipmap LOD → one
volume slice
PS calculates the right slice
and UVs
Based in distance to camera
and derivatives
Compressed to DXT5
19. Texturing
This a 20km x 20km
section of KUFII
terrain.
Texture details down
to ~3mm
Equivalent to
2
6,000,000 texels.
20. Texture Splatting
Classical terrain texturing method
Combine 2 repeating tiles using a lower
resolution blend map.
Use multipass render
..or multitexturing.
x
21. Texture Splatting
4096 x 4096 blend map for a 20Km x 20Km
results in ~5x5m per texel.
KUFII art team wanted ~0.1x0.1m per texel
22. Texture Splatting
4096 x 4096 blend map for a 20Km x 20Km
results in ~5x5m per texel.
KUFII art team wanted ~0.1x0.1m
Easy... just use a texture clipmap for the blend
map!
27. Conventional solution
Tradeoff between number of sections and
number of tiles in each section
Terrain artists need to be careful to disguise the
seams between adjacent sections
28. Conventional solution
Tradeoff between number of sections and
number of tiles in each section
Terrain artists need to be careful to disguise the
seams between adjacent sections
And most important: Geometry Clipmaps treat
terrain 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 blend
clipmap as a separate terrain section using up
to 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 blend
clipmap as a separate terrain section using up
to 2 tiles?
Reminder: One blend texel in KUFII → ~10x10cm.
Assign an index to each tile
Store 2 indices and one alpha value per texel of
the blend clipmap
Pack all the tiles in a texture Atlas.
33. Texture Splatting Revisited
A total 6 texture fetches required:
Blend ClipMap: 1
Normal ClipMap: 2
Color Atlas: 2
Bump Atlas: 1
34. Blend Clipmap Format
The tile with the highest weight goes in ID1
Bump map uses only ID1
Blend weight range is 0.5 to 1.0
Two possible formats
5551 RGBA => 32 tiles and 64 blend steps
8888 RGBA => 256 tiles and 512 blend steps
If weight == 0 then make ID2 = ID1 to optimize
texture bandwidth
36. Blend Map Filtering
Problem: 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
39. Layer Map Filtering
18 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.
41. PS Dynamic Flow Control
There are big areas in the Blend Map where
ID0 and ID1 don't 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-linear
filter.
Pre-compute the condition expression and store
it in the blend map alpha channel.
42. Texture Memory Requirements
888RGBX Blend Clipmap: 24 MB
6 slices x 1024x1024
Covering 128m to 4096m
Closest clipmap texel size = 12.5cm
DXT5 Normal Clipmap: 8MB
8 slices x 1024x1024
Covering 32m to 4096m
Closest clipmap texel size = 3.125cm
Total: 32MB
43. Low Quality Settings
Texture Memory Requirements
888RGBX Blend Clipmap: 7 MB
7 slices x 512x512
Covering 64m to 4096m
Closest clipmap texel size = 12.5cm
DXT5 Normal Clipmap: 2.25MB
9 slices x 512x512
Covering 16m to 4096m
Closest clipmap texel size = 3.125cm
Total: 9.25MB
46. Texturing Terrain Slopes
Textures are mapped to the terrain by a planar
projection along the Y axis.
In steeply sloped areas this causes
unacceptable distortion.
50. Texturing Terrain Slopes
Solution: Selectable projection axis and scale
per texture tile
Adds one extra level of indirection:
“Layer Table” Tile Axis Scale
X 1.5
ID1
ID2
f
Z 1
51. Texturing Terrain Slopes
Two 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 & Synthesis
Terrain divided into rectangular sections
For each section LOD chains of the elevation
and layer data are stored independently.
Section LODs are streaming on demand.
The synthesis process can fill the gaps when
some LOD is temporally unavailable.
Procedural synthesis is also use to generate
extra high frequency detail.