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