b) Describe
the Sutherland-Cohen algorithm for clipping? Is this applicable to any type of
window? Justify your answer. [9]
The more efficient
Cohen-Sutherland Algorithm performs initial tests on a line to determine
whether intersection calculations can be avoided.
- End-points
pairs are check for trivial acceptance or trivial rejected using the outcode.
- If not trivial-accepance or trivial-rejected,
divided into two segments at a clip edge.
- Iteratively clipped by testing trivial-acceptance
or trivial-rejected, and divided into two segments until completely
inside or trivial-rejected.
Pseudo-code
of Cohen-Sutherland
Algorithm.
To perform trivial
accept and reject tests, we extend the edges of the clip rectangle to divide
the plane of the clip rectangle into nine regions. Each region is assigned a
4-bit code deteermined by where the region lies with respect to the outside
halfplanes of the clip-rectangle edges. Each bit in the outcode is set to
either 1 (true) or 0 (false); the 4 bits in the code correspond to the
following conditions:
o
Bit
1 : outside halfplane of top edge, above top edge
Y > Ymax
Y > Ymax
o
Bit
2 : outside halfplane of bottom edge, below bottom edge
Y < Ymin
Y < Ymin
o
Bit
3 : outside halfplane of right edge, to the right of right edge
X > Xmax
X > Xmax
o
Bit
4 : outside halfplane of left edge, to the left of left edge
X < Xmin
X < Xmin
In summary, the C-S
algorithm is efficient when outcode testing can be done cheaply (for example,
by doing bitwise operations in assembly language) and trivial acceptance or
rejection is applicable to the majority of line segments .(For example, large
windows - everything is inside , or small windows - everything is outside).
3.b) Explain
the steps of the Cyrus-Beck line-clipping algorithm. [6]
The Cyrus–Beck algorithm is a line clipping algorithm. It was designed to be more efficient than the Sutherland–Cohen algorithm which uses repetitive clipping [1]. Cyrus–Beck is a general algorithm and can be used with a convex polygon clipping window unlike Sutherland-Cohen that can be used only on a rectangular clipping area
Here the parametric equation of a line in the view plane is:
P(t) = P(0) + t(P1 − P0)
where t = 0 at P(1) t = o at t0
Now to find intersection point with the clipping window we calculate value of dot product
n(Pt-f)
{if > 0
vector pointed toward interior
if = 0 vector
pointed parallel to plane containing f
if < 0 vector
pointed away from interior
here n stands for normal.
By this we select the point of intersection of line and clipping window where (dot product = 0 ) and hence clip the line
c) Why
clipping Is an Important operation for rendering? [4]
b) Is it necessary to compute lighting
information before clipping for rendering a 3D scene? Explain. [6]
Geometry in the complete 3D scene is
lit according to the defined locations of light sources and reflectance and
other surface properties. Current hardware implementations of the graphics
pipeline compute lighting only at the vertices of the polygons being rendered.
The lighting values between vertices are then interpolated during
rasterization. Per-fragment (i.e. per-pixel) lighting can be done on modern
graphics hardware as a post-rasterization process by means of a shader program.
Rough simulations of optical properties may be additionally employed: a simple calculation of the ray from the object to the point of view is made. Another calculation is made of the angle of incidence of light rays from the light source(s), and from these as well as the specified intensities of the light sources, the value of the pixel is calculated. Another simulation uses illumination plotted from a radiosity algorithm, or a combination of these two.
Raycasting is primarily used for realtime simulations, such as those used in 3D computer games and cartoon animations, where detail is not important, or where it is more efficient to manually fake the details in order to obtain better performance in the computational stage. This is usually the case when a large number of frames need to be animated. The resulting surfaces have a characteristic 'flat' appearance when no additional tricks are used, as if objects in the scene were all painted with matte finish.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.