# OpenGL Selection and Picking

Software and s/w Development

Dec 13, 2013 (4 years and 5 months ago)

69 views

Antialiasing

What is alias?

Alias

-

A false signal in telecommunication links from
beats between signal frequency and sampling frequency

(from dictionary.com)

Not just telecommunication, alias is everywhere in
computer graphics because rendering is essentially a
sampling process

Examples:

Jagged edges

False texture patterns

Rendering is a sampling process?

Yes indeed.

Image display example

Rendering is a sampling process?

Another example

Render a smooth surface

Ssignal sampling and filtering

Two important steps when information are
represented digitally:
sampling

and
reconstruction

Alias can be caused by any of the steps

Alias caused by under
-
sampling

Have

you ever look
ed

at an electric fan and
found it is rotated in a reverse direction?

Sample at only ¼ of the frequency

Incorrect result is seen !!
-

under
-
sampling

problem

Alias caused by under
-
sampling

1D signal sampling example

Actual signal

Sampled signal

How often is enough?

What is the right sampling frequency?

Sampling theorem (or Nyquist limit)
-

the
sampling frequency has to be at least twice
the
maximum

frequency of the signal to be
sampled

Need two samples in this cycle

www.
microsoft
.ca

Can alias be totally avoided

Given the sampling theorem by Nyquist ?

Not really

this is because the
maximum

frequency might be infinite, i.e., not
bandlimited

Most of

graphics scenes are not bandlimited:
sharp edges can never be completely sampled

in a
discrete manner (point sampling)

We will talk about what we can do to correct
alias for real time graphics

Strobe light on dripping water:
Temporal aliasing

Spokes on a rotating wheel:
Temporal aliasing

Moir
é

patterns:
Spatial aliasing

Examples of Aliasing

Antialiasing Lines

Idea:

Make line “fatter”

Fade line out (removes high frequencies)

Now sample the line

Antialiasing Lines

Solution 1

Unweighted Area Sampling:

Treat line as a single
-
pixel wide rectangle

Color pixels according to the percentage of each
pixel that is “covered” by the rectangle

Solution 1: Unweighted Area Sampling

Pixel area is unit square

Constant weighting function

Pixel color is determined by computing the
amount of the pixel covered by the line, then

Easy to compute, gives reasonable results

Line

One Pixel

Solution 2: Weighted Area Sampling

Treat pixel area as a circle with a radius of one pixel

Use a radially symmetric weighting function
(e.g.,
cone)
:

Areas closer to the pixel center are weighted more heavily

Better results than unweighted, slightly higher cost

Line

One Pixel

Solution 3: Super
-
sampling

Divide pixel up into “sub
-
pixels”:
2

2, 3

3, 4

4, etc.

Sub
-
pixel is colored if inside line

Pixel color is the average of its sub
-
pixel colors

Easy to implement
(in software and hardware)

Expensive

No antialiasing

Antialiasing
(2

2 super
-
sampling)

Different Supersampling Schemes

The common
formula:

c(i,x,y): color of the ith sample
for pixel(x,y)
;
Wi: weight

Different super
-
sampling schemes

Reconstruction

After the (ideal) sampling is done, we still
need to reconstruct back the original
continuous signal

The reconstruction is done by reconstruction
filter

Reconstruction Filters

Common reconstruction filters:

Box filter

Tent filter

Sinc filter = sin(
p
x)/
p
x

Box filter

Very simple, but not very good

Tent Filter

Based on linear interpolation. Better, but still
not smooth

Sinc Filter

Ideal low
-
pass filter

Anti
-
aliased texture mapping

The above anti
-
aliasing methods work better
for removing jagged edges but not texture
aliasing

Magnification

Minification

Re
-
sampling

Minification and Magnification

resample the
signal to a different resolution

Magnification

Minification

(note the minification is done badly here)

Magnification

Simpler to handle, just resample the
reconstructed signal

Reconstructed signal Resample the reconstructed signal

Magnification

Common methods: nearest neighbor (box
filter) or linear interpolation (tent filter)

Nearest neighbor bilinear interpolation

Minification

Harder to handle

The signal’s frequency is too high to avoid
aliasing

A possible solution:

Increase the low pass filter width of the ideal sinc
filter

this effectively blur the image

Blur the image first (using any method), and then
sample it

Minification

Several texels cover one pixel (under
sampling happens)

Under sample artifact

one pixel

Solution:

Either increase
sampling rate or
reduce the
texture
Frequency

We will discuss:

1.
Mip
-
mapping

2.
Rip
-
mapping

3.
Sum Area Table

Mip
-
mapping

By Lance Williams
(SIGGRAPH ’83)

Mip

many things in a
small place

The original texture is
augmented with a set of low
resolution textures

Which resolution to use
depends on the screen
projection size

try to
maintain pixel to texel
ration close to 1

average 2x2

texels

Mipmapping problem

Overblurring!

When a pixel covers many u
texels but few v texels, we always choose the
largest pixel coverage to decide the level

Non mipmapping

mipmapping

Ripmapping

Correct the over
-
blurring problem of
mipmapping

separating x and y filtering

Scale by half by x
across a row.

Scale by half in y
going down a column.

The diagonal has the
equivalent mip
-
map.

Four times the amount
of storage is required.

Four different texel
values to average

?

Summed Area Table

Another way to perform anisotropic filtering
-

can be used to compute the average color for
any arbitrary rectangular region in the texture
space
at a constant speed

A two dimensional array that has the same
size as the texture

Every pixel stores the sum of all the texel colors in the

lower left corner

Summed Area Table (SAT)

How to calculate the sum of texels in the area
between A and B?

R

A

B

C

D

R = SAT[B]

SAT[C]

SAT[D] + SAT[A]

The average value can be computed by

R / num of texels in R

Summed Area Table (SAT)

is used to filter the texture

Compute the rectangular bounding box of the pixel
area in the texture and then

use summed area table to compute the average
color (i.e., filter the texels when

magnification takes place)

pixel

polygon

Texture space

x

y

Summed Area Table

Less blurry than Mipmapping

Still blurry when the texture is viewed along
its diagonal

the bounding box of the pixel area is larger than
the actual pixel area

pixel

polygon

Texture space

x

y

not quit fit

Comparison

Non filtering

Mipmapping

Summed area table

Note that only mipmap is implemented by hardware and supported by OpenGL

Motion Blur

Temporal Antialias

Tricky

Simplest Solution:

supersampling in time

brute force approach

motion blur increases temporal
resolution

Just as pixel antialiasing increases
spatial resolution

If an object moves 16 pixels in one
frame, then 16 supersample images
(or even less) should be adequate