1 / 131

Review: The Basics

Review: The Basics. See pages 3-29 in the textbook This is basically a one-semester graphics course in one lecture set!. A Rendering Process. Scene is modeled using polygons in a hierarchical structure Scene is transformed into a view coordinate system

Download Presentation

Review: The Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Review: The Basics • See pages 3-29 in the textbook • This is basically a one-semester graphics course in one lecture set!

  2. A Rendering Process • Scene is modeled using polygons in a hierarchical structure • Scene is transformed into a view coordinate system • Culling – removing polygons that face away from the user • Clipping – Polygons are clipped to a 3D view volume (Frustum) • Clipped polygons are projected to 2D space • Colors are computed for the corners • Polygons are scan-line converted using incremental shading/texturing algorithms

  3. Modeling • Surfaces are created using polygons • Usually convex polygons • Order of vertex specification is important • For each vertex, specify: • Coordinates in object space • Vertex normal (orthogonal to surface at the vertex)

  4. OpenGL Example: A Cube void CChildView::Cube(GLdouble size) { GLdouble a[] = {0., 0., size}; GLdouble b[] = {size, 0., size}; GLdouble c[] = {size, size, size}; GLdouble d[] = {0., size, size}; GLdouble e[] = {0., 0., 0.}; GLdouble f[] = {size, 0., 0.}; GLdouble g[] = {size, size, 0.}; GLdouble h[] = {0., size, 0.}; glColor3d(0.8, 0., 0.); glBegin(GL_POLYGON); // Front glNormal3d(0, 0, 1); glVertex3dv(a); glVertex3dv(b); glVertex3dv(c); glVertex3dv(d); glEnd(); . . . h g c d e f a b

  5. Determining Normals • Computed surface normal • What math to do this? • Averaged surface normals • Underlying model equations

  6. a  b = [aybz-azby, azbx-axbz, axby-aybx]T Computing a surface normal • Given three non-colinear vertices, we can easily compute a surface normal: c b d a

  7. Making facets look smooth Nc Nd Nb Nv Na Ng Nh Nf Ne Provide a normal for each vertex. Each will be different...

  8. Example

  9. Vertex Issues: Large Polygons • Gouraud Shading: Compute the color at the vertices and interpolate over the face. • Most implementations of OpenGL and Direct3D • This causes problems with large polygons! • Why?

  10. How to fix • Avoid large polygons • Subdivide to solve the problem • How much?

  11. Example Omni directional white light and yellow spotlight. 9 1 25 900

  12. Smooth Shading • Smooth Shading is the use of interpolation to simulate curves and other graduate shading changes

  13. Gouraud Shading • Gouraud Shading • Compute the color at the vertices • Interpolate the color over the face of the primitive • Most implementations of OpenGL

  14. Notice: 2D Example (x,y) intensity (80,200) .7 I want the color der! (70,150) .65 (0,120) (180,80) .6 (100,0) .5

  15. Linear Interpolation • If we know how are we are along a line in one dimension, we can figure how are we are in the other dimensions (110, 75) 0.7 y=60, what is x? (70, 50) 0.5

  16. Bilinear Interpolation (80,200) .7 (30,150) 0.669 (121.7,150) 0.658 (70,150) .65 (0,120) (180,80) .6 (100,0) .5

  17. Bilinear Interpolation (80,200) .7 (30,150) 0.669 (121.7,150) 0.658 (70,150) .65 (0,120) (180,80) .6 (100,0) .5

  18. Gouraud Shading • Advantages • Color math only at vertices • Can be costly • Fast and easy (if we are drawing primitives) • Disadvantages • Does not simulate the actual curve, only the fact that colors interpolate • Color cannot increase beyond vertex colors. • When would that happen?

  19. Specular Highlights • What if the specular highlight is in a polygon? Specular Highlight Location Sphere Example!

  20. Phong Shading Sometimes called “Pixel shading” • Phong Shading • Interpolate Normals rather than colors • Compute color at each pixel Gouraud Phong

  21. Phong Shading • Advantages • Always better quality than Gouraud • Specular highlights are much better • Fewer polygons are required • Less fine tessellation • Disadvantages • Color computation at every pixel

  22. Problems with Smooth Shading • Polygonal Silhouette • Orientation Dependence

  23. Problems with Smooth Shading • Lights in the scene with large polygons • Unshared or missing vertices

  24. Problems with Smooth Shading • Unrepresentative Vertex Normals

  25. Problems with Smooth Shading • Too large a polygon

  26. Problems with Smooth Shading • Concave Polygons Abrupt color change around this point

  27. How would you build a robot? Body, head, arms, legs, etc. How would you build a hand? Palm, fingers, etc. Observe Fingers may be the same Arms may be the same Only relationships may differ Modeling and Composite Graphical Objects

  28. Robot Scene Graph Robot T T T T T Body Arm Leg T T T T T T Neck Torso Upper Lower Hand T T T T Thumb Finger

  29. OpenGL Scene Graphs void CRobot::Draw() { glPushMatrix(); glTranslated(BODYX, BODYY, BODYZ); DrawBody(); glPopMatrix(); glPushMatrix(); glTranslated(RARMX, RARMY, RARMZ); glRotated(90., 0, 0, 1); DrawARM(); glPopMatrix(); glPushMatrix(); glTranslated(LARMX, LARMY, LARMZ); glRotated(-90., 0, 0, 1); DrawARM(); glPopMatrix(); }

  30. Building a Bridge 4” 24”

  31. Geometric Transformations • Internally, we have vertices, normals, and operations on them. • The operations on them are called geometric transformations • Rotation, scaling, translation, etc.

  32. Affine operations • Translation • x’ = x + tx • y’ = y + ty • z’ = z + tz • Scaling • x’ = sxx • y’ = syy • z’ = szz • Rotation (CCW around z axis) • x’ = xcosq - ysinq • y’ = xsinq + ycosq • z’ = z • Skew (or Shear) • x’ = x + ay • y’ = y • z’ = z

  33. We sure would like to be able to do this in a matrix operation • Scaling • x’ = sxx • y’ = syy • z’ = szz • Rotation (CCW around z axis) • x’ = xcosq - ysinq • y’ = xsinq + ycosq • z’ = z Translation?

  34. 3D Transformations • Homogeneous coordinates in 3D • [x,y,z,1]T (x,y,z,w) • Matrices of this form: • 4x4 Matrices instead of 3x3 for 3D

  35. Translation

  36. How do I do auniform scale? Scaling

  37. What about Rotation? • How can we convert this to 3D?

  38. Rotation about Z axis Just keeps z constant!

  39. The 3 Rotation Matrices

  40. Skew or Shear

  41. Advantages of matrices • We can multiply them together • Matrix multiplication is associative • Any number of sequential operations in one (1) 4x4 matrix!!! • Notice: You can transpose everything and get the same result • Read left to right instead of right to left • Vertices are row vector rather than column vector • (DirectX and the textbook use this format)

  42. Inverses • We’ll often need matrix inverses • Most are easy to figure out • T(a,b,c)-1=T(-a,-b,-c) • Rx(q)-1=Rx(-q) • Inverses of rotation matrices are transposes • Other rule to remember • (ABC)-1=C-1B-1A-1

  43. Creating a Complex Transformation • What does gluLookAt do? void gluLookAt( GLdouble eyex,GLdouble eyey,GLdouble eyez,GLdouble centerx,GLdouble centery,GLdouble centerz,GLdouble upx,GLdouble upy,GLdouble upz);

  44. Some Math We’ll Need • Normalized vector • |v|=1 • How to normalize? • Dot product • a  b = axbx+ayby+azbz • Dot product of two normalized vectors is the cosine of the angle between them. • Scalar result • Cross product • a  b = [aybz-azby, azbx-axbz, axby-aybx]T

  45. Orthogonal Vectors • Orthogonal Vectors • Vectors at right angles to each other • v1 v2 = 0 • Characteristic of Normalized Vectors • v1 v1 = 1 • Cross product of normalized vectors yields orthogonal vectors • a  b will be orthogonal to both a and b • X  Y is Z, Y  Z is X, Z  X is Y • a  b = -(b  a)

  46. Homogenous Coordinates and Vectors • It is convention that • Points in space are indicated with w=1 • Vectors are indicated with w=0 • [12, 13, 5, 1]T is a point • [45, 13, 2, 0]T is a vector (point – point?) • Take care with those w values! • I often use Normalize3() rather than Normalize() as a function name.

  47. Frames • Frame – A center and three coordinate axes • A coordinate system World Frame and Camera Frame

  48. Defining a Frame(relative to another frame) • Need: • Origin • Vectors for X, Y, and Z axis of frame

  49. Lesser Specification • We can get by with: • Origin • One axis direction and which way is up When is enough enough? Z direction is negative of look direction. X is at right angles to Z and Up

More Related