+ All Categories
Home > Documents > Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

Date post: 22-Dec-2015
Category:
View: 216 times
Download: 3 times
Share this document with a friend
Popular Tags:
42
Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007 http://graphics.stanford.edu/courses/cs248-07/
Transcript
Page 1: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

Pre-Filter Antialiasing

Kurt Akeley

CS248 Lecture 4

4 October 2007

http://graphics.stanford.edu/courses/cs248-07/

Page 2: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Review

Page 3: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Aliasing

Aliases are low frequencies in a rendered image that are due to

higher frequencies in the original image.

Page 4: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Jaggies

Original:

Rendered:

Page 5: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Convolution theorem

Let f and g be the transforms of f and g. Then

f g f g* = ×

f g f g× = *

f g f g* = ×

f g f g× = *

Something difficult to do in one domain (e.g., convolution) may be

easy to do in the other (e.g., multiplication)

Page 6: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Aliased sampling of a point (or line)

x

=

*

=

F(s)f(x)

Page 7: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Aliased reconstruction of a point (or line)

x

=

*

=

F(s)f(x)

sinc(x)

Page 8: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Reconstruction error (actually none!)

Original Signal

AliasedReconstruction

Phase matters!

Page 9: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Sampling theory

Fourier theory explains jaggies as aliasing.

For correct reconstruction:

Signal must be band-limited

Sampling must be at or above Nyquist rate

Reconstruction must be done with a sinc function

All of these are difficult or impossible in the general case. Let’s see why …

Page 10: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Why band-limiting is difficult

Band-limiting primitives prior to rendering compromises image assembly in the framebuffer

Band-limiting changes (spreads) geometry Finite spectrum infinite spatial extent

Interferes with occlusion calculations

Leaves visible seams between adjacent triangles

Can’t band-limit the final (framebuffer) image

There is no final image, there are only samples

If the sampling is aliased, there is no recovery

Nyquist-rate sampling requires band-limiting

Page 11: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Why ideal reconstruction is difficult

In theory:

Required sinc function has Negative lobes (displays can’t produce

negative light)

Infinite extent (cannot be implemented)

In practice:

Reconstruction is done by a combination of Physical display characteristics (CRT, LCD, …)

The optics of the human eye

Mathematical reconstruction (as is done, for example, in high-end audio equipment) is not practical at video rates.

Page 12: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Two antialiasing approaches are practiced

Pre-filtering (this lecture)

Band-limit primitives prior to sampling

OpenGL ‘smooth’ antialiasing

Increased sample rate (future lecture)

Multisampling, super-sampling

OpenGL ‘multisample’ antialiasing

Page 13: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-Filter Antialiasing

Page 14: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Ideal point (or line cross section)

x

=

*

=

F(s)f(x)

sinc(x)

sinc(x)

Page 15: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Band-limited unit disk

x

=

*

=

F(s)f(x)

¥ ¥

sinc(x)

sinc(x)

Page 16: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Almost-band-limited unit disk

x

=

*

=

F(s)f(x)

sinc(x)

sinc2(x)

Finite extent!

sinc3(x)

Page 17: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Equivalences

These are equivalent:

Low-pass filtering

Band-limiting

(Ideal) reconstruction

These are equivalent:

Point sampling of band-limited geometry

Weighted area sampling (FvD 3.17.3) of full-spectrum geometry

Page 18: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filter pros and cons

Pros

Almost eliminates aliasing due to undersampling

Allows pre-computation of expensive filters

Great image quality (with important caveats!)

Cons

Can’t handle interactions of primitives with area

Reconstruction is still a problem

Page 19: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filtering in the vertex pipeline

Vertex assembly

Primitive assembly

Rasterization

Fragment operations

Display

Vertex operations

Application

Primitive operations

struct { float x,y,z,w; float r,g,b,a;} vertex;

struct { vertex v0,v1,v2

} triangle;struct { short int x,y; float depth; float r,g,b,a;} fragment;

struct { int depth; byte r,g,b,a;} pixel;

Framebuffer

Point sampling of pre-filtered primitives sets fragment alpha value

Fragments are blended into the frame buffer

Page 20: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filter point rasterization

alpha

point being sampled

at the center of this pixel

Page 21: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filter line rasterization

line being sampled

at the center of this pixel

alpha

