technische universität münchen fakultät für informatik computer graphics ss 2014 sampling...

40
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Upload: kaliyah-catterall

Post on 01-Apr-2015

217 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Fakultät für Informatik

Computer GraphicsSS 2014

Sampling

Rüdiger WestermannLehrstuhl für Computer Graphik und Visualisierung

Page 2: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

2

Overview

• So far:– Image synthesis

• Ray tracing; models, transformations, shading & lighting, textures, acceleration

• Today– Aliasing and antialiasing techniques

• Prefiltering • Supersampling • Postfiltering• Stochastic and adaptive sampling

Page 3: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

3

Sampling

• Mathematically, point sampling using regularly spaced sample points is the multiplication of the function with a comb function

0 xT 2T

Page 4: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

4

Sampling

• Recall: image synthesis means point sampling of a continuous signal– Image contains samples of a continuous signal at a

discrete set of positions– Pixel spacing determines the frequencies (the size of

details) that can be reconstructed– Undersampling the image (taking too less samples to

allow for the reconstruction of the signal from the samples) causes aliasing artifacts (alias = ghost)

Page 5: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

5

Aliasing

• Original scene and luminosity (brightness) distribution along a scan line

5

Page 6: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

6

Aliasing

• Point sampling the scene at pixel centers

6

Page 7: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

7

Aliasing

• The rendered image

7

Page 8: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

8

Aliasing

• Jagged profiles

8

Page 9: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

9

Aliasing

• Loss of details

9

Page 10: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

10

Aliasing

• Note: the sampling frequency decreases with increasing distance to the viewpoint

d0 d1 d2 d3viewpoint

Page 11: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

11

Aliasing

• With increasing distance to the viewer and slope of the surface, an ever larger surface area falls in-between adjacent rays

Page 12: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

12

Aliasing

• Cause of aliasing– Sampling frequency is not high enough to cover all

details– It is below the Niquist limit

Shannons Sampling Theorem: The signal has to be sampled at a frequency that is equal to or higher than two times the highest frequency in the signal

Page 13: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

13

Aliasing

• Aliasing artefacts– Spatial aliasing

– Temporal aliasing

Page 14: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

14

Antialiasing

• How to avoid aliasing caused by an undersampling of the signal, i.e. the sampling frequency is not high enough to cover all details– Supersampling - increase sampling frequency– Prefiltering - decrease the highest frequency in the

signal, i.e. filter the signal before sampling– Postfiltering – filtering after sampling, but just blurres

the image

Page 15: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

15

Antialiasing

• Supersampling - increase sampling frequency– Use more rays per pixel, i.e. virtually increase the

resolution of the pixel raster– e.g. use 4x4 rays per pixel and compute average of all

16 colors as final pixel color– Sharp edges are washed out– OK, but doesn´t eliminate aliasing because sharp edges

contain infinitely high frequencies

Page 16: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

16

Antialiasing

• Supersampling– Regular supersampling

Page 17: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

17

Antialiasing

• Filtering: average weighted samples

Page 18: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

18

Antialiasing

• Filtering example

Page 19: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

19

Antialiasing

• Filtering - jittered instead of regular sampling

Page 20: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

20

Antialiasing

• Regular sampling– Visibility of aliases also caused by the regular sampling

grid– Human visual system is sensitive against regular

structures, but rather insensitive against high frequency noise

• Stochastic supersampling– Place samples randomly within pixel– Alias frequencies are converted to noise– But can result in clusters of sample

Page 21: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

21

Antialiasing

• Poisson-disk sampling– Random generation of samples with

limit for the minimum distance between samples

• Jittered sampling– Random jittering from regular grid points

• Stratified random sampling– Regular partitioning of pixel region– One random sample per partition

Page 22: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

22

Antialiasing

• Comparison– Regular, 1x1

Regular 3x3

Regular, 7x7

Jittered, 3x3

Jittered, 7x7

22

Page 23: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

23

Antialiasing

• Example:

23

Page 24: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

24

Antialiasing

• Example:

24

Page 25: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

25

Antialiasing

• Example:

25

Page 26: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

26

Antialiasing

• Example:

26

Page 27: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

27

Antialiasing

• Prefiltering – Antialiasing before sampling (mainly used in texture

mapping)• Filtering (smoothing) a signal to remove details below the

frequency which is used to sample the signal

Page 28: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

28

Antialiasing

• Prefiltering combines color contributions into a pixel

Page 29: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• Many texels fall onto one pixels

29

Page 30: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• Mip-Mapping:prefiltered levels of detail (LOD) in a pyramid

• At every level:average 2x2texels from thefiner levelinto one texel30

Page 31: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

31

Page 32: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

32

Page 33: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• Mip-Mapping: how does it work?– When a fragment is texture mapped, the mip-map level

at which the texel size is equal to the pixel size is computed

– From this level the texture is then sampled

– It remains to be answered how the level is computed

33

Page 34: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• We want to know what the size of one texel wrt the size of one pixel is – this allows estimating how many texels fall into one pixel

34

Page 35: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• Computing the mip-map level:Check screen pixel “size” in texture coordinates

35less than one texel per pixelwe call this magnification

more than one texel per pixelwe call this minification

u,v: fragments texture coordinatesx,y: pixel coordinates

Page 36: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

36

Page 37: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

37 without MipMapping with MipMapping

Page 38: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

38Isotropic filtering

(mipmapping)Anisotropic filtering

Page 39: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

Antialiasing in texture mapping

• Mip-Mapping– The mip-map only stores a discrete set of levels – If pixel size matches texel size at a level in between, it

is interpolated between the two adjacent levels

39

Sample 0

Sample 1

interpolateassignSelect

resolution

Bilinear in texture + linear between levels

= trilinear

Page 40: Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung

Technische Universität München

Computer Graphics

40

Summary

• Quality of rendering strongly depends on antialiasing algorithms used– Typically, supersampling in combination with

prefiltering is used• Supersampling and mipmapping

• We are now ready to implement a high quality and efficient ray tracing algorithm

• What comes next is an alternative image synthesis approach based on the projection of geometry onto the image plane