DOC PREVIEW
UVA CS 445 - Clipping

This preview shows page 1-2-3-4-27-28-29-30-56-57-58-59 out of 59 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 59 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ClippingOutlineRecap: Homogeneous CoordsRecap: Perspective ProjectionSlide 5Recap: Perspective Projection MatrixRecap: OpenGL’s Persp. Proj. MatrixProjection MatricesSlide 9Next Topic: ClippingSlide 11Why Clip?Slide 13Trivial AcceptsTrivial RejectsSlide 16Cohen-Sutherland Line ClippingSlide 18Slide 19Slide 20Slide 21Slide 22Clipping PolygonsWhy Is Clipping Hard?Slide 25Slide 26Slide 27Sutherland-Hodgman ClippingSlide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39Slide 40Slide 41Point-to-Plane testPoint-to-Plane TestFinding Line-Plane IntersectionsSlide 45Line-Plane IntersectionsSlide 473-D ClippingSlide 49Clipping Under PerspectiveSlide 51Slide 52Perspective ProjectionSlide 54Slide 55Clipping Homogeneous CoordsSlide 57Slide 58Clipping: The Real WorldClippingAaron BloomfieldCS 445: Introduction to GraphicsFall 2006(Slide set originally by David Luebke)2OutlineReviewClipping BasicsCohen-Sutherland Line ClippingClipping PolygonsSutherland-Hodgman ClippingPerspective Clipping3Recap: Homogeneous CoordsIntuitively:The w coordinate of a homogeneous point is typically 1Decreasing w makes the point “bigger”, meaning further from the originHomogeneous points with w = 0 are thus “points at infinity”, meaning infinitely far away in some direction. (What direction?)To help illustrate this, imagine subtracting two homogeneous points: the result is (as expected) a vector4Recap: Perspective ProjectionWhen we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world:How tall shouldthis bunny be?5Recap: Perspective ProjectionThe geometry of the situation:Desiredresult:P (x, y, z)XZViewplaned(0,0,0)x’ = ?' , ' ,d x x d y yx y z dz z d z z d� �= = = = =6Recap: Perspective Projection MatrixExample:Or, in 3-D coordinates:10100010000100001zyxddzzyxddzydzx,,7Recap: OpenGL’s Persp. Proj. MatrixOpenGL’s gluPerspective() command generates a slightly more complicated matrix:Can you figure out what this matrix does?2cotwhere0100200000000yfarnearnearfarfarnearnearfarfovfZZZZZZZΖfaspectf8Projection MatricesNow that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplicationEnd result: can create a single matrix encapsulating modeling, viewing, and projection transformsThough you will recall that in practice OpenGL separates the modelview from projection matrix (why?)9OutlineReviewClipping BasicsCohen-Sutherland Line ClippingClipping PolygonsSutherland-Hodgman ClippingPerspective Clipping10Next Topic: ClippingWe’ve been assuming that all primitives (lines, triangles, polygons) lie entirely within the viewport In general, this assumption will not hold11ClippingAnalytically calculating the portions of primitives within the viewport12Why Clip?Bad idea to rasterize outside of framebuffer bounds Also, don’t waste time scan converting pixels outside window13ClippingThe naïve approach to clipping lines:for each line segment for each edge of viewport find intersection points pick “nearest” point if anything is left, draw itWhat do we mean by “nearest”?How can we optimize this?14Trivial Accepts Big optimization: trivial accept/rejectsHow can we quickly determine whether a line segment is entirely inside the viewport?A: test both endpoints. xminxmaxymaxymin15Trivial RejectsHow can we know a line is outside viewport?A: if both endpoints on wrong side of same edge, can trivially reject linexminxmaxymaxymin16OutlineReviewClipping BasicsCohen-Sutherland Line ClippingClipping PolygonsSutherland-Hodgman ClippingPerspective Clipping17Cohen-Sutherland Line ClippingDivide viewplane into regions defined by viewport edgesAssign each region a 4-bit outcode: 0000 0010000110010101 01001000 10100110xminxmaxymaxymin18Cohen-Sutherland Line ClippingTo what do we assign outcodes?How do we set the bits in the outcode?How do you suppose we use them?xminxmax0000 0010000110010101 01001000 10100110ymaxymin19Cohen-Sutherland Line ClippingSet bits with simple testsx > xmax y < ymin etc.Assign an outcode to each vertex of lineIf both outcodes = 0, trivial acceptbitwise AND vertex outcodes togetherIf result  0, trivial rejectAs those lines lie on one side of the boundary lines0000 0010000110010101 01001000 10100110ymaxymin20Cohen-Sutherland Line ClippingIf line cannot be trivially accepted or rejected, subdivide so that one or both segments can be discardedPick an edge that the line crosses (how?)Intersect line with edge (how?)Discard portion on wrong side of edge and assign outcode to new vertexApply trivial accept/reject tests; repeat if necessary21Outcode tests and line-edge intersects are quite fast (how fast?) But some lines require multiple iterations:Clip topClip leftClip bottomClip rightFundamentally more efficient algorithms:Cyrus-Beck uses parametric linesLiang-Barsky optimizes this for upright volumesCohen-Sutherland Line Clipping22OutlineReviewClipping BasicsCohen-Sutherland Line ClippingClipping PolygonsSutherland-Hodgman ClippingPerspective Clipping23Clipping PolygonsWe know how to clip a single line segmentHow about a polygon in 2D?How about in 3D?Clipping polygons is more complex than clipping the individual linesInput: polygonOutput: polygon, or nothingWhen can we trivially accept/reject a polygon as opposed to the line segments that make up the polygon?24What happens to a triangle during clipping?Possible outcomes:TriangletriangleWhy Is Clipping Hard?TrianglequadTriangle5-gonHow many sides can a clipped triangle have?25A really tough case: Why Is Clipping Hard?26A really tough case: Why Is Clipping Hard?concave polygonmultiple polygons27OutlineReviewClipping BasicsCohen-Sutherland Line ClippingClipping PolygonsSutherland-Hodgman


View Full Document

UVA CS 445 - Clipping

Documents in this Course
Lighting

Lighting

49 pages

Color

Color

20 pages

Clipping

Clipping

10 pages

Shadows

Shadows

95 pages

Color

Color

37 pages

Radiosity

Radiosity

49 pages

Assign 3

Assign 3

28 pages

Splines

Splines

17 pages

Color

Color

17 pages

Load more
Download Clipping
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Clipping and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Clipping 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?