30
Status – Week Status – Week 227 227 Victor Moya Victor Moya

Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

Status – Week Status – Week 227227

Victor MoyaVictor Moya

Page 2: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

SummarySummary

How to lose a week.How to lose a week. Rasterization.Rasterization.

Page 3: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

What is the problem with w?What is the problem with w? If w is 0 (vertex in the near plane) If w is 0 (vertex in the near plane)

then x/w and y/w are infinite!then x/w and y/w are infinite! You can not draw something in the You can not draw something in the

infinite ...infinite ... If w is < 0 then weird things happen. If w is < 0 then weird things happen.

Wrapping around the infinite.Wrapping around the infinite.

Page 4: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 5: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

A vertex with w = 0 and no clipping

Page 6: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

A vertex with w = 0 and clipping

Page 7: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 8: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

A vertex with w < 0 and no clipping

Page 9: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Vertex with w < 0 and clipping

Page 10: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

That is why clipping should be That is why clipping should be mandatory ...mandatory ...

However using 2DH rasterization However using 2DH rasterization (Olano & Greer, McCool)(Olano & Greer, McCool) We don’t need to divide by w the We don’t need to divide by w the

vertices.vertices. The triangle three edge equations can The triangle three edge equations can

be derived without calculating x/w and be derived without calculating x/w and y/w for the vertex.y/w for the vertex.

Page 11: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

That’s fine.That’s fine. But we still have a problem ...But we still have a problem ...

Page 12: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Where do we start drawing?Where do we start drawing? Test all pixels => Pixel PlanesTest all pixels => Pixel Planes

Evaluate edge equations at all pixels in parallel Evaluate edge equations at all pixels in parallel (usually using tiles).(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 McCool paper: hierarchical rasterization with

Hilber curves.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!!!

Page 13: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Test all pixels:Test all pixels: Tiled architecture with evaluators at Tiled architecture with evaluators at

all pixels.all pixels. Only uses by Pixel Planes.Only uses by Pixel Planes. Are we not going to use this Are we not going to use this

approach?approach? It seems too much hardware ...It seems too much hardware ... Is applicable to current GPUs?Is applicable to current GPUs?

Page 14: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Recursive search:Recursive search: We could try to implement McCool We could try to implement McCool

algorithm or another similar.algorithm or another similar. But it takes log(N, M) cycles to But it takes log(N, M) cycles to

generate the first fragment.generate the first fragment. And requires to a stack of saved And requires to a stack of saved

states (McCool actually walks back, states (McCool actually walks back, expending cycles in the process).expending cycles in the process).

Page 15: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

But performs trivial clip reject at first level But performs trivial clip reject at first level evaluation.evaluation.

Admits early HZ rejection of large triangle Admits early HZ rejection of large triangle regions.regions.

Requires multiple HZ levels.Requires multiple HZ levels. And you could reuse the multiple evaluators And you could reuse the multiple evaluators

of stamp based rasterizer for a faster of stamp based rasterizer for a faster search.search.

Study the cost in hardware and time.Study the cost in hardware and time. To be done?To be done?

Page 16: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizarRasterizar

Page 17: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 18: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 19: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 20: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 21: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 22: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 23: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 24: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Calculate a start point:Calculate a start point: You can actually calculate x/w and y/w and You can actually calculate x/w and y/w and

pick a vertex as start point.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 at least one of the three vertices inside the viewport (w > 0) or viewport (w > 0) or

at least one viewport corner inside the projected at least one viewport corner inside the projected triangle.triangle.

Because the projected triangle should still be Because the projected triangle should still be a convex polygon (or so I hope).a convex polygon (or so I hope).

Page 25: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Page 26: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

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 If any vertex has w > 0 choose a vertex as

start point.start point. If all vertex have w <= 0 evaluate the edge If all vertex have w <= 0 evaluate the edge

equations at the four viewport corners.equations at the four viewport corners. If any corner is inside choose a corner as start If any corner is inside choose a corner as start

point.point.

Page 27: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Pro:Pro: Seems to work ... unless I have Seems to work ... unless I have

missed something.missed something. Cons:Cons:

Traversal algorithm now must take Traversal algorithm now must take into account that it can start into account that it can start anywhere.anywhere.

Increases saved state.Increases saved state.

Page 28: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization Hardware cost:Hardware cost:

3 x tests : w <= 0 (or w > 0)3 x tests : w <= 0 (or w > 0) 3 x 2 x divs : divide by w: x/w, y/w3 x 2 x divs : divide by w: x/w, y/w 3 x 2 comps : for choosing a vertex3 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 muls2 x muls 2 x adds2 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 mux and additional logic for choosing between

vertices or corners.vertices or corners.

Page 29: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Traversal cost for any start Traversal cost for any start point/direction:point/direction: 4 saved states:4 saved states:

3 edge equations3 edge equations– 3 values per edge equation.3 values per edge equation.

Additional edge equations for other Additional edge equations for other parameters?parameters?

– Z/w?Z/w?

Tiled traversal:Tiled traversal: 4 additional tile save states.4 additional tile save states.

Page 30: Status – Week 227 Victor Moya. Summary How to lose a week. How to lose a week. Rasterization. Rasterization

RasterizationRasterization

Evaluators:Evaluators: No stamp:No stamp:

– at least 4 x 3 evaluators (up, down, right, left)at least 4 x 3 evaluators (up, down, right, left)– at least 4 x 3 tests e >= 0.at least 4 x 3 tests e >= 0.

Stamped (NxM):Stamped (NxM):– at least (NxM + 4) x 3 evaluators (NxM at least (NxM + 4) x 3 evaluators (NxM

current, up, down, right, left).current, up, down, right, left).– at least (NxM + 4) x 3 tests e >= 0.at least (NxM + 4) x 3 tests e >= 0.