David Luebke1/19/99 CS 551/651: Antialiasing David Luebke [email protected].

28
David Luebke 1/19/99 CS 551/651: CS 551/651: Antialiasing Antialiasing David Luebke David Luebke [email protected] [email protected] http://www.cs.virginia.edu/ http://www.cs.virginia.edu/ ~cs551dl ~cs551dl

Transcript of David Luebke1/19/99 CS 551/651: Antialiasing David Luebke [email protected].

Page 1: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

CS 551/651: CS 551/651: AntialiasingAntialiasing

David LuebkeDavid Luebke

[email protected]@cs.virginia.edu

http://www.cs.virginia.edu/~cs551dlhttp://www.cs.virginia.edu/~cs551dl

Page 2: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

AdministriviaAdministrivia

Hand in Assignment 1Hand in Assignment 1 Assignment 2: upcomingAssignment 2: upcoming

– Sampling strategies in RSRTSampling strategies in RSRT– Due Tuesday March 9Due Tuesday March 9

Page 3: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Recap: Recap: Antialiasing StrategiesAntialiasing Strategies

Prefiltering: low-pass filter the signal Prefiltering: low-pass filter the signal before samplingbefore sampling– Pros: Pros:

Guaranteed to eliminate aliasingGuaranteed to eliminate aliasing Preserves Preserves allall desired frequencies desired frequencies

– Cons: Cons: Expensive Expensive Can introduce “ringing”Can introduce “ringing” Doesn’t fit most rendering algorithmsDoesn’t fit most rendering algorithms

Page 4: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Recap:Recap:Antialiasing StrategiesAntialiasing Strategies

Supersampling: sample at higher Supersampling: sample at higher resolution, then filter downresolution, then filter down– Pros:Pros:

Conceptually simpleConceptually simple Easy to retrofit existing renderersEasy to retrofit existing renderers Works well most of the timeWorks well most of the time

– Cons:Cons: High storage costsHigh storage costs Doesn’t eliminate aliasing, just shifts Nyquist Doesn’t eliminate aliasing, just shifts Nyquist

limit upwardslimit upwards

Page 5: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Recap:Recap:Antialiasing StrategiesAntialiasing Strategies

A-Buffer: approximate prefiltering of A-Buffer: approximate prefiltering of continuous signal by samplingcontinuous signal by sampling– Pros:Pros:

Integrating with scan-line renderer keeps Integrating with scan-line renderer keeps storage costs lowstorage costs low

Can be efficiently implemented with clever Can be efficiently implemented with clever bitwise operationsbitwise operations

– Cons: Cons: Still basically a supersampling approachStill basically a supersampling approach Doesn’t integrate with ray-tracingDoesn’t integrate with ray-tracing

Page 6: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Recap: Recap: Antialiasing StrategiesAntialiasing Strategies

Stochastic supersampling: convert Stochastic supersampling: convert high frequencies into noisehigh frequencies into noise– Pros: Pros:

Retains advantages of supersamplingRetains advantages of supersampling Noise is visually better than aliasingNoise is visually better than aliasing

– Cons:Cons: Harder to retrofit Z-bufferHarder to retrofit Z-buffer Ideal sampling distribution (Poisson Disc) Ideal sampling distribution (Poisson Disc)

is expensiveis expensive

Page 7: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Recap: Recap: Antialiasing ExamplesAntialiasing Examples

See Watt & Watt, p 120See Watt & Watt, p 120 See Foley & van Dam, p 644-645See Foley & van Dam, p 644-645

Page 8: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

We’ve discussed two nonuniform We’ve discussed two nonuniform sampling approachessampling approaches– Adaptive supersampling: Adaptive supersampling:

Sample (say) once per pixel, then supersample if Sample (say) once per pixel, then supersample if intensity changes a lotintensity changes a lot

– Stochastic supersampling:Stochastic supersampling: Use multiple samples per pixel, but not on a Use multiple samples per pixel, but not on a

uniform griduniform grid

Can we filter nonuniform supersampled Can we filter nonuniform supersampled images?images?

Page 9: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Recall: convolution Recall: convolution I’I’ of filter of filter hh with with image function image function II is given by: is given by:

I’I’((x,yx,y)) = = II((ii, , jj) ) hh((xx--ii, , y-jy-j)) Can we use this equation for Can we use this equation for

nonuniform sampling?nonuniform sampling? Implicit in this equation is a Implicit in this equation is a

normalizing factor: we assume the normalizing factor: we assume the filter weights sum to unityfilter weights sum to unity

Page 10: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Pixel

Page 11: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Sampling Grid

Page 12: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Polygon

Page 13: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Adaptive Sampling

Page 14: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Final Samples

Problem:Problem:– Many more red samples Many more red samples

than blue samplesthan blue samples– But final pixel actually more But final pixel actually more

blue than red!blue than red!– Simple filtering will not Simple filtering will not

handle this correctlyhandle this correctly

Page 15: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Approximate answer: Approximate answer: weighted weighted average filteraverage filter – Divide total value of samples X filter Divide total value of samples X filter

by total value of filter at sample points:by total value of filter at sample points: I(i, j) h(x-i, y-j)

h(x-i, y-j)I’(x,y) =

