《#9scanconversion:#9扫描转换》由会员分享,可在线阅读,更多相关《#9scanconversion:#9扫描转换(84页珍藏版)》请在金锄头文库上搜索。
1、#9: Scan Conversion & Midterm Review,CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006,1,Outline for Today,Rendering intro Culling & clipping Scan conversion Midterm review,2,Rendering,Fancier term: Image Synthesis Synthesis of a 2D image from a 3D scene description Result is a 2D
2、 array of pixels Red, Green, Blue values (range 0-255 or 0.0-1.0) Can also have: opacity (“alpha”), depth (“Z”), Rasterization = determining which pixels are drawn by a given object,3,Hardware vs. Software Rendering,Highest quality rendering is done by software Algorithms such as “ray tracing”, “pho
3、ton maps”, etc Fanciest lighting, shadowing, surface shading, smoke & fog, etc. Can take minutes or hours to compute an image RenderMan (Pixar), Dali (Henrik Wann Jensen), RADIANCE, POVRay, Modern computers often have special-purpose 3D rendering hardware. “GPU” = Graphics Processing Unit. (Nvidia,
4、ATI) Hardware implements the traditional 3D graphics rendering pipeline Very fast, but relatively simple algorithm: Limits ability to get subtle shadows, reflections, etc. Limits on complexity of surface shading description, etc. Continually improving, driven by games industry. (Modern graphics hard
5、ware is programmable, blurring the distinction between hardware & software rendering.) We will start with algorithms that are used by GPUs, but well do them in software.,4,3-D Graphics Rendering Pipeline,Normalized view space,Modeling Transformation,Viewing Transformation,Lighting & Shading,Clipping
6、,Projection,Scan conversion, Hiding,Primitives,Image,Object space,World space,Camera space,Image space, Device coordinates,Culling,(I added this step to the diagram),Today,5,Rendering Triangle Sets,Will focus on triangles for now Most basic and useful Algorithms also for lines, points, polygons, cir
7、cles, ellipses, Assume we have colors I.e., colors assigned per-vertex Next week well look at lighting,6,Weve already done culling,Assume weve already culled to the view volume: Weve tossed out objects that we know are outside the view Does that mean everything that remains will be drawn?,7,More cul
8、ling, and clipping,The view volume culling may have been coarse per-triangle view volume culling Some triangles may intersect the edge of the view volume clipping Some triangles may be on the back sides of objects backface culling Some triangles may be obscured by other triangles hidden surface elim
9、ination , AKA hiding Some triangles may be degenerate degenerate culling We will do culling/clipping before we rasterize triangles We will do hidden-surface elimination at the last step,8,Outline for Today,Rendering intro Culling & clipping Scan conversion Midterm review,9,Culling,The sooner we can
10、detect that a triangle is not going to be visible, the less time has to be spent processing it We did object-level frustum culling. Now we cull individual triangles There are three common reasons to cull a triangle: If it doesnt lie within the view volume (view frustum culling) If it is facing away
11、from the viewer (backface culling) If it is degenerate (area=0) Well get to the first case later, when we do clipping,10,Backface Culling,Commonly use triangles to model the surface of a solid object If the object has no holes, the triangles will only be seen from the outside. Consider the triangles
12、 as “one-sided”, i.e. only visible from the front If the back of the triangle is facing the camera, it can be culled Back facing triangles should be culled as early as possible Expect roughly 50% of triangles in a scene to be back facing. Usually, backface culling is done before clipping: a very qui
13、ck operation affects a much larger percentage of triangles than clipping,11,Backface Culling,By convention, the front is the side where the vertices are ordered counterclockwise: Why not backface cull based on specified normals? Normals not always specified Per-vertex normals might not agree Not use
14、d in same section of hardware: normal vector used for lighting/shading only, not necessarily available to clipping/culling/rasterizing units Most renderers allow triangles to be defined as one- or two-sided. Two-sided triangles not backface culled Used for thin objects, non-closed objects Many rende
15、rers also allow: specifying whether vertices are ordered clockwise or counterclockwise specifying whether to cull front or back faces instead of culling, draw in a different color,12,Backface Culling,Can cull in any convenient space Usually backface cull in camera space Can also backface cull in obj
16、ect space transform camera position into object coords dont have to transform triangles at all before culling,13,Degenerate Culling,A degenerate triangle has no area, nothing to draw Can happen happen if all 3 vertices lie in a straight line Can happen if 2 or all 3 vertices are located at the exact same place The backface cull test will automatically reject these, as the normal will be zero:,14,Clipping,For triangles that intersect the faces of the