Real-time 3D Graphics - Virginia Techcourses.cs.vt.edu/cs5754/lectures/rtgraphics.pdf · Graphics...
Transcript of Real-time 3D Graphics - Virginia Techcourses.cs.vt.edu/cs5754/lectures/rtgraphics.pdf · Graphics...
1
Real-time 3D Graphics
Doug A. Bowman
2
(C) 2008 Doug Bowman, Virginia Tech 2
Outline
(Very) brief review of 3D image synthesis
Real-time 3D graphics for VEs
3
(C) 2008 Doug Bowman, Virginia Tech 3
Rendering 3D scenes
Most 3D graphics is based on scenescomposed of objects built of polygons.
Goal: from scene specification and viewingspecification, produce a 2D image of thescene with proper 3D perspective bydetermining the color for each pixel on thedisplay
3D teapot animation…
4
(C) 2008 Doug Bowman, Virginia Tech 4
Overview of 3D image synthesis(rendering)
3D model
2D projection
Pixel values
Displayed image
Includes scene definition, camera properties,lighting characteristics, etc.
projection
rasterization
display
Process of mapping the desired 3D primitivesinto a 2D space
2D versions of 3D primitives
Process of changing primitive definitions intopixel locations/colors
Color value for each pixel on the screen, storedin the frame buffer
Process of taking information from framebuffer and producing physical representationon a display device
5
(C) 2008 Doug Bowman, Virginia Tech 5
3D Viewing Example
XZ
Y
Object model
X
Y
Z
6
(C) 2008 Doug Bowman, Virginia Tech 6
Coordinate systems
Right- vs. left-handed World vs. object (object
trees, scenegraphs) World vs. camera Screen/display
Transformations (mappings)between CSs
Right-handedCS
X
Y
Z
7
(C) 2008 Doug Bowman, Virginia Tech 7
Graphics pipeline
Object definition
Compose scene
Define view parameters
Perform culling
Clip to 3D view
volume
Hidden surface removal
Rasterization
Shading
Local space
3D screen space
View space
World space
Display space
Modeling transformation
Viewing transformation
Perspectiveprojection
8
(C) 2008 Doug Bowman, Virginia Tech 8
Modeling transformation
For each vertex:transform object toworld coords.
Each M represents atransformation matrix.
Where is chair2relative to room?
room
table rug
chair1 chair2
M1 M2
M4M3
M0
9
(C) 2008 Doug Bowman, Virginia Tech 9
Graphics pipeline
Object definition
Compose scene
Define view parameters
Perform culling
Clip to 3D view
volume
Hidden surface removal
Rasterization
Shading
Local space
3D screen space
View space
World space
Display space
Modeling transformation
Viewing transformation
Perspectiveprojection
10
(C) 2008 Doug Bowman, Virginia Tech 10
Viewing transformation
Transform world to camera coords. Where are the objects with respect to the camera?
Viewing transformation animation…
View frustum
11
(C) 2008 Doug Bowman, Virginia Tech 11
Clipping
Process of removing polygons and parts ofpolygons that fall outside the view frustum
Basically, comparing each vertex withplane equations for the six view frustumsides
12
(C) 2008 Doug Bowman, Virginia Tech 12
Projections
Projection: mapping 3D to 2D spaceCenter of projection = camera = eyeProjection plane = viewplane: 2D plane
onto which objects are projected
Perspective projection
13
(C) 2008 Doug Bowman, Virginia Tech 13
Mathematics of a one-pointprojection
xprojected = dx/z= x/(z/d)
yprojected = dy/z= y/(z/d)
d
P(x, y, z)
Projection animation…
14
(C) 2008 Doug Bowman, Virginia Tech 14
Graphics pipeline
Object definition
Compose scene
Define view parameters
Perform culling
Clip to 3D view
volume
Hidden surface removal
Rasterization
Shading
Local space
3D screen space
View space
World space
Display space
Modeling transformation
Viewing transformation
Perspectiveprojection
15
(C) 2008 Doug Bowman, Virginia Tech 15
Hidden-surface elimination
Problem: we only need to displaypolygons that are visible
Example approaches:z-buffer (hardware)BSP treeSpatial subdivision
16
(C) 2008 Doug Bowman, Virginia Tech 16
Shading
We can increase realism by adding shading/lighting, butmore complex approaches take longer to calculate
constant flat Gouraud
17
(C) 2008 Doug Bowman, Virginia Tech 17
Rasterization
Once vertices have been projected, we onlyneed to “fill in” the primitives between thevertices
Rasterization (sometimes called scanconversion) is the process of determining whichpixels are part of a primitive and “turning on”those pixels.
Polygon fill animation…
18
(C) 2008 Doug Bowman, Virginia Tech 18
Graphics pipeline
Object definition
Compose scene
Define view parameters
Perform culling
Clip to 3D view
volume
Hidden surface removal
Rasterization
Shading
Local space
3D screen space
View space
World space
Display space
Modeling transformation
Viewing transformation
Perspectiveprojection
19
(C) 2008 Doug Bowman, Virginia Tech 19
What is real time?
“Fast enough” that the user canPerceive smooth motionInteract with the environment
Often stated in frames per second (fps) –number of views of the scene rendered inone second
A frame rate of approx. 10-30 fps is theminimum for “real-time”
20
(C) 2008 Doug Bowman, Virginia Tech 20
Speed vs. Quality tradeoff
More complex models ⇒ slower renderingWe must manage this tradeoff to achieve
maximum quality with an acceptable framerate
21
(C) 2008 Doug Bowman, Virginia Tech 21
Techniques for real-time 3D graphics
Polygonal simplificationView cullingOcclusion cullingLevel of detail managementTexture substitutionLightmaps
22
(C) 2008 Doug Bowman, Virginia Tech 22
Polygonal simplification
Decrease the number of polygons without sacrificingvisual quality (meet polygon budget)
30944 triangles 2502 triangles 621 triangles 251 triangles
23
(C) 2008 Doug Bowman, Virginia Tech 23
Level of detail management
LOD: change the complexityof the model/imagedynamically to maintain real-time performance
Ex: use simplified modelswhen objects are at a greatdistance
24
(C) 2008 Doug Bowman, Virginia Tech 24
Level of detail - another example
Matchcharacteristics ofhuman eye
Use high detail infovea, low detail inperiphery
25
(C) 2008 Doug Bowman, Virginia Tech 25
26
(C) 2008 Doug Bowman, Virginia Tech 26
View culling
Not the same as clipping!
Easy: remove all objects that are behindthe plane of the camera
Harder: remove all objects outside theview frustum
27
(C) 2008 Doug Bowman, Virginia Tech 27
Occlusion culling
Hidden-surface elimination techniques: stillrender all polygons (e.g. z-buffer)
Occlusion culling: remove polygons fromconsideration before rendering
28
(C) 2008 Doug Bowman, Virginia Tech 28
Texture substitution (imposters)
Textures cancause objects toappear muchmore detailedthan they actuallyare
Problem: whenthe user is close
29
(C) 2008 Doug Bowman, Virginia Tech 29
Lightmaps
Pre-calculate lighting for a scene, thentexture lighting onto objects
30
(C) 2008 Doug Bowman, Virginia Tech 30
Lightmapped VEs
31
(C) 2008 Doug Bowman, Virginia Tech 31
Other graphics issues for VEs
Stereo renderingOff-axis projections Inserting the user into the scenegraphParallel / distributed rendering