0% found this document useful (0 votes)
5 views

Lecture 28

This document is a lecture on computer graphics covering various projection techniques, triangle representation, and color management in graphics. It explains concepts like oblique and perspective projection, triangle strips and fans, back-face culling, rasterization, and color representation including alpha blending. Additionally, it discusses handling oversaturated colors and the use of negative colors in graphics rendering.

Uploaded by

usmansaeed1512
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture 28

This document is a lecture on computer graphics covering various projection techniques, triangle representation, and color management in graphics. It explains concepts like oblique and perspective projection, triangle strips and fans, back-face culling, rasterization, and color representation including alpha blending. Additionally, it discusses handling oversaturated colors and the use of negative colors in graphics rendering.

Uploaded by

usmansaeed1512
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 84

Computer Graphics

Lecture 28

REVIEW III

Taqdees A. Siddiqi
[email protected]
REVIEW III
Taqdees A. Siddiqi
[email protected]
Oblique Projection
 Xp = x + z ( L1 cos (Ф) )
 Yp = y + z ( L1 sin (Ф) )
Perspective Projection
Presumptions For Simplification

The point of View (POV) must lie on the Z axis,


The screen plane must be parallel to the X-Y plane,
with the left and right edges of the screen parallel to
the Y-axis,
and the top and bottom edges of the screen parallel
to the X-axis
Because the POV represents the viewer’s eye,
and we presume that the viewer will be behind the
center of the screen.
Two common approaches are used with this:
1. The first is where the POV is at some point (0, 0, -
z) and the screen lies on the X-Y plane,
graphically, this looks like figure:
2. The second is where the POV lies at the origin,
and the screen lies on a plane at some +Z
coordinate, as shown in figure given below:
 Calculating the screen pixel that correlates to a 3D
point is now a matter of simple geometry. From a
viewpoint above the screen and POV (looking at the
X-Z plane), the geometry appears like the one shown
in figure below:
In geometric terms, we say that the triangle from A to
B to S is similar to the triangle from A to C to P
because the three angles that make up the triangles
are the same; the angle from AB to AS is the same
as the angle from AC to AP.
 The two right angles i.e. 90o, and therefore the
remaining two angles are the same (the sum of the
angles in a triangle is always 180 degrees).
What also holds true from similar triangles is that the
ratio of two sides also holds between the similar
triangles; this means that the ratio of BS to AB is the
same as the ratio of CP to AC.
But we know what AB is - it is Screen.z! and
we know what AC is - it is point.z! and
we know what CP is - it is point.x!
therefore:
|BS| / |AB| = |CP| / |AC|
|BS| = |AB| * |CP| / |AC|
|BS| = Screen.z * point.x / point.z
Note that:
 Screen.z is the distance d from the point of view at
origin or the scaling factor.
Triangles
 Triangles "flesh out" a 3D object, connecting them
together to form a skin or mesh that defines the
boundary surface of an object
 The ordering of the vertices goes clockwise around
the triangle
Three points in space, and the triangle connecting them
Triangle Strips and Fans
Triangle List

 The first is an explicit list or array of triangles, where


every three elements represent a new triangle.
Triangle Fan
 Triangle fans, conceptually, look like the folding fans
you see in souvenir shops. They are a list of triangles
that all share a common point.
A list of points composing a triangle fan
Triangle Strip

 Triangles in a triangle strip, instead of sharing a


common element with all other triangles like a fan,
only share elements with the triangle immediately
preceding them.
 The first three elements define the first triangle. Then
each subsequent element is combined with the two
elements before it, in clockwise order, to create a
new triangle
A list of points composing a triangle strip
Plane

 Planes are defined as infinitely large, infinitely thin


slices of space, like big pieces of paper.
 Each of the triangles that make up our model, exists
in its own plane
Equation of plane in 3D

Ax + By + Cz + d = 0
Ax + By + Cz + d = 0

 The triplet (a, b ,c) represents what is called the


normal of the plane
Ax + By + Cz + d = 0

 The d component in the equation represents the


distance from the plane to the origin. The distance is
computed by tracing a line towards the plane until
you hit it.
Ax + By + Cz + d = 0

 Finally the triplet (x ,y, z) is any point that satisfies


the equation
 The set of all points (x ,y, z) that solve the equation
is exactly all the points that lie in the plane
‘d’ is -ve when the normal faces away from origin
‘d’ is +ve when the normal faces towards origin
 It's important to notice that technically the normal (x,