Page 22: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filtered primitive stored in table

Supports pre-computation

Simplifies distance calculation (square root in table)

Can compensate for reconstruction errors

Sampling and reconstruction go hand-in-hand

3Point size

4Xscreen frac

bits

4Yscreen frac bits

4Pixel index

8Fragment Alpha

32K x 8

Page 23: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Line tables get big!

5Line slope

4Xscreen frac

bits

4Yscreen frac bits

4Pixel index

81M x 8

3Line width

Fragment Alpha

Page 24: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Triangle pre-filtering is difficult

Three arbitrary vertex locations define a huge parameter space

Resulting table is too large to implement

Edges can be treated independently

But this is a poor approximation near vertexes, where two or three edges affect the filtering

And triangles can be arbitrarily small

Page 25: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Pre-filtering in the vertex pipeline

Vertex assembly

Primitive assembly

Rasterization

Fragment operations

Display

Vertex operations

Application

Primitive operations

struct { float x,y,z,w; float r,g,b,a;} vertex;

struct { vertex v0,v1,v2

} triangle;struct { short int x,y; float depth; float r,g,b,a;} fragment;

struct { int depth; byte r,g,b,a;} pixel;

Framebuffer

Point sampling of pre-filtered primitives sets fragment alpha value

Fragments are blended into the frame buffer

Page 26: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Ideal pre-filtered image assembly

Impulse-defined points and lines have no area

So they don’t occlude each other

So fragments should be summed into pixels

C’pixel = Cpixel + Afrag Cfrag

Page 27: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Practical pre-filtered image assembly

Frame buffers have limited numeric range

So summation causes overflow or clamping

‘Uncorrelated’ clamped blend yields good results But clamping R, G, and B independently causes

color shift

‘Anti-correlated’ clamped blend is an alternative Best for rendering pre-filtered triangles

sorted front-to-back

But requires frame buffer to store alpha values

C’pixel = (1-Afrag)Cpixel + Afrag Cfrag

Page 28: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Anti-correlated blend function

i = min(Afrag, (1-Apixel))

A’pixel = Apixel + I

C’pixel = Cpixel + i Cfrag

Page 29: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Demo

Page 30: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

OpenGL API

glEnable(GL_POINT_SMOOTH);

glEnable(GL_LINE_SMOOTH);

glEnable(GL_POLYGON_SMOOTH);

glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);

glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE); // sum

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // blend

glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); // saturate

Page 31: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Filtering and Human Perception

Page 32: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Resolution of the human eye

Eye’s resolution is not evenly distributed

Foveal resolution is ~20x peripheral

Systems can track direction of view, draw high-resolution inset

Flicker sensitivity is higher in periphery

One eye can compensate for the other

Research at NASA suggests high-resolution dominant display

Human visual system is well engineered …

Page 33: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Imperfect optics - linespread

Ideal Actual

Page 34: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Linespread function

Page 35: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Filtering

x

=

*

=

F(s)f(x)

Page 36: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Frequencies are selectively attenuated

=

*

=

f(x)f(x)

*

Page 37: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Selective attenuation (cont.)

=

*

=

f(x)f(x)

*

Page 38: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Modulation transfer function (MTF)

Page 39: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Optical “imperfections” improve acuity

Image is pre-filtered

Cutoff is approximately 60 cpd

Cutoff is gradual – no ringing

Aliasing is avoided

Foveal cone density is 120 / degree

Cutoff matches retinal Nyquist limit

Vernier acuity is improved

Foveal resolution is 30 arcsec

Vernier acuity is 5-10 arcsec

Linespread blur includes more sensors

Page 40: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Summary

Two approaches to antialiasing are practiced

Pre-filtering (this lecture)

Increased sample rate

Pre-filter antialiasing

Works well for non-area primitives (points, lines)

Works poorly for area primitives (triangles, especially in 3-D)

The human eye is well adapted

Sampling theory helps us here too

Page 41: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

Assignments

Before Thursday’s class, read

FvD 3.1 through 3.14, Rasterization

Project 1:

Continue work

Demos Wednesday 10 October

Page 42: Pre-Filter Antialiasing Kurt Akeley CS248 Lecture 4 4 October 2007

CS248 Lecture 4 Kurt Akeley, Fall 2007

End


Recommended