Page 16: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Correct answer: multistage filteringCorrect answer: multistage filtering– Use weighted-average filters in Use weighted-average filters in

cascade, sequentially applying filters cascade, sequentially applying filters with lower and lower cutoff frequencieswith lower and lower cutoff frequencies

– What do such filters look like?What do such filters look like?

Page 17: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Nonuniform Nonuniform SupersamplingSupersampling

Real-world answer: ignore the Real-world answer: ignore the problemproblem– Keep random components small Keep random components small

compared to filter widthcompared to filter width– Use standard supersampling filterUse standard supersampling filter– Cook ‘87 (REYES) uses 4x4 jittered Cook ‘87 (REYES) uses 4x4 jittered

supersamplingsupersampling

Page 18: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing and Antialiasing and Texture MappingTexture Mapping

We may want to apply antialiasing We may want to apply antialiasing techniques to the texture mapping techniques to the texture mapping process separately from the rest of process separately from the rest of the rendering processthe rendering process

Why?Why?

Page 19: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing and Antialiasing and Texture MappingTexture Mapping

Texture mapping is uniquely harderTexture mapping is uniquely harder– Coherent textures present pathological Coherent textures present pathological

artifactsartifacts– Correct filter shape changesCorrect filter shape changes

Texture mapping is uniquely easierTexture mapping is uniquely easier– Textures are known ahead of timeTextures are known ahead of time– They can thus be prefilteredThey can thus be prefiltered

Page 20: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing and Antialiasing and Texture MappingTexture Mapping

More on texture problemsMore on texture problems– Coherent texture frequencies become Coherent texture frequencies become

infinitely high with increasing distanceinfinitely high with increasing distance Ex: checkerboard receding to horizonEx: checkerboard receding to horizon

– Unfiltered textures lead to Unfiltered textures lead to compressioncompression Ex: pixel covers entire checkerboard Ex: pixel covers entire checkerboard Unfiltered mapping: pixel is black or whiteUnfiltered mapping: pixel is black or white Moving checkerboard Moving checkerboard flashing pixels flashing pixels

Page 21: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing and Antialiasing and Texture MappingTexture Mapping

Problem: a square pixel on screen Problem: a square pixel on screen becomes a curvilinear quadrilateral becomes a curvilinear quadrilateral in texture map (see W&W, p 140)in texture map (see W&W, p 140)

The coverage and area of this shape The coverage and area of this shape change as a function of the mappingchange as a function of the mapping

Most texture antialiasing algorithms Most texture antialiasing algorithms approximate this shape somehowapproximate this shape somehow

Page 22: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing and Antialiasing and Texture MappingTexture Mapping

Mip-mappingMip-mapping– MIP = MIP = Multim in Parvo Multim in Parvo (many things in (many things in

a small place)a small place)– Ignores shape change of inverse pixelIgnores shape change of inverse pixel– But allows But allows sizesize to vary to vary

Idea: store texture as a pyramid of Idea: store texture as a pyramid of progressively lower-resolution progressively lower-resolution images, filtered down from originalimages, filtered down from original

Page 23: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing: Mip-MappingAntialiasing: Mip-Mapping

Depth of Mip-Map

Page 24: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

GAntialiasing: Mip MappingAntialiasing: Mip Mapping

RBR G

BR G

BB

GR

Page 25: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing: Mip MappingAntialiasing: Mip Mapping

Distant textures use higher levels of Distant textures use higher levels of the mipmapthe mipmap

Thus, the texture map is prefilteredThus, the texture map is prefiltered Thus, reduced aliasing!Thus, reduced aliasing!

Page 26: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing: Mip MappingAntialiasing: Mip Mapping

WhichWhich level of mip-map to use? level of mip-map to use?– Think of mip-map as 3-D pyramidThink of mip-map as 3-D pyramid– Index into mip-map with 3 coordinates: Index into mip-map with 3 coordinates:

u, v, du, v, d (depth) (depth) Q:Q: What does d correspond to in the What does d correspond to in the

mip-map?mip-map? A: size of the filterA: size of the filter

Page 27: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing: Mip MappingAntialiasing: Mip Mapping

The size of the filter (i.e., The size of the filter (i.e., dd in the in the mip-map) depends on the pixel mip-map) depends on the pixel coverage area in the texture mapcoverage area in the texture map– In general, treat d as a continuous In general, treat d as a continuous

valuevalue– Blend between nearest mip-map level Blend between nearest mip-map level

using linear interpolationusing linear interpolation Q: Q: What is tri-linear interpolation?What is tri-linear interpolation?

Page 28: David Luebke1/19/99 CS 551/651: Antialiasing David Luebke cs551dl@cs.virginia.educs551dl.

David Luebke 1/19/99

Antialiasing: Mip MappingAntialiasing: Mip Mapping

Q: What’s wrong with the mip-map Q: What’s wrong with the mip-map approach to prefiltering texture?approach to prefiltering texture?

A: Assumes pixel maps to square in A: Assumes pixel maps to square in texture spacetexture space

More sophisticated inverse pixel More sophisticated inverse pixel filters (see F&vD p 828):filters (see F&vD p 828):– Summed area tablesSummed area tables– Elliptical weighted average filteringElliptical weighted average filtering