y, z) does not have to be unit-length for it to have a
valid plane equation. But since things end up nicer if
the normal is unit-length.
Back-face Culling
Back-face Culling

 To perform the back-face cull, just subtract one of the


triangle's points from the camera location and
perform a dot product of the resultant vector and the
normal. If the result of the dot product is greater than
zero, then the view point was in front of the triangle
Figure: A visual example of back-face culling
Triangle Rasterization
Flat Filling Triangles
 For each scan line (horizontal line on the screen),
find the points of intersection with the edges of the
triangle. Then, draw a horizontal line between
intersections and do this for all scan lines.
Gouraud Shading Triangles
 Flat triangle interpolated only one value (x in
connection with y), 256 colors gouraud needs three
(x related to y, color related to y, and color related to
x),
 hi-color gouraud needs seven parameters (i.e. x
related to y, red, green and blue components of color
related to y, and color related to x (also three
components))
Textured Triangles
 We can also apply any bitmap on triangle for filling it.
 Again we're using the idea of interpolation; And
again the idea is perfectly the same, only two more
values to interpolate, that is five values in all
 In texture mapping, we interpolate x, u, and v
related to y, and u and v related to x (u and v are
coordinates in the 2D bitmap space)
The left triangle is the triangle which is drawn onto the
screen. There's a single scanline (one call to the
horizontal line routine) pointed out as an example.
The triangle on the right is the same triangle in the
bitmap space, and there's the same scanline drawn
from another point of view into it, too..
COLOR

 A color is usually represented in the graphics


pipeline by a three-element vector representing the
intensities of the red, green, and blue components
 Or for a more complex object, by a four-element
vector containing an add-itional value called the alpha
component that represents the opacity of the color
 Colors can also be represented as floating point
values in the range [0,1]
A 16-bit display is named since each pixel in a 16-bit
image is taken up by 16 bits (2 bytes):
 5 bits of red information,
 6 bits of green information,
 and 5 bits of blue information
 A 24-bit display, of course, uses 24 bits, or 3 bytes
per pixel, for color information. This gives 1 byte, or
256 distinct values each, for red, green, and blue
Finally, there is 32-bit color, something seen on most
new graphics cards. Many 3D accelerators keep 8
extra bits per pixel around to store transpa-rency
information, which is generally referred to as the
alpha channel
GAMUT
The 1931 CIE diagram
shows the gamut of
the eye and the
lesser gamut of
output devices.
Multiplication of Colors

 Colors are multiplied to describe the interaction


between a surface and a light source
 The colors of each are multiplied together to estimate
the reflected light color–this is the color of the light
that this particular light reflects off this surface
• This intensity of our light is represented by, say, a nice
lime green color

• Let's say we shine this light on a nice magenta surface


given by cs.
Multiplying (modulating) color values results in
a color equal to or less than (darker) the
original two.
Dealing with Saturated Colors
Adding colors can result in colors that are outside
the displayable range.
The results of three strategies for dealing with the same
oversaturated color.
Clamping Color Values

Any value that's greater than one is clamped to one,


and any value less than zero are clamped to zero.
Scaling Color Values

Instead of clamping, we might want to scale the color by


dividing by the largest color value, thus scaling the rgb
values into the [0,1] range.
Clipping Color Values

One problem with clamping or scaling colors is that they


get darker (lose saturation). An alternative to scaling is
to maintain saturation by shifting color values. This
technique is called clipping,
Color Space Tool

 The ColorSpace tool is a handy tool that we can use


to interactively add two colors together to see the
effects of the various strategies for handling
oversaturated colors.
Negative Colors and Darklights

 Darklights are nothing more than lights in which one


or more of the color values are negative.
Uses of Darklights

 Eliminate bright areas of a scene


 Filter out a specific RGB color
 Night Vision – to eliminate Red and Blue components
Alpha Blending

 An alpha value of 0xFF (255) means the color is


completely opaque, and an alpha value of 0x00 (0)
means the color is completely transparent.
 The name "alpha blending" comes from the fact that
generally the blending factors used are either the
alpha or the inverse of the alpha.
Final Color =
SOURCE *
SOURCE BLEND FACTOR
+
DESTINATION *
DESTINATION BLEND FACTOR
FINAL COLOR = SOURCE * 1.0 + DESTINATION * 0.0
First Image
Second Image
Image after blending
Computer Graphics

Lecture 28

You might also like