Title: CSE 681 Supersampling
1CSE 681Supersampling
2Aliasing Recap
Fourier Transform
samplinggrid
(multiplication)
(convolution)
Fourier Transform
sampledsignal
3Aliasing Recap
- Aliasing due to
- Sampling
- The sampling process introduces frequencies out
to infinity - We have lost the function f (x) and now only have
discrete samples - Overlap in the frequency domain the higher
frequencies for the copy at 1/T intermix with the
low frequencies centered at the origin - Reconstruction
- Convolution in the spatial domain is the same as
multiplication in the frequency domain
No aliasing
Aliasing
4Anti-aliasing
- Sampling Increase sampling frequency
- Improves results at a computational cost
- Doesnt solve the problem in most cases
- Reconstruction Better filter with larger
neighborhoods - Improves results at a computational cost
- Bad filters are most cost effective but just
blur bad results
5Anti-aliasing Supersampling
- OK, we decide to pay the computational cost
- Just add more samples initiate more rays per
pixel - Reconstruction becomes more expensive also
which filter?
Idea
6Supersample and Reconstruct
- Subdivide the pixel into a grid of subpixels and
define new subpixel centers - Weight each sample according to your
reconstruction filter - The box filter will weight each sample equally
according to the size of the neighborhood - What about a tent filter or truncated gaussian?
filter weight
sample color
pixel
7Anti-aliasing Supersampling
Jaggies
Anti-aliasing
8Supersampling Schemes
- There are many ways to subdivide a pixel
9Full Scene Anti-Aliasing(FSAA)Hardware Supported
AA
- Borrowed from Answers.com
10Quincunx Multisampling
- Wikipedia definition
- A quincunx is the arrangement of five units in
the pattern corresponding to the five-spot on
dice, playing cards, or dominoes. The quincunx is
named after the Roman coin of the same name. - Uses
- A quincunx was the standard tactical formation
for elements of a Roman legion. - A quincunx is a standard pattern for planting an
orchard, especially in France. - Quincunxes are used in modern computer graphics
as a sampling pattern for anti-aliasing. - The spots on 5th side of a dice form a quincunx.
- In astrology (and less commonly in astronomy), a
quincunx is an angle of five-twelfths of a
circle, or 150, between two objects (the Sun,
Moon or planets). - The points on each face of a unit cell of a
face-centred cubic lattice form a quincunx. - A quincuncial map is a conformal map projection
that maps the poles of the sphere to the centre
and four corners of a square, thus forming a
quincunx.
11Quincunx Hardware Supported AA
- Define only two samples/pixel
- reconstruct with five samples
12Quincunx Hardware Supported AA
- Quality comparable to 4xFSAA (full scene) at half
the cost!
4X FSAA
4X Quincunx
13Adaptive Supersampling
- Observation Aliasing is worse where the function
has higher frequencies - Idea Target our supersampling. Only do it when
we need to!
14Adaptive Supersampling
- A Recursive Algorithm
- Sample Phase (Top-Down)
- Trace rays at the pixel corners (initial area)
- Trace ray at pixel center
- If center is different from corners
- Subdivide into 4 sub-pixels
- Recurse on the sub-pixels
- Reconstruction Phase (Bottom-Up)
- Pixel color is ¼ of each quadrant
- Each subpixel (quadrant) is average of higher
level center point and opposite corner point - Collect colors from the bottom up
15Adaptive Supersampling
- Only do extra work when we think we need it
- For example, additional rays are traced along
edges
Needs more samples
Andrew Zaferakis - http//www.cs.unc.edu/andrewz/
comp238/hw2/index.html
16Stochastic Sampling A Monte-Carlo Approach
- Monte-Carlo method any method that uses random
numbers - Random number generators on the computer must use
an algorithm and thus can only give us
pseudo-random numbers - Unix has generators such as rand, random,
drand48 - Go look them up using man pages
- A seed value will determine a specific sequence
of random values
17A Modelling ExampleFractal Mountains
- Fractals represent controlled randomness to
produce natural looking behavior Random height
field
18A Monte-Carlo Method to Approximate p
- Take a unit circle (centered at the origin) and a
bounding box (square with side length 2) - Acircle p
- Asquare 4
- Take a point (x, y) inside the square
- The probability ((x, y) -1 x 1 and -1 y
1 is inside the circle) chance the point
will be inside the circle
outside
inside
For example, what is the chance of a heads if you
flip a coin?
19A Monte-Carlo Method to Approximate p
- OK, lets flip a coin
- Consider the following procedure
- Initialize Ncircle 0 and Nsquare 0
- Choose a random point (x, y)
- If (x, y) is inside the circle then increment
Ncircle - Increment Nsquare
- Repeat
Run this N times
20A Monte-Carlo Method to Approximate p
- The probability a random point is inside the unit
circle - Choose N random points and let M Ncircle
- Approximate p
As N Þ a better approximation
21Estimate p Using Monte-Carlo
- Results
- N 10,000 p 3.1388
- N 100,000 p 3.1452
- N 1,000,000 p 3.14164
- N 10,000,000 p 3.1422784
-
22Choosing Random Numbers
- Does it matter how the N random numbers are
chosen? - Choose random numbers evenly across the space
p 4
p 4
p 0
23Estimate p Using Monte-Carlo
- double x, y, pi
- const int m_nMaxSamples 100000000
- int count 0
- for (int k 0 k lt m_nMaxSamples k)
- x 2.0 drand48() 1.0 // Map to the range
-1,1 - y 2.0 drand48() 1.0
- if (xx yy lt 1.0) count
-
- pi 4.0 (double) count / (double)m_nMaxSamples
24Stochastic Sampling
- OK, back to our story supersampling
- Observation Throwing more and more samples at
problem areas (very high frequencies) seems like
a losing battle - We are just blurring our results anyway when we
reconstruct - Idea Reduce aliasing with noise
- Our visual system likes to enhance regular
patterns - Our eyes are less sensitive to non-ordered
sampling patterns - If it is going to look noisy anyway, lets just
make it better looking noise
25Stochastic Sampling
- We cannot get rid of the noisy look so convert
it to noise with the correct average intensity
Basic checkerboard
Checkerboard with noise
26Stochastic Sampling
- Simple as choosing sample locations in a pixel
randomly . . . right? - What can go wrong?
- Clustering
27Spatial Jittering
- Jittering Apply a noisy offset to pre-determined
sample locations
28Jittering A Regular Grid
- Use pixel subdivision followed by jittering
29Reconstruction
- How do we reconstruct the function with
irregularly spaced samples? - Box filter (easy)
- Average all the contributions with equal weight
within the pixel region - Non-uniform weighted filters (more work)
- Weight each sample according to its distance from
the area center - Sum the weighted samples and normalize by
dividing by the number of filter values
30Effects of Spatial Jittering
- High frequencies are converted to noise instead
of incorrect patterns - High frequencies are attenuated
- The intensity of the resulting noise is
proportional to the lost energy
31Stochastic Sampling Hardware Supported
- ATI - SMOOTHVISIONä
- Jittered sampling pattern
- Each pixel has (2x, 4x, 8x) pre-programmed
jittered sampling locations
Possible pixel sample locations for
the SMOOTHVISION 4x setting
32Quick Comparison
2x SmoothVision
Quincunx
Borrowed from http//www.anandtech.com
33Poisson DistributionNon-Uniform Stochastic
Sampling
- A stochastic sampling such that there is a
minimum distance between neighboring samples - I.e., any two samples are separated by at least a
distance e - Avoids clustering
- Similar to the distribution of vision receptors
in your eye - This is the ideal stochastic sampling to use, but
not easy to define