CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
3D Graphics Rendering and Terrain Modeling
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
Two-Dimensional Viewing Jehee Lee Seoul National University.
Computer Graphics Viewing.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
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.
Hidden Surface Removal
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
2-Dimension Viewing and Clipping
Clipping Apart from clipping to the view volume, clipping is a basic operation in many other algorithms –Breaking space up into chunks –2D drawing and.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CHAPTER 11 Shadows © 2008 Cengage Learning EMEA. LEARNING OBJECTIVES In this chapter you will learn about: – –Shadow rendering algorithms – –Blinn’s shadow.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Computer Graphics Lecture 32 Fasih ur Rehman. 3D Transforms The idea of 3D transforms is the same as that of 2D – A 3D point is represented by (x, y,
Windows, Viewports, and Clipping
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Implementation II.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
EEL Introduction to Computer Graphics
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
Computer Graphics I, Fall 2010 Implementation II.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
A.Aruna/Assistant Professor/SNSCE
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
RENDERING : Global Illumination
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning.
Computer Graphics Implementation II
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
3D Graphics Rendering PPT By Ricardo Veguilla.
Implementation I Ed Angel
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
Implementation II Ed Angel Professor Emeritus of Computer Science
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
Introduction to Computer Graphics with WebGL
Clipping Clipping Sutherland-Hodgman Clipping
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA

LEARNING OBJECTIVES In this chapter you will learn about: – –Height maps – –Creating and rendering a height map – –Hidden surface removal – –The Z-buffer algorithm – –The painter’s algorithm – –Clipping – –Two-dimensional line clipping – –Cohen-Sutherland clipping – –Liang-Barsky clipping – –The clipping of polygons – –Three-dimensional clipping – –Level of Detail (LOD) algorithms

HEIGHT MAPS Height maps, also called height fields, are predominantly used in computer games for realistic terrain generation. A height map is stored as a two-dimensional array consisting of x- and z-values. Each x- and z-coordinate is assigned a certain value (a y-coordinate) representing the height of a specific point on a 3D surface. Height maps can thus be described as simple two- dimensional arrays containing height values, sampled at evenly spaced intervals.

HEIGHT MAPS Height maps, as a function of x- and z- coordinates, can be represented using the following equation:

HEIGHT MAPS

Creating and Rendering a Height Map [see the textbook and online source code for a detailed discussion and examples].

HIDDEN SURFACE REMOVAL Culling is the process of comparing the position and orientation of polygons against the view volume’s field of view, with polygons facing away from the camera being eliminated. This elimination minimized the amount of computational overhead involved with hidden surface removal. Culling is basically a test determining the visibility of an object, and based on this test the object can be removed if not visible – a process known as hidden surface removal. A culling test is based on a simple vector calculation, specifically, the dot product between a polygon’s normal and the line-of-sight vector (the vector from the center of projection to the polygon). If the result of the dot product is positive then we can flag the polygon as visible (with its normal facing towards the viewer).

HIDDEN SURFACE REMOVAL There are two main hidden surface removal algorithm classes: – –object space algorithms – –image space algorithms. [see the textbook for a detailed example and discussion].

The Z-Buffer Algorithm The most common hidden surface removal algorithm is called the z-buffer algorithm. This image space algorithm was developed in 1975 by Edwin Catmull, current president of Walt Disney and Pixar Animation Studios. Z-buffering, sometimes referred to as depth- buffering, stores the depth values for each pixel being drawn in the frame buffer’s depth buffer. This stored depth data, or z-values, are then used by the algorithm to determine the pixels that should be drawn. [see the textbook for a detailed example and discussion].

The Painter’s Algorithm The painter’s algorithm orders polygons based on their distance from the viewer. This distance is calculated from the polygon’s centroid to the point of view.

The Painter’s Algorithm It is also possible to draw the objects of a scene in a front-to-back manner, resulting in the reverse painter’s algorithm. There is one serious flaw in the painter’s hidden surface removal algorithm – the overlapping of three or more polygons can cause it to fail. Another problem is encountered when two or more polygons intersect each other.

CLIPPING Clipping is an optimization operation resulting in the display of only visible objects. Clipping can be performed at the image space level, object space level or at both. Image space clipping, as with image space hidden surface removal, occurs during the rasterization phase and is done on a per-pixel basis. It defines a clipping filter operating on a pixel-by-pixel basis, determining whether a particular pixel lies within the specified viewport or not. Object space clipping is on the other hand either plane- based in object space or boundary-based in screen space. When performing plane-based clipping, we have to convert our view space boundaries to an object space clipping-plane, subsequently testing for the visibility of vertices inside this clipping-plane.

CLIPPING Boundary-based clipping clips against screen boundaries while in screen space by flagging the intersection of objects with planes adjacent to the x-, y- and z-axes.

Two-Dimensional Line Clipping Two-dimensional line clipping or line-segment clipping determines the primitives, or sections of primitives, visible to the viewer. All lines located within the predefined view volume pass the clipping test and are sent to the rasterizer for display. Primitives not located within the view volume are culled or eliminated. The lines, or primitives, partially located within the view volume are clipped so that only their visible sections are sent to the rasterizer for display.

Two-Dimensional Line Clipping The subsequent figure illustrates the following four possible clipping situations: A The line is completely visible within the predefined view volume, thus passing the clipping test. B The line is completely outside the predefined view volume and can be eliminated from the drawing process. C The line extends from outside the clipping region, enters the view volume and exits it again at another point. Lines like these must be clipped at both ends of the view volume. D The line segment is only partially within the predefined view volume. Its section outside of the clipping region must thus be clipped.

Two-Dimensional Line Clipping

There are several line clipping algorithms, such as the Cohen-Sutherland clipping algorithm, Liang-Barsky clipping, and Cyrus-Beck clipping. The core issue with clipping algorithms is determining the intersection of two lines.

Two-Dimensional Line Clipping The clipping process determines these intersections and can be described by the following three steps: 1 Take the input coordinates of a line, (x1, y1) and (x2, y2), as input. 2 Read the coordinates of the clipping rectangle. 3 Generate the clipped line coordinates, (x1’, y1’) and (x2’, y2’), by comparing the input values of the line to the coordinates of the clipping region.

Two-Dimensional Line Clipping Extending the mathematical approach used for calculating the intersection of two lines to determine the point of intersection of a line and clipping rectangle is relatively simple.

Cohen-Sutherland Clipping The Cohen-Sutherland two-dimensional line clipping algorithm can be considered a brute-force approach to the clipping problem. The algorithm basically divides the clipping region into a number of sections (specifically nine regions), each with its own unique 4-bit binary number, called an outcode.

Cohen-Sutherland Clipping [see the textbook for a detailed discussion and example].

Liang-Barsky Clipping The Liang-Barsky two-dimensional line clipping algorithm uses the parametric form of a line and the clipping window to determine the clipping coordinates of lines intersecting the clipping volume. This algorithm is significantly more efficient than Cohen-Sutherland clipping.

Liang-Barsky Clipping

To summarize, the Liang-Barsky clipping algorithm consists of the following steps: 1 Define all line segments in parametric form. 2 Set the minimum and maximum values for t (tmin ¼ 0 and tmax ¼ 1). 3 Calculate all the t values located between tmin and tmax. 4 Determine whether the arbitrary values of each parametric line lie within the clipping window. a If the line intersects, shorten the line segment via a floating- point division. b If the line doesn’t intersect the clipping window, discard it. 5 Display all clipped line segments.

Clipping Polygons Extending two-dimensional line clipping to polygons involves the clipping of polygons against a clipping rectangle or against other polygons, as is the case with hidden surface removal. Polygon clipping algorithms are derived from simple line clipping algorithms. We can thus clip a polygon against the edges of a clipping rectangle. There is, however, a problem with this approach – –clipping concave polygons can result in several additional polygons as shown in Figure

Clipping Polygons

The The illustrated problem is not encountered when working with convex polygons. The only solution to this problem is to consider the clipped region as a single polygon or to tessellate (divide) the polygon into a number of convex polygons

Clipping Polygons

Three-Dimensional Clipping Three-dimensional objects are clipped against a bounding volume as opposed to a clipping rectangle. Specifically, when clipping in 3D space we need to consider the intersections of lines and planes or polygons and planes as opposed to the clipping of lines against lines, which is the case with 2D space. A simple technique often employed to reject objects completely outside the clipping volume and to accept objects entirely inside it is to create a bounding sphere for the object and to subsequently test its edges against that of the view volume. A bounding volume, or bounding box, is simply a volume containing a geometric object.

Three-Dimensional Clipping

INTRODUCTION TO LEVEL OF DETAIL (LOD) ALGORITHMS Level of Detail algorithms are concerned with the complexity of geometric objects; basically decreasing an object’s mesh complexity (the number of polygons) as the distance between the object and the viewer increases. The main reason for using these algorithms is to increase the efficiency of a rendering operation by lessening the workload on the graphics system.

INTRODUCTION TO LEVEL OF DETAIL (LOD) ALGORITHMS