prog 2 kangaroo hall of fame midterm review interpolation
play

Prog 2, Kangaroo Hall of Fame, Midterm Review, (Interpolation if - PowerPoint PPT Presentation

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Prog 2, Kangaroo Hall of Fame, Midterm Review, (Interpolation if time) Week 6, Wed Feb 9 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005 Program 2


  1. University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Prog 2, Kangaroo Hall of Fame, Midterm Review, (Interpolation if time) Week 6, Wed Feb 9 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005

  2. Program 2 Corrections/Clarifications  handin 314 proj2 (not 414)  ‘f’ not ‘s’ to toggle flat/smooth shading  ‘s’ already in use for camera  add: ‘t’ to toggle between randomly colored and grey terrain  makes it easier to check if lighting correct  add: ‘u’ to replace terrain with new randomly generated geometry  consider adding for a bit of extra credit:  ‘+/-’ toggle to increment/decrement abs cam speed 2

  3. Program 2 Corrections/Clarifications  roll/yaw confusion  first para. correct, second para. wrong  left horiz drag = yaw, right horiz drag = roll  image + flying expertise courtesy of Matt Baumann 3

  4. Program 2 Quick Demo 4

  5. Review: Midpoint Algorithm  moving incrementally along x direction  draw at current y value, or move up to y+1?  check if midpoint between two possible pixel centers above or below line  candidates  top pixel: (x+1,y+1),  bottom pixel: (x+1, y)  midpoint: (x+1, y+.5)  check if midpoint above or below line  below: top pixel  above: bottom pixel 0 < dy  assume , slope x < x dx < 1 1 2 5

  6. Review: Bresenham Algorithm y=y0; e=0; for (x=x0; x <= x1; x++) { draw(x,y);  all integer arithmetic if (2(e+dy) < dx) {  cumulative error function e = e+dy; } else { y=y+1; e=e+dy-dx; y=y0; eps=0 }} for ( int x = x0; x <= x1; x++ ){ draw(x,y); eps += dy; if ( (eps << 1) >= dx ){ y++; eps -= dx; } } 6

  7. Review: Flood Fill  draw polygon edges, seed point, recursively set all neighbors until boundary is hit to fill interior  drawbacks: visit pixels up to 4x, per-pixel memory storage needed P 7

  8. Review: Scanline Algorithms  set pixels inside polygon boundary along horizontal lines one pixel apart  use bounding box to speed up 3 1 5=0 2 P 4

  9. Review: Edge Walking  basic idea:  draw edges vertically  interpolate colors down edges  fill in horizontal spans for each scanline  at each scanline, interpolate edge colors across span 9

  10. Review: General Polygon Rasterization  idea: use a parity test for each scanline edgeCnt = 0; for each pixel on scanline (l to r) if (oldpixel->newpixel crosses edge) edgeCnt ++; // draw the pixel if edgeCnt odd if (edgeCnt % 2) setPixel(pixel); 10

  11. Hall of Fame 11

  12. But Wait, There’s More!  nice comment :)  “this project is fun, only one of the very few that I actually enjoyed. Too bad there's only one CG course in UBC =(  two fourth year CG courses await you!  424 Geometric Modelling  426 Animation 12

  13. Midterm Review 13

  14. Midterm Exam  Friday Feb 11 10am-10:50am  you may use one handwritten 8.5”x11” sheet  one side of page  no other notes, no books  nonprogrammable calculators OK  arrive on time!  sit every other seat, ID out in front of you  coats and bags in front of room 14

  15. What’s Covered  transformations  viewing and projections  coordinate systems of rendering pipeline  lighting and shading  not scan conversion 15

  16. Reading  FCS book, Red book  see web page for details  you can be tested on material in book but not covered in lecture  you can be tested on material covered in lecture but not covered in book 16

  17. Old Exams Posted  see course web page 17

  18. The Rendering Pipeline  pros and cons of pipeline approach Model/View Model/View Perspective Geometry Model/View Perspective Geometry Perspective Geometry Lighting Lighting Clipping Clipping Lighting Clipping Transform. Transform. Transform. Database Database Transform. Transform. Transform. Database Frame- Frame- Frame- Scan Scan Depth Scan Depth Depth Texturing Texturing Texturing Blending Blending Blending buffer buffer Conversion buffer Conversion Conversion Test Test Test 18

  19. Transformations translate(a,b,c) translate(a,b,c) scale(a,b,c) scale(a,b,c) x ' 1 a x x ' a x                         y ' 1 b y y ' b y             = = z ' c z z ' 1 c z                         1 1 1 1 1 1             Rotate ( x , ) Rotate ( z , ) Rotate ( y , ) θ θ θ cos sin x ' 1 x cos sin θ − θ θ θ                     sin cos y ' cos sin y 1 θ − θ θ θ           = z ' sin cos z 1 sin cos         θ θ   − θ θ           1 1 1 1 1           19

  20. Homogeneous Coordinates  x w x w ⋅  ⋅        y w y w w ⋅ w ⋅     w w         x x     w= 1 1 w=     y y     1 1         y y x x 20

  21. Composing Transformations Ta Tb = Tb Ta, but Ra Rb Rb != != Rb Rb Ra and Ta Ra and Ta Rb Rb != != Rb Rb Ta Ta Ta Tb = Tb Ta, but Ra 21

  22. Composing Transformations  example: rotation around arbitrary center 22

  23. Composing Transformations  example: rotation around arbitrary center  step 1: translate coordinate system to rotation center 23

  24. Composing Transformations  example: rotation around arbitrary center  step 2: perform rotation 24

  25. Composing Transformations  example: rotation around arbitrary center  step 3: back to original coordinate system 25

  26. Composing Transformations  rotation about a fixed point p’ = TRT -1 p  rotation around an arbitrary axis OpenGL:  considering frame vs. object D  p’ = DCBAp C frame B A draw p object 26

  27. Transformation Hierarchies  hierarchies don’t fall apart when changed  transforms apply to graph nodes beneath 27

  28. Matrix Stacks  push and pop matrix stack  avoid computing inverses or incremental xforms  avoid numerical error T 2 (x) T 2 (x) T 1 (x) T 1 (x) T 3 (x) T 3 (x) World coordinates World coordinates 28

  29. Matrix Stacks D = C scale(2,2,2) trans(1,0,0) D = C scale(2,2,2) trans(1,0,0) glPushMatrix() () glPushMatrix glPopMatrix() () glPopMatrix C D C D DrawSquare() () DrawSquare C C C C C glPushMatrix() () C C glPushMatrix C glScale3f(2,2,2) glScale3f(2,2,2) B B B B B B B B glTranslate3f(1,0,0) glTranslate3f(1,0,0) A A A A A A A A DrawSquare() () DrawSquare glPopMatrix() () glPopMatrix 29

  30. Transformation Hierarchies  example glTranslate3f(x,y,0); glTranslate3f(x,y,0); glRotatef( ,0,0,1); ( ,0,0,1); glRotatef θ 1 DrawBody(); (); DrawBody glPushMatrix(); (); glPushMatrix θ glTranslate3f(0,7,0); glTranslate3f(0,7,0); 2 DrawHead(); (); θ DrawHead 4 glPopMatrix(); (); glPopMatrix glPushMatrix(); (); glPushMatrix glTranslate(2.5,5.5,0); (2.5,5.5,0); glTranslate θ θ glRotatef( ,0,0,1); ( ,0,0,1); glRotatef θ θ 3 5 2 1 DrawUArm(); (); DrawUArm glTranslate(0,-3.5,0); (0,-3.5,0); glTranslate y y glRotatef( ,0,0,1); ( ,0,0,1); glRotatef θ 3 DrawLArm(); (); DrawLArm x x glPopMatrix(); (); glPopMatrix ... (draw other arm) ... (draw other arm) 30

  31. Display Lists  reuse block of OpenGL code  more efficient than immediate mode  code reuse, driver optimization  good for static objects redrawn often  can’t change contents  not just for multiple instances  interactive graphics: objects redrawn every frame  nest when possible for efficiency 31

  32. Double Buffering  two buffers, front and back  while front is on display, draw into back  when drawing finished, swap the two  avoid flicker 32

  33. Projective Rendering Pipeline glVertex3f(x,y,z) glVertex3f(x,y,z) viewing/ object world camera alter w alter w WCS VCS WCS VCS OCS OCS glFrustum(...) (...) glFrustum projection projection modeling modeling viewing viewing transformation transformation transformation transformation transformation transformation clipping glTranslatef(x,y,z) (x,y,z) gluLookAt(...) (...) glTranslatef gluLookAt / w / w CCS CCS glRotatef( (th th,x,y,z) ,x,y,z) glRotatef perspective perspective .... .... normalized division division OCS - object coordinate system device glutInitWindowSize(w,h) (w,h) glutInitWindowSize WCS - world coordinate system glViewport(x,y,a,b) (x,y,a,b) glViewport NDCS NDCS viewport viewport VCS - viewing coordinate system transformation transformation CCS - clipping coordinate system device DCS DCS NDCS - normalized device coordinate system 33 DCS - device coordinate system

  34. Projection  theoretical pinhole camera eye eye point point image image plane plane – image inverted, more convenient equivalent eye eye point point image image plane plane 34

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend