+ All Categories
Home > Documents > Geometry for Game

Geometry for Game

Date post: 13-Jan-2016
Category:
Upload: topper
View: 27 times
Download: 0 times
Share this document with a friend
Description:
Geometry for Game. Game Models. Geometry Position / vertex normals / vertex colors / texture coordinates Topology Primitive Lines / triangles / surfaces / … Property Materials Textures Motion Hierarchy Level-of-detail. Geometry Data. Vertex position (x, y, z , w ) - PowerPoint PPT Presentation
Popular Tags:
22
1 Geometry for Game Geometry for Game
Transcript
Page 1: Geometry for Game

1

Geometry for GameGeometry for Game

Page 2: Geometry for Game

GeometryGeometry– Position / vertex normals / vertex colors / texture Position / vertex normals / vertex colors / texture

coordinatescoordinates TopologyTopology

– PrimitivePrimitive» Lines / triangles / surfaces / …Lines / triangles / surfaces / …

PropertyProperty– MaterialsMaterials– TexturesTextures

MotionMotion HierarchyHierarchy Level-of-detailLevel-of-detail

2

Game ModelsGame Models

Page 3: Geometry for Game

3

Vertex positionVertex position– (x, y, z(x, y, z, w, w))– In model space or screen spaneIn model space or screen spane

Vertex normalVertex normal– (n(nxx, n, nyy, n, nzz))

Vertex colorVertex color– (r, g, b) or (diffuse, specular)(r, g, b) or (diffuse, specular)

Texture coordinates on vertexTexture coordinates on vertex– (u(u11, v, v11), (u), (u22, v, v22), …), …

Skin weightsSkin weights– ((bonebone11, w, w11, bone, bone22, w, w22, …), …)

Geometry DataGeometry Data

Page 4: Geometry for Game

4

LinesLines– Line segmentsLine segments– PolylinePolyline

» Open / closedOpen / closed

Indexed trianglesIndexed triangles TTriangle Strips / Fansriangle Strips / Fans SSurfacesurfaces

– NNon-on-uuniform niform RRational ational BB SSpline (pline (NURBSNURBS)) SSubdivisionubdivision

Topology DataTopology Data

Page 5: Geometry for Game

5

Geometric data Vertex data v0, v1, v2, v3, …

(x, y, z, nx, ny, nz, tu, tv)

or (x, y, z, cr, cg, cb, tu, tv, …)

Topology Face v0 v3 v6 v7

Edge table

v0

v3

v6

v7

Right-hand rule for index

polygon normal

vertex normal

Indexed TrianglesIndexed Triangles

Page 6: Geometry for Game

6

v0

v1

v2

v3

v4

v5

v6

v7

T0

T1

T2 T3

T4

T5

v0 , v1 , v2 , v3 , v4 , v5 , v6 , v7

Triangle StripsTriangle Strips

“Get great performance to use triangle strips for rendering on current hardware

Page 7: Geometry for Game

7

MaterialMaterial TexturesTextures ShadersShaders

Property on SurfaceProperty on Surface

Page 8: Geometry for Game

8

MaterialMaterial– AmbientAmbient

» EnvironmentEnvironment» Non-lighted areaNon-lighted area

– DiffuseDiffuse» Dynamic lightingDynamic lighting

– EmissiveEmissive» Self-lightingSelf-lighting

– Specular with shinenessSpecular with shineness» Hi-lightHi-light» View-dependentView-dependent» Not good for hardware renderingNot good for hardware rendering

LLocal illuminationocal illumination FFor fixed function rendering pipelineor fixed function rendering pipeline

MaterialsMaterials

Page 9: Geometry for Game

9

TexturesTextures– Single textureSingle texture– Texture coordinate animationTexture coordinate animation– Texture animationTexture animation– Multiple texturesMultiple textures– AlphamapAlphamap

TexturesTextures

Material or vertex colors

Base color texture

Lightmap

Page 10: Geometry for Game

10

Programmable Shading LanguageProgrammable Shading Language– Vertex shaderVertex shader– PPixel shaderixel shader

Procedural way to implement some process of Procedural way to implement some process of renderingrendering– TransformationTransformation– LightingLighting– TexturingTexturing– BRDFBRDF– RasterizationRasterization– Pixel fill-inPixel fill-in

ShadersShaders

Page 11: Geometry for Game

11

Vertex Data Topology Data

ClassicTransform &

LightingVertex Shader

Clipping & Viewport Mapping

Texturing Pixel Shader

Fog

Alpha, Stencil, Depth Testing

GeometryStage

RasterizerStage

Shader PipelineShader Pipeline

Page 12: Geometry for Game

