Graphics Pipeline Transforming Scenes to Pixels Data 3 D Culling Application Scene Database Lighting View Transform 2 D Hardware Clipping Rasterization Video Out Scene Database Model of the scene that is created by the application Objects describes their shapes models their materials wood vs marble vs Light sources location properties of each light Viewing model camera location properties Frequently hierarchical body arm hand finger Clipping Only keep that portion of primitives within viewport we clip objects to viewport borders this is different than culling cull reject entirely hidden objects clip cut off hidden parts of objects may be done in 2 D or 3 D Clipping to Viewport Computing Normals on Triangle Meshes v3 v2 a v 2 v1 b v 3 v1 Triangle defines unique plane can easily compute normal n a b a b depends on vertex orientation clockwise order gives n n v1 n4 n3 n1 n2 Vertex normals less well defined can average face normals works for smooth surfaces but not at sharp corners think of a cube Smooth vs Flat Shading per face normals per vertex normals Preserving Sharp Features per corner normals per vertex normals Drawing Wireframe Meshes Just draw each polygon as lines see also glPolygonMode glColor3fv black for int j 0 j n j glBegin GL LINE LOOP glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 glEnd Optimizing Drawing Triangle Strips glBegin GL TRIANGLE STRIP glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 Triangle A glVertex3fv v4 Triangle B glVertex3fv v5 Triangle C glVertex3fv v6 Triangle D glEnd Emitting vertices costs something each must be transformed and lit fewer vertices faster drawing Take advantage of prior vertices first 3 specify triangle for each subsequent vertex take previous 2 vertices this will define the next triangle v2 v4 A v1 B C v3 v6 D v5 Up to a factor of 3 improvement for sufficiently long strips requires only 1 vertex triangle Trick is to generate strips usually start with just triangles Optimizing Drawing Triangle Fans glBegin GL TRIANGLE FAN glVertex3fv v1 glVertex3fv v2 glVertex3fv v3 Triangle A glVertex3fv v4 Triangle B glVertex3fv v5 Triangle C glVertex3fv v6 Triangle D glEnd v3 Also 1 vertex per triangle if the loop is sufficiently large but it usually won t be v2 A B v4 A lot like triangle strips but start with a central point build triangles around it v1 C D v6 v5 Where Do Meshes Come From Manual construction write out polygons or maybe write some code to generate them or manually move vertices around in space Acquisition from real objects via laser scanners vision systems generates set of points on surface need to build set of polygons surface reconstruction problem Generating Animation We create animated behavior just like movie projectors display a sequence of still images in rapid succession creates the illusion of continuous motion around 10 Hz is the minimum acceptable rate film projectors generally run at 24 Hz broadcast and video are usually at 30 Hz Assuming our redraws are fast it s easy to program set up a system timer to go off every 1 n of a second generate a redraw event when the timer goes off Immersive applications must pay close attention to frame rate flight simulators are a good example inconsistent frame rates lead to incredible nausea Single vs Double Buffering Single Buffering draw into same frame buffer being used to generate video signal can draw on top of existing image if appropriate tends to lead to flickering Double Buffering draw in separate frame buffer front buffer for video signal back buffer drawing target must redraw entire scene every frame must swap buffers when drawing is finished avoids flickering Demo Awash in a Sea of Polygons Acquisition systems often produce huge models millions of polygons per object are common billions of polygons per object are starting to happen dealing with these models is a real problem 300 million faces 3 7 GB after gzip compression This has led to a lot of current research compression can do much better than gzip for geometric models level of detail control don t draw what s too small to see Optimizing Drawing Level of Detail Control Don t always need all the detail in models as objects move further away can see less and less Use models appropriate for current context maintain multiple versions of object 70 000 triangles 10 000 triangles 3000 triangles Optimizing Drawing Level of Detail Control Pick the right model for the current viewing distance
View Full Document
Unlocking...