1Greg HumphreysCS445: Intro GraphicsUniversity of Virginia, Fall 2004Clipping3D Rendering Pipeline (for direct illumination)3D PrimitivesModelingTransformationProjectionTransformationClippingLightingImageViewportTransformationScanConversion2D Image Coordinates3D Modeling Coordinates3D World Coordinates3D Camera Coordinates2D Screen Coordinates2D Screen CoordinatesViewingTransformation3D World Coordinates2D Image Coordinates3D Rendering Pipeline (for direct illumination)3D PrimitivesModelingTransformationProjectionTransformationClippingLightingImageViewportTransformationScanConversion2D Image Coordinates3D Modeling Coordinates3D World Coordinates3D Camera Coordinates2D Screen Coordinates2D Screen CoordinatesViewingTransformation3D World Coordinates2D Image Coordinates2D Rendering PipelineViewportTransformationScanConversionClipping2D PrimitivesImageClip portions of geometric primitivesresiding outside the window Fill pixels representing primitives in screen coordinatesTransform the clipped primitivesfrom screen to image coordinates 3D Primitives2D Rendering PipelineViewportTransformationScanConversionClipping2D PrimitivesImageClip portions of geometric primitivesresiding outside the window Fill pixels representing primitives in screen coordinatesTransform the clipped primitivesfrom screen to image coordinates 3D PrimitivesClipping• Avoid drawing parts of primitives outside window Window defines part of scene being viewed Must draw geometric primitives only inside windowScreen CoordinatesWindow2Clipping• Avoid drawing parts of primitives outside window Window defines part of scene being viewed Must draw geometric primitives only inside windowViewingWindowClipping• Avoid drawing parts of primitives outside window Points Lines Polygons Circles etc.ViewingWindowPoint ClippingWindowwx1 wx2wy2wy1(x,y)• Is point (x,y) inside the clip window?inside = (x >= wx1) && (x <= wx2) && (y >= wy1) && (y <= wy2);Line Clipping• Find the part of a line inside the clip windowP1P10P9P8P7P4P3P6P5P2Before ClippingP’8P’7P4P3P6P’5After ClippingLine Clipping• Find the part of a line inside the clip windowCohen Sutherland Line Clipping• Use simple tests to classify easy cases firstP1P10P9P8P7P4P3P6P5P23Cohen Sutherland Line Clipping• Classify some lines quickly by AND of bit codesrepresenting regions of two endpoints (must be 0)Bit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P1P10P9P8P7P4P3P6P5P2Cohen Sutherland Line Clipping• Classify some lines quickly by AND of bit codesrepresenting regions of two endpoints (must be 0)Bit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P1P10P9P8P7P4P3P6P5P2Cohen Sutherland Line Clipping• Classify some lines quickly by AND of bit codesrepresenting regions of two endpoints (must be 0)Bit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P5Cohen Sutherland Line Clipping• Classify some lines quickly by AND of bit codesrepresenting regions of two endpoints (must be 0)Bit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P54Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P8P’7P4P3P6P’55Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’5Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P10P9P’8P’7P4P3P6P’56Cohen-Sutherland Line Clipping• Compute intersections with window boundary forlines that can’t be classified quicklyBit 1 Bit 2Bit 3Bit 40000 010010000001 010110010010 01101010P’8P’7P4P3P6P’5Clipping• Avoid drawing parts of primitives outside window Points Lines Polygons Circles etc.2D Screen CoordinatesWindowPolygon Clipping• Find the part of a polygon inside the clip window?Before ClippingPolygon Clipping• Find the part of a polygon inside the clip window?After ClippingSutherland Hodgeman Clipping• Clip to each
View Full Document