Per-pixel lightingPer-pixel lighting Motion blurMotion blur Volume / Height fogVolume / Height fog Volume linesVolume lines Depth of fieldDepth of field Fur fightingFur fighting Reflection / RefractionReflection / Refraction NPR (NPR (non-photorealistic rendering non-photorealistic rendering )) ShadowShadow Linear algebra operatorsLinear algebra operators Perlin noisePerlin noise QuaternionQuaternion Sparse matrix solversSparse matrix solvers Skin bone deformationSkin bone deformation NNormal mapormal map DDisplacement mapisplacement map PParticle shaderarticle shader

12

Procedural Morphing Water Simulation

Powered by ShaderPowered by Shader

Page 13: Geometry for Game

13

TTime-dependent dataime-dependent data TTransformation dataransformation data

– PPositionosition– OOrientationrientation

FormatsFormats– PivotPivot– Position vectorPosition vector– QuaternionQuaternion– Eurler anglesEurler angles– Angular displacementAngular displacement

Motion DataMotion Data

Page 14: Geometry for Game

14

Discrete LODDiscrete LOD– Switch multiple resolution models run-timelySwitch multiple resolution models run-timely

CContinuous LODontinuous LOD– Use progressive mesh to dynamically reduce the Use progressive mesh to dynamically reduce the

rendered polygonsrendered polygons VView-dependent LODiew-dependent LOD

– Basically for terrainBasically for terrain

Level-of-detailLevel-of-detail

Page 15: Geometry for Game

Render a model in different level-of-detail at runtimeRender a model in different level-of-detail at runtime User control or automatic change the percentage of User control or automatic change the percentage of

rendered verticesrendered vertices Use mapping function between two successive Use mapping function between two successive

meshes to control the simplification processmeshes to control the simplification process

15

Progressive MeshProgressive Mesh

Map for

edge collapse

Vertex list

Triangle list

IndexIndex 00 11 22 33 44 55 66 77 88

MapMap 00 11 11 22 33 00 44 55 66

00 11 22 33 44 55 66 77 88

00 22 55 00 11 22 33 55 88

0 0 6

4

Page 16: Geometry for Game

16

Real-time optimal adapting meshes (ROAM)Real-time optimal adapting meshes (ROAM) UUse height mapse height map RRun-timely to re-construct the active (for un-timely to re-construct the active (for

rendering) geometric topology (re-mesh) to rendering) geometric topology (re-mesh) to get an optimal mesh (polygon count) to get an optimal mesh (polygon count) to improve the rendering performanceimprove the rendering performance

SSomeone calls this technique as the omeone calls this technique as the view-view-dependent level-of-detaildependent level-of-detail

VVery good for fly-simulation-like applicationery good for fly-simulation-like application

View-dependent LOD for Terrain - ROAMView-dependent LOD for Terrain - ROAM

Page 17: Geometry for Game

17

Apply progressive mesh for multi-resolution Apply progressive mesh for multi-resolution model generationmodel generation

Use in-game discrete LOD for performance Use in-game discrete LOD for performance tuningtuning

WWhy ?hy ?– FFor modern game API / platform, dynamic vertex or modern game API / platform, dynamic vertex

update is expensive (not good for performance)update is expensive (not good for performance)» LLock video memory -> aversely affect CPU/GPU ock video memory -> aversely affect CPU/GPU

performanceperformance

Level-of-detail SuggestionLevel-of-detail Suggestion

Page 18: Geometry for Game

18

Bounding sphere Bounding cylinder Axis-aligned bounding box (AABB) Oriented bounding box (OBB) Discrete oriented polytope (k-DOP); k/2 pairs

Bounding Sphere AABB

OBB

k-DOP

Bounding VolumeBounding Volume

Bounding Cylinder

Page 19: Geometry for Game

19

Collision DetectionCollision Detection VVisibility Cullingisibility Culling HHit Testit Test

Bounding Volume - ApplicationBounding Volume - Application

Page 20: Geometry for Game

20

Bounding sphere B1(c1, r1), B2(c2, r2)

If the distance between two bounding spheres islarger than the sum of radius of the spheres, thenthese two objects have no chance to collide.

d > r1+ r2

D

B1

B2

c1

c2

Application Example - Bounding SphereApplication Example - Bounding Sphere

Page 21: Geometry for Game

21

Axis-aligned bounding box (AABB)Axis-aligned bounding box (AABB)– SSimplified computation based on the axis-implified computation based on the axis-

aligned featurealigned feature– Have to compute the AABBs at runtimeHave to compute the AABBs at runtime AABB

Application Example - AABBApplication Example - AABB

Page 22: Geometry for Game

22

Oriented bounding box (OBB)Oriented bounding box (OBB)– Intersection computation based on the Intersection computation based on the

transformed OBB geometric datatransformed OBB geometric data» 3D containment test3D containment test» Line intersection with planeLine intersection with plane

FFor games, or games,

OBB

Application Example - OBBApplication Example - OBB


Recommended