Download presentation
Presentation is loading. Please wait.
1
CSE 381 – Advanced Game Programming Terrain
Badlands, South Dakota
2
Think of it as a textured blanket
3
Obviously a rendering challenge Also a collision detection challenge
Terrain Obviously a rendering challenge Also a collision detection challenge Requires a huge amount of data for outside game environments Usually pre-lit – what does this mean? Typically integrated with: sky water sun
4
Terrain Characteristics
fidelity how realistic is it? for model & textures spread degree to which areas of the terrain are unique freedom how much are the player’s movements restricted by the terrain? Want real earth terrain data?
5
Some game engines have terrain managers
Terrain Modeling Some game engines have terrain managers with their own GUI terrain generation tools with their own rendering optimizations Terrain building as models can also be positioned, rotated, etc. as one
6
Texturing provides this Typical textures:
Terrain Cover Texturing provides this Typical textures: grass, flowers, dirt, pebbles, rocks, moss, sand, stone, etc. Most engines support terrain texture blending What’s that? good for transition areas at borders of differing terrain
7
When making Terrain Textures
avoid making distinctive marks Why? avoid making textures with patterns Remember, these will be repeated over an area
8
How do you think terrain data is stored?
Height maps What’s that? a 2D image that stores topographical info for a square map region different shades of gray represent different elevations brightness of a pixel denotes its elevation
9
Each pixel represents an area’s elevation
More on height maps Each pixel represents an area’s elevation ex: 1 pixel is a square meter black may be the base elevation pure white may be the other extreme values in between are scaled Ex: 8 bits per pixel means 256 possible elevations
10
Each pixel represents a tile (square of terrain) For each tile
Using Height Maps Terrain generator reads a height map file and creates the appropriate geometry How? Each pixel represents a tile (square of terrain) For each tile a vertex is generated at appropriate elevation two triangles are generated connecting new vertex to bordering vertices Some generators will add more vertices Why? Interpolation (more on this later)
11
Terrain Units WU – world units Example:
refers to measurement scale for a game world basic WU is one inch Example: level tile is 10 X 10 units (meters or otherwise) 100 tiles X 100 tiles level is 1000 X 1000 NOTE: each tile may have many triangles again, depending on interpolation
12
Think of as its own level object Has a position, scale, rotation
Water Think of as its own level object Has a position, scale, rotation Typically specified using a single rectangle can fit into non rectangular terrain contours For camera out of water: typically water drawn using multiple textures one for shallows, one for deep can be blended via depth gradient effects then applied E.g., specular highlights For camera under water: other effects like fog, viscosity, waves, etc.
13
Terrain Rendering What do we need to know? how to store the data
how to load it how to render it how to detect collisions with it. Why? Nothing should go below the terrain
14
Height Maps Revisited Height maps are images
When a level is loaded, how might we store terrain data such that it can be efficiently: rendered used in collision detection calculations
15
2 Terrain Management Options
Static Option - Load height map into a mesh (or meshes) and treat terrain as any other mesh easy to implement typically divided into clumps Dynamic Option - Load height map data into data structure, each frame, use dynamically changing mesh based on location of frustum that’s a bit trickier
16
Clumps What’s a clump? What’s the benefit of managing clumps? Why?
a chunk of terrain subset of a level’s full terrain What’s the benefit of managing clumps? more efficient rendering/management of terrain Why? problem reduction
17
Clump Construction Example
Suppose we are loading a 256 x 256 height map Construct terrain as 16 x 16 clumps How many clumps is that? 256 How many vertices per height map pixels? depends on interpolation (more on this in a moment)
18
How do we use the clumps? Each frame, select only the visible clumps for rendering How do we do that? frustum culling is one way but there’s a simpler way clumps are cells in the 2D grid in what cell is the camera? render that clump in which direction is the look at vector? render those clumps know the max clump distance that can be viewed
19
Dynamic Terrain Generation
Height map is a 2D grid At start of level: build a recyclable mesh to store dynamic terrain Each frame: determine where on the grid the camera is fill dynamic terrain with visible portions of grid
20
What’s the point of interpolation?
Rounding terrain How? add more vertices to the grid Simple algorithm add 2 between each pair of vertices what height? make them closer to nearest existing vertex than 1/3 of height difference. Why?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.