[CS7031] Graphics and Console Hardware and Real-time …and A2 w2 Also interpolate 1 w1 and 1 w2...

Preview:

Citation preview

[CS7031] Graphics and Console Hardwareand Real-time Rendering

15th Lecture :: GPU - Rasterisation (one)Dr. Michael Manzke

michael.manzke@cs.tcd.ie

Trinity College Dublin

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 1/34

Rasterisation orScan Convertion

Outline:

FundamentalsSystem examplesSpecial topics

Suggested reading:

Triangle Scan Conversion Using 2D HomogeneousCoordinates [OG97]Optimal Depth Buffer for Low-cost GraphicHardware [LJ99]Minimum Triangle Seperation for Correct Z-bufferOcclusion [AS06]

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 2/34

Recall that...

Straight lines project to straight lines:

When projection is to a plan (our assumption)Only vertexes need to be transformedThat’s why we’re interested in lines and polygones

Parameterizations(e.g., projected distance) arewarped:

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 3/34

Recall that ...

Ideal screen coordinates are continuous

Implementations always use discrete math, but withsubstantial sub-pixel precisionA pixel is a big thing

Addressable resolution equal to pixels on screenLots of data

Points and lines have no geometric area ...

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 4/34

Terminology

Rasterisation: convertion of primitives to fragments

Primitive: point, line, polygon, glyph, image, ...Fragment: transient data structure, e.g.,

short x, y;

long depth;

short r, g, b, a;

Pixels exist in an array (e.g., framebuffer)

Have implicit < x, y > cooordinates

Fragment are routed to appropriate pixels

This is the "sort" we saw in the previpus lectureThere will be more sorting ...

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 5/34

Two Fundamental Operation

Fragment selection

Identify pixels for which fragment are to begeneratedMust be conservative, efficiency matters< x, y > paratemers are special

Attribute assignment

Assign attribute value to each fragmentE.g., color, depth, ...

Scheduling: the third fundamental operation

Assign fragment to parallel fragment shaders

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 6/34

Fragment Selection

Generate one fragment for each pixel that isintersected by the primitive

Intersect could mean that the primitive’s areaintersects the pixel’s:

Centre point, orSquare region, orFilter-function

Some examples on the following slides:

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 7/34

Point Sampled Fragment Selection

Aliased rasterisation

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 8/34

Box Sampled Fragment Selection

Tiled rasterisation (scaling the primitive doesn’t do this)

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 9/34

Filtered Fragment Selection

Antialiased rasterisation

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 10/34

Fragment Selection (continued)

What if the primitive doesn’t have a geometric area?

Points don’tLines don’t

Two choises

Rule-based approach (e.g., Bresenham line)allow desired propertiies to be maintained, butmay require additional hardware complexity

Assign an screen-scace area (e.g. circle for point,rectangle for line)

can utilize polygon rasterisation algprithm, butmay result in wavy lines, flashing points, etc.

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 11/34

Attribute Assignment

Identify a parameterisation for each attribute

e.g. planar

Sample this parameterisation as required

Which parameterisation?

Lots of possiblities (linear, cuic, . . . )Always define implisitly by vertex values

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 12/34

Attribute Assignment

Properties of vertex-defined parameterisation:

Zero-order continuityIf fully specified by the two vertexes that specifythe edge

Triangle allow planar parameterisationPolygons (4+ edges) are (almost) never planar

Parameterisation may vary with screenorientation

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 13/34

Linear Interpolation

Compute intermediate attribute value

Along a line: A = aA1 + bA2, a + b = 1

On a plan: A = aA1 + bA2 + cA3, a + b + c = 1

Only projected values interpolate linearly in screenspace (straight lines project to straight lines)

a and y are projected (divided by w)Attribute values are not naturally projected

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 14/34

Linear Interpolation

Choice for attribute interpolation in screen space

Interpolate unprojected valuesCheap and easy to do, but gives wrong valuesSometimes OK for color, butNever acceptable for texture coordinates

Do it right

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 15/34

Incorrect Attribute Interpolation

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 16/34

Perspective-correct LinearInterpolation

Only projected values interpolate correctly, so project A

Lineatly interpolate A1

w1

and A2

w2

Also interpolate 1

w1

and 1

w2

These also interpolate linearly in screen space

Divide interpolants at each sample point to recover A

A

w1

w

= A

Division is expensive (more than add or multiply, so)Recover w for the sample point (reciprocate), andMultiply each projected attribute by w

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 17/34

Perspective-correct LinearInterpolation

Barycentric triangle parameterization:

A =

aA1

w1

+bA2

w2

+cA3

w3

a

w1

+b

w2

+c

w3

a + b + c = 1

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 18/34

Example: Gouraud ShadedQuadrilateral

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 19/34

Example: Gouraud ShadedQuadrilateral

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 20/34

All Polygons are Triangles

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 21/34

Normal-based Quad Decomposition

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 22/34

Point Sampled Triangles

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 23/34

Point Sampled Points and Lines

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 24/34

Outline Problem

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 25/34

Integer DDA Arithmetric

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 26/34

Triangle Rasterisation Examples

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 27/34

Algorithm Properties

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 28/34

Gouraud Shaded (GTX)

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 29/34

Engine per Pixel (Pixel Plane 4)

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 30/34

Engine per Pixel (Pixel Plane 4)

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 31/34

Pixel Planes 4 Fragment Selection

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 32/34

References

[OG97] Marc Olano and Trey Greer. Triangle scanconversion using 2d homogeneous coordinates. InHWWS ’97: Proceedings of the ACMSIGGRAPH/EUROGRAPHICS workshop on Graphicshardware, pages 89–95, New York, NY, USA, 1997.ACM.

[LJ99] Eugene Lapidous and Guofang Jiao. Optimaldepth buffer for low-cost graphics hardware. In HWWS’99: Proceedings of the ACMSIGGRAPH/EUROGRAPHICS workshop on Graphicshardware, pages 67–73, New York, NY, USA, 1999.ACM.

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 33/34

References

[AS06] Kurt Akeley and Jonathan Su. Minimumtriangle separation for correct z-buffer occlusion. In GH’06: Proceedings of the 21st ACMSIGGRAPH/Eurographics symposium on Graphicshardware, pages 27–30, New York, NY, USA, 2006.ACM.

Dr. Michael Manzke - CS7031 :: 15th Lecture :: GPU - Rasterisation (one) :: December 20, 2010 – p. 34/34

Recommended