12+ +Sampling+and+Filtering
12+ +Sampling+and+Filtering
Christoph Garth
Scientific Visualization Lab
A Bit of Theory
Throughout the course, we have observed artifacts during rendering, both in ray tracing
and rasterization.
These artifacts result due to the pointwise sampling of the light signal.
Computer Graphics – Sampling & Filtering– A Bit of Theory 12–1
Observe: Image synthesis is a pointwise sampling of a piecewise continuous signal.
• The generated image consists of samples of the light signals at discrete points on a
virtual sensor (pixel raster).
• The inter-pixel distance defines the frequency (amount of the detail) which can be
reconstructed (represented).
• Undersampling of the image – using too few samples – results in aliasing artifacts.
Shannon sampling theorem: A signal with a maximum frequency f must be sampled with
frequency 2f to allow correct reconstruction.
time
original rendered
d0 d1 d2
camera
high frequencies
aliasing
≈ Nyquist frequency
low frequencies
correct reconstruction
• ray tracing: send several rays per pixel and calculate average
• rasterization: virtually increase resolution of pixel raster, then average
Practice:
Weighted sampling is derived from pre-filtering (smoothing) the light signal using a
Gaussian filter.
jittered regular
• The human visual perception is very sensitive for regular structures, but less
sensitive for high frequency noise.
Jittered sampling
• Random shift of samples on a regular grid.
Stratified sampling
• Create random samples per regular sections of the pixel.
regular, 1x1
regular, 3x3
regular, 7x7
jittered, 3x3
jittered, 7x7
There are many postfiltering techniques for real-time rendering: MLAA, SMAA, CSAA, . . . ,
some vendor-specific → Details elsewhere.
Computer Graphics – Sampling & Filtering– Postfiltering 12–22
Prefiltering
Textures are very sensitive to aliasing effects:
• The pre-image of one pixel in screen-coordinates can cover several texels in texture
space (minification).
• Undersampling occurs if only one texel in the pre-image is evaluated.
• Mitigation: multiple samples (expensive) or pre-filtering.
t xs
Pixel
Texel
s ys
...
l=3
Construction of levels: l=2
...
image space
generated during the
rendering, then the level of
detail is calculated such that
texel size corresponds to the
pixel size. The resulting
texture is interpolated at this
texture space
level.
• How to calculate the size of a
texel relative to the pixel
size?
δu δv
δy , δy
δu δv δu δv
d ≈ max , , ,
δx δx δy δy
l = log2 d
δu δv
δx , δx
δu
≈ ux+1,y − ux,y
δx
δu
≈ ux,y+1 − ux,y
δy
u, v: texture coordinates of the fragment
x, y: image pixel coordinates
l < 0 ⇒ less texel per pixel: l > 0 ⇒ more texel per pixel:
magnification minification
Sample 0
assign
Select resolution interpolate
Sample 1
undersampling /
minfication
aliasing
stepping effects
magnification
undersampling /
minfication
aliasing
stepping effects
magnification
undersampling /
minfication
aliasing
stepping effects
magnification
Avoids minification/magnification if
the sample rate is different in u- and
v-direction.
isotropic anisotropic
same level for different levels
x- and y-direction for x- and y-direction
Real-time rendering:
Real-time applications (e.g. games) use a combination of supersampling, prefiltering and
postfiltering, for example typically:
• supersampling
• in combination with mipmapping
(requires ray differentials for screen-space derivatives)