page 1
play

Page 1 1 Midterm Topics Reading: Today H1, P1, H2, P2 FCG - PDF document

University of British Columbia News CPSC 314 Computer Graphics extra lab coverage: Mon 12-2, Wed 2-4 May-June 2005 P2 demo slot signup sheet Tamara Munzner handing back H1 today well try to get H2 back tomorrow Compositing,


  1. University of British Columbia News CPSC 314 Computer Graphics � extra lab coverage: Mon 12-2, Wed 2-4 May-June 2005 � P2 demo slot signup sheet Tamara Munzner � handing back H1 today � we’ll try to get H2 back tomorrow Compositing, Clipping, Curves � we will put them in bin in lab, next to extra handouts � solutions will be posted Week 3, Thu May 26 � you don’t have to tell us you’re using grace days � only if you’re turning it in late and you do *not* want to use up grace days http://www.ugrad.cs.ubc.ca/~cs314/Vmay2005 � grace days are integer quantities � Homework 1 Common Mistakes Schedule Change � Q4, Q5: too vague � HW 3 out Thu 6/2, due Wed 6/8 4pm � don’t just say “rotate 90”, say around which axis, and in which direction (CCW vs CW) � be clear on whether actions are in old coordinate frame or new coordinate frame � Q8: confusion on push/pop and complex operations � wrong: object drawn in wrong spot! glPushMatrix(); glTranslate(..a..); glRotate(..); draw things glPop(); � correct: object drawn in right spot glPushMatrix(); glTranslate(..a..); glRotate(..); � both: nice modular function glTranslate(..-a..); that doesn’t change modelview matrix draw things � � glPop(); Poll Midterm Logistics � which do you prefer? � Tuesday 12-12:50 � P4 due Fri, final Sat � sit spread out: every other row, at least three seats between you and next person � final Thu in-class, P4 due Sat � you can have one 8.5x11” handwritten one- sided sheet of paper � keep it, can write on other side too for final � calculators ok � � Page 1 1

  2. Midterm Topics Reading: Today � H1, P1, H2, P2 � FCG Chapter 11 � pp 209-214 only: clipping � first three lectures � topics � FCG Chap 13 � RB Chap Blending, Antialiasing, ... � Intro, Math Review, OpenGL � Transformations I/II/III � only Section Blending � Viewing, Projections I/II � � Reading: Next Time Errata � FCG Chapter 7 � p 214 � f(p) > 0 is “outside” the plane � p 234 � For quadratic Bezier curves, N=3 � w_i^N(t) = (N-1)! / (i! (N-i-1)!)... � �� Review: Illumination Review: Light Sources � directional/parallel lights � transport of energy from light sources to surfaces & points � point at infinity: (x,y,z,0) T includes direct and indirect illumination � � point lights � finite position: (x,y,z,1) T � spotlights � position, direction, angle � ambient lights Images by Henrik Wann Jensen �� �� Page 2 2

  3. Review: Light Source Placement Review: Reflectance � geometry: positions and directions � specular : perfect mirror with no scattering � standard: world coordinate system � gloss : mixed, partial specularity � effect: lights fixed wrt world geometry � diffuse : all directions with equal energy � alternative: camera coordinate system � effect: lights attached to camera (car headlights) + + = specular + glossy + diffuse = reflectance distribution �� �� Review: Reflection Equations Review: Reflection Equations 2 n n l n h h � Blinn improvement I diffuse = k d I light (n • l) v v I specular = k s I light ( h • n ) n shiny θ l l h = ( l + v )/2 I specular = k s I light ( v • r ) n shiny � full Phong lighting model � combine ambient, diffuse, specular components # lights � k d ( n • l i ) + k s ( v • r i ) n shiny ) 2 ( N ( N · L )) – L = R I total = k s I ambient + I i ( i = 1 � don’t forget to normalize all vectors: n,l,r,v,h �� �� Review: Lighting Review: Shading Models � flat shading � lighting models � compute Phong lighting once for entire � ambient polygon � normals don’t matter � Gouraud shading � Lambert/diffuse � compute Phong lighting at the vertices and � angle between surface normal and light interpolate lighting values across polygon � Phong/specular � Phong shading � surface normal, light, and viewpoint � compute averaged vertex normals � interpolate normals across polygon and perform Phong lighting across polygon �� �� Page 3 3

  4. Review: Non-Photorealistic Shading Correction/Review: Computing Normals k w = 1 + n ⋅ l � cool-to-warm shading , c = k w c w + (1 − k w ) c c 2 � per-vertex normals by interpolating per-facet � draw silhouettes: if , e =edge-eye vector ( e ⋅ n 0 )(e ⋅ n 1 ) ≤ 0 normals ( n 0 ⋅ n 1 ) ≤ threshold � draw creases: if � OpenGL supports both � computing normal for a polygon � three points form two vectors � pick a point b (a-b) x (c-b) � vectors from � A: point to previous � B: point to next c-b � AxB: normal of plane direction a-b � normalize: make unit length c � which side of plane is up? � counterclockwise a point order convention �� http://www.cs.utah.edu/~gooch/SIG98/paper/drawing.html �� End of Class Last Time � use version control for your projects! � CVS, RCS � partially work through problem with lighting Compositing �� �� Compositing Premultiplying Colors specify opacity with alpha channel: (r,g,b, α ) � � how might you combine multiple elements? α =1: opaque, α =.5: translucent, α =0: transparent � � foreground color A , background color B A over B � C = α A + (1- α ) B � but what if B is also partially transparent ? � C = α A + (1- α ) β B = β B + α A + β B - α β B � γ = β + (1- β ) α = β + α – αβ � � 3 multiplies, different equations for alpha vs. RGB premultiplying by alpha � � C’ = γ C, B’ = β B, A’ = α A � C’ = B’ + A’ - α B’ � γ = β + α – αβ � 1 multiply to find C, same equations for alpha and RGB �� �� Page 4 4

  5. Rendering Pipeline Geometry Geometry Model/View Model/View Model/View Perspective Perspective Geometry Perspective Lighting Lighting Lighting Clipping Clipping Clipping Transform. Transform. Transform. Transform. Database Database Database Transform. Transform. Clipping Frame- Frame Frame- Scan Scan Scan Depth Depth Depth Texturing Texturing Texturing Blending Blending Blending buffer buffer Conversion Conversion Conversion Test Test buffer Test �� �� Next Topic: Clipping Clipping � we’ve been assuming that all primitives (lines, � analytically calculating the portions of triangles, polygons) lie entirely within the viewport primitives within the viewport � in general, this assumption will not hold: �� �� Why Clip? Line Clipping � bad idea to rasterize outside of framebuffer � 2D bounds � determine portion of line inside an axis-aligned rectangle (screen or window) � also, don’t waste time scan converting pixels outside window � 3D � could be billions of pixels for very close � determine portion of line inside axis-aligned objects! parallelpiped (viewing frustum in NDC) � simple extension to 2D algorithms �� �� Page 5 5

  6. Clipping Trivial Accepts � big optimization: trivial accept/rejects � naïve approach to clipping lines: � Q: how can we quickly determine whether a line for each line segment segment is entirely inside the viewport? for each edge of viewport � A: test both endpoints find intersection point pick “nearest” point if anything is left, draw it B � what do we mean by “nearest”? D � how can we optimize this? C A �� �� Trivial Rejects Clipping Lines To Viewport � Q: how can we know a line is outside � combining trivial accepts/rejects � trivially accept lines with both endpoints inside all edges viewport? of the viewport � A: if both endpoints on wrong side of same � trivially reject lines with both endpoints outside the same edge, can trivially reject line edge of the viewport � otherwise, reduce to trivial cases by splitting into two segments �� �� Cohen-Sutherland Line Clipping Cohen-Sutherland Line Clipping � assign outcode to each vertex of line to test � outcodes � line segment: ( p1,p2 ) � 4 flags encoding position of a point relative to � trivial cases top, bottom, left, and right boundary � OC( p1 )== 0 && OC( p2 )==0 1010 1000 1001 1010 1000 1001 � both points inside window, thus line segment completely � OC( p1 )=0010 y=y y max y= p3 p3 max visible (trivial accept) p1 p1 � OC( p2 )=0000 � (OC( p1 ) & OC( p2 ))!= 0 0010 0010 0000 0000 0001 0001 � OC( p3 )=1001 � there is (at least) one boundary for which both points are outside (same flag set in both outcodes) p2 p2 y=y y min y= min � thus line segment completely outside window (trivial 0110 0110 0100 0100 0101 0101 reject) x=x x min x=x x= x max x= max min �� �� Page 6 6

Recommend


More recommend