300 likes | 367 Views
Status – Week 227. Victor Moya. Summary. How to lose a week. Rasterization. Rasterization. What is the problem with w? If w is 0 (vertex in the near plane) then x/w and y/w are infinite! You can not draw something in the infinite ...
E N D
Status – Week 227 Victor Moya
Summary • How to lose a week. • Rasterization.
Rasterization • What is the problem with w? • If w is 0 (vertex in the near plane) then x/w and y/w are infinite! • You can not draw something in the infinite ... • If w is < 0 then weird things happen. Wrapping around the infinite.
Rasterization A vertex with w = 0 and no clipping
Rasterization A vertex with w = 0 and clipping
Rasterization A vertex with w < 0 and no clipping
Rasterization Vertex with w < 0 and clipping
Rasterization • That is why clipping should be mandatory ... • However using 2DH rasterization (Olano & Greer, McCool) • We don’t need to divide by w the vertices. • The triangle three edge equations can be derived without calculating x/w and y/w for the vertex.
Rasterization • That’s fine. • But we still have a problem ...
Rasterization • Where do we start drawing? • Test all pixels => Pixel Planes • Evaluate edge equations at all pixels in parallel (usually using tiles). • Search a region or pixel inside the triangle. • Recursive approach. • McCool paper: hierarchical rasterization with Hilber curves. • Calculate a start point. • But we can’t use x/w and y/w without clipping!!!
Rasterization • Test all pixels: • Tiled architecture with evaluators at all pixels. • Only uses by Pixel Planes. • Are we not going to use this approach? • It seems too much hardware ... • Is applicable to current GPUs?
Rasterization • Recursive search: • We could try to implement McCool algorithm or another similar. • But it takes log(N, M) cycles to generate the first fragment. • And requires to a stack of saved states (McCool actually walks back, expending cycles in the process).
Rasterization • But performs trivial clip reject at first level evaluation. • Admits early HZ rejection of large triangle regions. • Requires multiple HZ levels. • And you could reuse the multiple evaluators of stamp based rasterizer for a faster search. • Study the cost in hardware and time. • To be done?
Rasterization • Calculate a start point: • You can actually calculate x/w and y/w and pick a vertex as start point. • But only if w > 0. • What happens with if w <= 0? • It seems there is always either • at least one of the three vertices inside the viewport (w > 0) or • at least one viewport corner inside the projected triangle. • Because the projected triangle should still be a convex polygon (or so I hope).
Rasterization • So the start point can be either: • A projected vertex. • A corner of the viewport. • Algorithm: • If any vertex has w > 0 choose a vertex as start point. • If all vertex have w <= 0 evaluate the edge equations at the four viewport corners. • If any corner is inside choose a corner as start point.
Rasterization • Pro: • Seems to work ... unless I have missed something. • Cons: • Traversal algorithm now must take into account that it can start anywhere. • Increases saved state.
Rasterization • Hardware cost: • 3 x tests : w <= 0 (or w > 0) • 3 x 2 x divs : divide by w: x/w, y/w • 3 x 2 comps : for choosing a vertex • muxs additional logic for choosing a vertex. • 4 x 3 evaluators: e = ax + by + c: • 2 x muls • 2 x adds • 4 x 3 tests: e >= 0 • muxs and additional logic for choosing a corner. • mux and additional logic for choosing between vertices or corners.
Rasterization • Traversal cost for any start point/direction: • 4 saved states: • 3 edge equations • 3 values per edge equation. • Additional edge equations for other parameters? • Z/w? • Tiled traversal: • 4 additional tile save states.
Rasterization • Evaluators: • No stamp: • at least 4 x 3 evaluators (up, down, right, left) • at least 4 x 3 tests e >= 0. • Stamped (NxM): • at least (NxM + 4) x 3 evaluators (NxM current, up, down, right, left). • at least (NxM + 4) x 3 tests e >= 0.