CSE 381 – Advanced Game Programming Terrain Management

Slides:



Advertisements
Similar presentations
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Advertisements

CSE 380 – Computer Game Programming Tile Based Graphics Legend of Zelda, by Nintendo, released 1987.
Lecture 8 Transparency, Mirroring
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Graphics Pipeline.
Game Programming 09 OGRE3D Lighting/shadow in Action
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
3D Graphics Rendering and Terrain Modeling
3D Game Programming All in One By Kenneth C. Finney.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
3D Game Programming All in One By Kenneth C. Finney.
Background Caches for Large Outdoor Scenes Bill Hess.
1 3D –graphics and animation Shading and Surface Characteristics Harri Airaksinen.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Guilford County Sci Vis V204.01
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Computer Graphics Mirror and Shadows
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation.
CSS 522 Topics in Rendering March 01,2011 Scott and Lew.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Sky Rendering The actual physics is very complicated and costly to calculate. Several cheap approaches for very distant skies: –Constant backdrop –Skybox.
Vector vs. Bitmap
Introduction to Textures and Skins Chapter 8 & 9 3D Game Programming All-in-One By Ken Finney.
Computer Graphics Texture Mapping
Main Goal Development of an application that allows flying virtually over El Hierro Island (Canary Islands), showing the building structures of a hydroelectric.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
10/27/20151 UDK Terrain CIS 488/588 Bruce R. Maxim UM-Dearborn.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
CSE 381 – Advanced Game Programming GLSL Lighting.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
3D Viewers Two main uses: –Detector/event exploration – interactivity priority (15fps min). –Generate presentation material (still/movie renders) – quality.
Design Studies 20 ‘Show Off’ Project How to make a computer monitor In Google Sketchup By: Liam Jack.
Mark Nelson 3d projections Fall 2013
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
CSE 380 – Computer Game Programming Tile Based Graphics & Scrolling Legend of Zelda, by Nintendo, released 1987.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
CS324e - Elements of Graphics and Visualization Fractals and 3D Landscapes.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
1Ellen L. Walker 3D Vision Why? The world is 3D Not all useful information is readily available in 2D Why so hard? “Inverse problem”: one image = many.
Introduction to Computer Graphics
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
PROPERTY OF PIMA COUNTY JTED, 2011
Week 7 - Monday CS361.
Image-Based Rendering
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
CSE 381 – Advanced Game Programming Terrain
UMBC Graphics for Games
Lecture 13 Clipping & Scan Conversion
Advanced Computer Graphics: Texture
Presentation transcript:

CSE 381 – Advanced Game Programming Terrain Management http://www.cse.ohio- state.edu/~somasund/GRAPHICS/TeapotPhongOUT.jpg 1

Think of it as a textured blanket

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

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? http://edcwww.cr.usgs.gov

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

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

When making Terrain Textures avoid making distinctive marks Why? avoid making textures with patterns Remember, these will be repeated over an area

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

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

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)

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

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.

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

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

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

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

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)

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

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

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?

Skies Add ambiance Add realism Add value Note: Inside or outside game? Different genres use different approaches rpg vs. fps Inside or outside game? http://vterrain.org/Atmosphere/ 21

Approaches Skyplanes Skyboxes Skydomes Cloud Generation & rendering

For all approaches Render in sky space Huh? Render first, with depth buffer off Use geometry that fits sky textures minimize interpolation this means sky geometry is much smaller than other objects

Skyplanes Simplest to model and texture Does not completely enclose camera Disadvantage: End of plane is noticible Doesn’t cover horizon Should only be used when mountains or other objects fills gaps

Simplest Skyplane Approach Use 2 triangles put them right over the camera Ex: 1 y-unit above camera at all times Move sky with camera Map sky texture onto geometry again, minimize interpolation No minification or magnification What determines this? How you: size it texture it position it

Alternative: curved plane Shaped like a parachute Considerations: Resolution (number of vertex rows/columns) Radius Height of peak Repetitions of texture

Creating the Geometry How can we create vertices that are: evenly spaced part of mesh centered over 0,0 in x&z range -planeSize/2 through planeSize/2 Plane size = √((2*radius)2/2) Using Pythagorean theorem, in loop, calculate distance to determining y values

Rendering Skyplanes Disable: lighting fog depth testing To blend clouds with sky, enable OpenGL blending

Sky Fading Note that the sky fades on the horizon, it doesn’t just get cut off How can we add this effect? For skyplane, add alpha value to all vertices: those nearest center (0, ?, 0) fully opaque, gradually + and – from center more transparent use a linear, or better yet, exponential function

Clouds with Volume How do we add 3Dish clouds? Use Layers of them same and different textures blend them

Skyboxes Most common sky rendering technique Fully encloses camera Inexpensive Again, enclose camera in small box How does it work? render distant scenery onto inside or cube

Skybox Atlas http://boxxblog.blogspot.com/2008/09/skyboxes-in-video-games.html 32

Traditional Approach Render ordinary textured cube Align with the world axis Centered around camera Render it first Disable necessary features as before Size of box can be small it should fit the textures make sure it’s in the frustum

Skybox Rendering Steps Clear the depth buffer Disable depth test Disable depth writes Disable fog and lighting Render the box Enable depth test and writes Enable lighting and fog Draw the rest of the scene

Skybox Edges Boxes have seams We don’t want those to show up Why would they? mag/minification may sample nearby pixels border may be nearby results in poor interpolation Alternative, use texture coordinates that don’t start at edge, but one pixel off edge or employ GL_CLAMP_TO_EDGE ignores edge texels in interpolation

Does the skybox move? Not relative to the camera Camera can rotate, of course Skybox goes where ever the camera is Assumption is skybox art is of things very far away

Generating Skybox Art Common to make a large, continuous texture to wrap around sides, for example Break it up for texturing Good tools exist: Skypaint by Gavin Bell paint seamless, panoramic 360 deg. Images Terragen by Planetside generate sky boxes and terrain

Skybox Layering Can provide more beautiful experiences Example: 3 layers Outer layer for static background (e.g. stars) Middle layer for dynamic stuff (e.g. clouds) Inner layer for much closer stuff (e.g. mountains) Middle layer may use texture animation Means moving textures across a geometry How? Gradually adjusting texture coordinates

Textures vs. Colors Note that skies transition from horizon colors to sunset colors and make a smooth transition Colored Vertex rendering can do this easily more easily than texturing Option, use colors for outer layer, textures for inner layers

For multi-layered approach Draw outer skybox layers Disable depth writing Draw skyplane Enable depth writing Draw inner skybox layers

Skydomes For even better sky rendering Good for night-day transitions Good for advanced effects Uses one texture (for back layer) Provides better terrain sky transitions http://azerdark.wordpress.com/2010/01/31/skydome/ 41

Generating Vertices Use spherical equations Polar coordinates calculate evenly spaced points on globe For more on Skydomes and advanced sky rendering, see the end of Chapter 9