Unit 4 - Final
Unit 4 - Final
Visible-Surface Determination
Introduction: Hidden surface elimination
• In a given set of 3D objects and viewing specification, we wish to determine which
lines and surfaces of the object are visible, so that we can display only visible lines
or surfaces. This process is called as the hidden surface elimination.
• The hidden lines or surfaces determine the lines, edges surfaces are visible to an
observer located at a specific point in space.
• These objects are broadly classified according to weather they deal with object
definition directly or their projected images.
• These two approaches are called object space method and image space method.
Compare Object space Method and Image Space Method : [VIMPT]
Sr. Object-Space Method Image Space Method
No.
3 Compare each object with all other For each pixel, examine all n objects to
objects to determine the visibility of the determine the one closest to the viewer.
object parts.
4 For each object in the scene do For each pixel in the image do
Begin Begin
1. Determine those parts of the 1. Determine those objects closest to
objects whose view is the viewer that is pierced by the
unobstructed by other parts of it projector through the pixel.
or any other object with respect 2. Draw the pixel in the object color.
to the viewing specification. End
2. Draw those parts in the object
color.
End
7 Display is more accurate, but more Display is less accurate, but less expensive
expansive as compared to image space as compared to object space method.
method.
Suitable for scene with small number of
objects and objects with simple
relationship with each other.
Coherence:
• It is the property by which we can relate one part of an object with other part.
•
Types of coherence
• Object Coherence: If two objects are entirely different from each other comparison need
to be done between objects not there properties.
• Face Coherence: Surface properties computed for one part of a face can be applied to
adjacent parts after small incremental modification.
• Scan line Coherence: Line or surface segments visible in one scan line are also likely
to be visible in adjacent scan lines.
• Area and Span Coherence: A group of adjacent pixels in an image is often covered by
the same visible object.
• Depth Coherence: The depths of adjacent parts of the same surface are similar.
• Frame Coherence: Pictures of the same scene at successive points in time are likely to
be similar, despite small changes in objects.
• Edge Coherence : Visibility changes if a edge crosses behind a visible face.
Problem of Visibility
Problem Definition: Given a set of 3-D surfaces to be projected onto a 2-D screen, obtain the
nearest surface corresponding to any point on the screen.
Example:
No Lines Removed: Original figure:
Hidden Lines Removed:
Categories of algorithms:
1. Back face removal:
2. The z-Buffer Algorithm or Depth Buffer Method: [VIMPT]
It uses two types of buffers:
◼ Frame Buffer and Z Buffer
◼ Frame buffer stores Intensity values.
◼ Z buffer stores the large negative values.
3. Painter’s algorithms (depth sorting): [VIMPT]
• Min-max test are used to check weather two polygons are overlapping or not.
• The painter's algorithm, also known as a priority fill, is one of the simplest
solutions to the visibility problem in 3D computer graphics.
• When projecting a 3D scene onto a 2D plane, it is necessary at some point to decide
which polygons are visible, and which are hidden.
• The name "painter's algorithm" refers to the technique employed by many
painters for painting distant parts of a scene before parts which are nearer thereby
covering some areas of distant parts.
• The painter's algorithm sorts all the polygons in a scene by their depth and then paints
them in this order, farthest to closest
• It will paint over the parts that are normally not visible — thus solving the visibility
problem — at the cost of having painted invisible areas of distant objects.
• The ordering used by the algorithm is called a 'depth order’.
• Main Idea
o A painter creates a picture by drawing background scene elements before
foreground ones.
• Requirements
o Draw polygons in back-to-front order
o Need to sort the polygons by depth order to get a correct image
4. Scan-Line Method
• The scan-line algorithm is another image-space algorithm.
• It processes the image one scan-line at a time rather than one pixel at a time.
• As the scan line is processed, it examines all polygon surfaces intersecting that line
to determine which are visible.
• It then does the depth calculation and finds which polygon is nearest to the view plane.
• Finally it enters the intensity value of the nearest polygon at that position into the frame
buffer.
• By using area coherence of the polygon, the processing efficiency is improved over the
pixel oriented method.
• The scan line algorithm maintains the active edge list.
• This active edge list contains only edges that cross the current scan line, sorted in order
of increasing x.
• The scan line method of hidden surface removal also stores a flag for each surface that
is set on or off to indicate whether a position along a scan line is inside or outside of
the surface.
• Scan lines are processed from left to right.
• At the leftmost boundary of a surface, the surface flag is turned ON; and at the rightmost
boundary, it is turned OFF.
• Using an active edge table, the scan-line algorithm keeps track of where the projection
beam is at any given time during the scan-line sweep.
• When it enters the projection of a polygon, an ON flag goes on, and the beam switches
from the background colour to the colour of the polygon.
• After the beam leaves the polygon's edge, the colour switches back to background
colour.
• when the scan-line beam finds itself in two or more polygons, it becomes necessary to
perform a z-depth sort and select the colour of the nearest polygon as the painting
colour.
• In the following Figure scan-line S1 must deal only with the left-hand object.
• S2 must plot both objects, but there is no depth conflict.
• S3 must resolve the relative z-depth of both objects in the region between edge E5 and
E3
• The right-hand object appears closer.
Example 2:
The active list for scan line 1 contains information from the edge table for edges AB, BC, EH,
and FG. For positions along this scan line between edges AB and BC, only the flag for surface
S1 is on. Therefore, no depth calculations are necessary, and color values are calculated from
the surface properties and lighting conditions for surface S1. Similarly, between edges EH and
FG, only the flag for surface S2 is on. No other positions along scan line 1 intersect surfaces,
so the color for those pixels is the background color, which could be loaded into the frame
buffer as part of the initialization routine.
For scan lines 2 and 3 in Figure 10, the active edge list contains edges AD, EH, BC, and FG.
Along scan line 2 from edge AD to edge EH, only the flag for surface S1 is on. But between
edges EH and BC, the flags for both surfaces are on. Therefore, a depth calculation is necessary,
using the plane coefficients for the two surfaces, when we encounter edge EH. For this
example, the depth of surface S1 is assumed to be less than that of S2, so the color values for
surface S1 are assigned to the pixels across the scan line until boundary BC is encountered.
Then the surface flag for S1 goes off, and the colors for surface S2 are stored up to edge FG.
No other depth calculations are necessary, because we assume that surface S2 remains behind
S1 once we have determined the depth relationship at edge EH.
We can take advantage of coherence along the scan lines as we pass from one scan line to the
next. In Figure 10, scan line 3 has the same active list of edges as scan line 2. No changes have
occurred in line intersections, so it is again unnecessary to make depth calculations between
edges EH and BC. The two surfaces must be in the same orientation as determined on scan line
2, so the colors for surface S1 can be entered without further depth calculations.
Curves:
Curve Representation:
• Curves can be broadly classified into two categories→
Non-parametric, and parametric curves.
• Non-parametric Curves are further classified into− explicit, implicit.
Nonparametric Curves:
Implicit Curve:
• An implicit curve is defined by an implicit function of the form −
• f(x, y) = 0
• It can represent multi valued curves (multiple y values for an x value).
• A common example is the circle, whose implicit representation is
• x2 + y2 - R2 = 0
• Curves in 3D are not as easily represented in implicit form.
Explicit Curves:
• A mathematical function y = f(x) can be plotted as a curve.
• y is given in-terms of x
• Such a function is the explicit representation of the curve.
• The explicit representation is single-valued.
• For each value of x, only a single value of y is normally computed by the function.
There are three problems with describing curves using nonparametric equations :
• (1) If the slope of a curve at a point is vertical or near vertical, its value becomes infinity
or very large, which is a difficult condition to deal with both computation and
programming. It may lead to indistinct mathematical conditions.
• (2) Shapes of most engineering objects are intrinsically independent of any coordinate
system. What determines the shape of an object is the relationship between its data
points themselves and not between these points and some arbitrary coordinate system
• (3) If the curve is to be displayed as a series of point or straight-line segments, the
computations involved could be extensive.
Parametric Curves:
• Curves having parametric form are called parametric curves.
• The explicit and implicit curve representations can be used only when the function is
known.
• In practice the parametric curves are used.
• A two-dimensional parametric curve has the following form −
• P(t) = f(t), g(t)
• The functions f and g become the (x, y) coordinates of any point on the curve, and the
points are obtained when the parameter t is varied over a certain interval [a, b], normally
[0, 1].
Note: All the formulas are important do it well.
Parametric Representation of a Circle: [VIMPT]
Conversion:
x2=r2cos2t
y2=r2sin2t
x2 + y2= r2cos2t + r2sin2t = r2 (cos2t+sin2t )= r2
Sums:
x=5cos t, y= 5 sin t ; these are the parametric equations of a circle, what will be the implicit non-parametric representation of the same
circle?
Provided that:
• x and y in terms of z in explicit form of the intersection curve is given by,
• y=z2
• x=y2/z =(z2)2/z = z4/z=z3
Space curves parametrically represented as,
• x= x(u)
• y=y(u)
• z= z(u)
Cubic Splines:
Bezier Curves: [VIMPT]
• Bezier curve is an approach for the construction of the curve.
• A Bezier curve is determined by a defining polygon.
• Bezier curves have a number of properties that make them highly useful and convenient
for curve and surface design. They are also easy to implement.
• Therefore Bezier curves are widely available in various CAD systems and reason for
choosing cubic Bezier curve is that they provide reasonable design flexibility and are
also included in general graphic packages.
Properties of Bezier curve: [VIMPT]
1. The basis functions are real.
2. Bezier curve always passes through the first and last control points i.e. curve has
same end points as the guiding polygon.
3. The degree of the polynomial defining the curve segment is one less than the number
of defining polygon point. Therefore, for 4 control points, the degree of the polynomial
is three, i.e. cubic polynomial.
4. The curve generally follows the shape of the defining polygon.
5. The direction of the tangent vector at the end points is the same as that of the vector
determined by first and last segments.
6. The curve lies entirely within the convex hull formed by four control points.
7. The convex hull property for a Bezier curve ensures that the polynomial smoothly
follows the control points.
8. The curve exhibits the variation diminishing property. This means that the curve
does not oscillate about any straight line more often than the defining polygon.
9. The curve is invariant under an affine transformation.
[Not to be Included in Properties]
• Another approach to construct the Bezier curve is called midpoint approach.
• In this approach the Bezier curve can be constructed simply by taking midpoints.
• In midpoint approach midpoints of the lines connecting four control points (A, B, C,
D) are determined(AB, BC, CD).
• These midpoints are connected by line segments and their midpoints ABC and BCD
are determined.
• Finally these two midpoints are connected by line segments and its midpoint ABCD is
determined.
• This is illustrated in Fig. 9.8.
• The point ABCD on the Bezier curve divides the original curve into two sections.
• This makes the points A, AB, ABC and ABCD are the control points for the first section
and the points ABCD, BCD, CD and D are the control points for the second section.
• By considering two sections separately we can get two more sections for each separate
section i.e. the original Bezier curve gets divided into four different curves.
• This process can be repeated to split the curve into smaller sections until we have
sections so short that they can be replaced by straight lines or even until the sections
are not bigger than individual pixels.
• BCD instead of CDE ……
B-spline Curves: [VIMPT]
• We have seen that, a curve generated by using the vertices of a defining polygon
between the curve and the polygon. This scheme is provided by the choice of basis
function.
• [Disadvantages of Bezier Curve Method: ]
• The Bezier curve produced by the Bernstein basis function has a limited flexibility.
• First number of specified polygon vertices fixes the order of the resulting
polynomial which defines the curve.
• For example, polygon with four vertices results a cubic polynomial curve.
• The only way to reduce the degree of the curve is to reduce the number of vertices
conversely the only way to increase the degree of the curve is to increase the
number of vertices.
• The second limiting characteristics is that the value of the blending function is
nonzero for all parameter values over the entire curve. Due to this, change in one
place, changes the entire curve [global change] and this eliminates the ability to produce
a local change with in a curve. → global change
• There is another basis function, called the B-spline basis, which contains the
Bernstein basis as a special case.
• The B-spline basis is non-global. [local]
• It is nonglobal because each vertex in B-spline, is associated with a unique basis
function.
• Thus, each vertex affects the shape of the curve only over a range of parameter
values where its associated basis function is nonzero.
• The B-spline basis also allows the order of the basis function and hence the degree of
the resulting curve is independent of the number of vertices.
• The B-spline curve it is possible to change the degree of the resulting curve without
changing the number of vertices of the defining polygon.
• If P(u) be the position vectors along the curve as a function of the parameter u, a
B-spline curve is given by:
Properties of B-spline: [VIMPT]
1. The sum of the B-spline basis functions for any parameter value u is 1.
2. Each basis function is positive or zero for all parameter values, i.e., Ni, k >= 0.
3. Except for k = 1 each basis function has precisely one maximum value.
4. The maximum order of the curve is equal to the number of vertices of defining
polygon. [max limit]
5. The degree of B-spline polynomial is independent of the number of vertices of
defining polygon (with certain limitations).
6. B-spline allows local control [non-global] over the curve surface because each
vertex affects the shape of a curve only over a range of parameter values where its
associated basis function is nonzero.
7. The curve exhibits the variation diminishing property. Thus the curve does not
oscillate about any straight line more often than its defining polygon.
8. The curve generally follows the shape of defining polygon.
9. Any affine transformation can be applied to the curve by applying it to the vertices
of defining polygon.
10. The curve lies within the convex hull of its defining polygon.
•
Quadric Surfaces:
• If a surface is the graph of an equation of second degree in 3D system it is called
quadric Surface.
Bezier Surfaces:
• The Bézier surface is formed as the Cartesian product of the blending functions of
two orthogonal Bézier curves.
• Where Pi,j is the i,jth control point. There are Ni+1 and Nj+1 control points in the i and j
directions respectively.
Properties of Bezier Surfaces
• The degree of the surface in each polynomial direction is one less than the number of
defining polygon vertices in that direction
• The surface generally follows the shape of the defining polygon net.
• The surface is contained in the convex hull of the polygon net.
• Each of the boundary curve in this case is a Bezier curve.
• Splines are used in graphics to represent smooth curves and. surfaces. They use a
small set of control points (knots) and a function that generates a curve through
those points.
Concave polygon