3fill in all pixels between pairs of intersections

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e polygon. 2.Sort the intersections in the increasing order of the x coordinate. 3.Fill in all pixels between pairs of  intersections. Can also deal with concave polygons Span extrema Only turn on pixels whose centers are interior to the polygon: Otherwise will intrude other adjacent polygons round up values on the left edge of a span, round down on the right edge Scanline Algorithm Cons and Pros - Simple - Very serial (cannot be efficiently parallelized) - Special cases require exception handling Triangle Rasterization by Barycentric Coordinates Barycentric coordinates ● Can check whether a pixel is inside / outside the triangle ● Can interpolate the attributes at the vertices ● Often used in modern graphics cards ● Can be easily parallelized Triangle Rasterization * Barycentric Coordinates * Computing Barycentric Coordinates The triangle is composed of 3 points p0 (x0,y0), p1 (x1, y1), p2(x2,y2). For point (x,y), its barycentric coordinates can be computed by where Bounding Box of a Triangle Calculate a tight bounding box for a triangle: simply calculate pixel coordinates for each vertex, and find the minimum/maximum for each axis min (x0,x1,x2), max (x0,x1,x2) min (y0,y1,y2), max (y0,y1,y2) * Scanning inside the triangle ● For each pixel, compute the barycentric coordinates ● Color it if all the three values are in the range of [0,1] * Interpolation by Barycentric Coordinates We can use the barycentric coordinates to interpolate attributes of the triangle vertices •color, depth, normal vectors, texture coordinates c1 c2 (α,β,γ) αc1+βc2 +γc3 c3 Interpolation of Depth •When triangles are overlapped, need t...
View Full Document

This document was uploaded on 03/26/2014.

Ask a homework question - tutors are online