Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Lecture 28 REVIEW III Taqdees A. Siddiqi

Similar presentations


Presentation on theme: "Computer Graphics Lecture 28 REVIEW III Taqdees A. Siddiqi"— Presentation transcript:

1 Computer Graphics Lecture 28 REVIEW III Taqdees A. Siddiqi cs602@vu
Computer Graphics Lecture 28 REVIEW III Taqdees A. Siddiqi

2 REVIEW III Taqdees A. Siddiqi cs602@vu.edu.pk

3 Oblique Projection

4

5 Xp = x + z ( L1 cos (Ф) ) Yp = y + z ( L1 sin (Ф) )

6 Perspective Projection

7 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

8 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: 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:

9

10 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:

11

12 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:

13

14 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.

15 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).

16 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.

17 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:

18 |BS| / |AB| = |CP| / |AC| |BS| = |AB| * |CP| / |AC| |BS| = Screen.z * point.x / point.z

19 Note that: Screen.z is the distance d from the point of view at origin or the scaling factor.

20 Triangles

21 Triangles "flesh out" a 3D object, connecting them together to form a skin or mesh that defines the boundary surface of an object

22 The ordering of the vertices goes clockwise around the triangle

23 Three points in space, and the triangle connecting them

24 Triangle Strips and Fans

25 Triangle List The first is an explicit list or array of triangles, where every three elements represent a new triangle.

26 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.

27 A list of points composing a triangle fan

28 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.

29 The first three elements define the first triangle
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

30 A list of points composing a triangle strip

31 Plane Planes are defined as infinitely large, infinitely thin slices of space, like big pieces of paper.

32 Each of the triangles that make up our model, exists in its own plane

33 Equation of plane in 3D Ax + By + Cz + d = 0

34 Ax + By + Cz + d = 0 The triplet (a, b ,c) represents what is called the normal of the plane

35 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.

36 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

37 ‘d’ is -ve when the normal faces away from origin

38 ‘d’ is +ve when the normal faces towards origin

39 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.

40 Back-face Culling

41 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

42 Figure: A visual example of back-face culling

43 Triangle Rasterization Flat Filling Triangles

44 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.

45

46 Gouraud Shading Triangles

47 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),

48 hi-color gouraud needs seven parameters (i. e
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))

49 Textured Triangles

50 We can also apply any bitmap on triangle for filling it.

51 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

52 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)

53

54 The left triangle is the triangle which is drawn onto the screen
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.

55 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..

56 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

57 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

58 Colors can also be represented as floating point values in the range [0,1]

59 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

60 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

61 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

62 GAMUT The 1931 CIE diagram shows the gamut of the eye and the lesser gamut of output devices.

63 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

64 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.

65

66 Multiplying (modulating) color values results in a color equal to or less than (darker) the original two.

67 Dealing with Saturated Colors

68 Adding colors can result in colors that are outside the displayable range.

69 The results of three strategies for dealing with the same oversaturated color.

70 Any value that's greater than one is clamped to one, and any value less than zero are clamped to zero. Clamping Color Values

71 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.

72 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,

73 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.

74

75 Negative Colors and Darklights
Darklights are nothing more than lights in which one or more of the color values are negative.

76 Uses of Darklights Eliminate bright areas of a scene
Filter out a specific RGB color Night Vision – to eliminate Red and Blue components

77 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.

78 The name "alpha blending" comes from the fact that generally the blending factors used are either the alpha or the inverse of the alpha.

79 Final Color = SOURCE. SOURCE BLEND FACTOR + DESTINATION
Final Color = SOURCE * SOURCE BLEND FACTOR + DESTINATION * DESTINATION BLEND FACTOR

80 FINAL COLOR = SOURCE * 1.0 + DESTINATION * 0.0

81 First Image

82 Second Image

83 Image after blending

84 Computer Graphics Lecture 28


Download ppt "Computer Graphics Lecture 28 REVIEW III Taqdees A. Siddiqi"

Similar presentations


Ads by Google