410 likes | 553 Views
Computer Graphics SS 2014 Sampling. Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung. Overview . So far : Image synthesis Ray tracing ; models , transformations , shading & lighting , textures , acceleration Today Aliasing and antialiasing techniques
E N D
Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung
Overview • So far: • Image synthesis • Ray tracing; models, transformations, shading & lighting, textures, acceleration • Today • Aliasing andantialiasingtechniques • Prefiltering • Supersampling • Postfiltering • Stochasticand adaptive sampling
Sampling • Mathematically, point sampling using regularly spaced sample points is the multiplicationof the function with a comb function x 0 T 2T
Sampling • Recall: imagesynthesismeanspointsamplingof a continuoussignal • Image containssamplesof a continuoussignal at a discretesetofpositions • Pixel spacingdeterminesthefrequencies (thesizeofdetails) thatcanbereconstructed • Undersamplingtheimage(takingtoolesssamplestoallow for thereconstructionofthesignalfromthesamples) causesaliasingartifacts (alias = ghost)
Aliasing • Original sceneandluminosity (brightness) distributionalong a scanline
Aliasing • Point sampling the scene at pixel centers
Aliasing • The rendered image
Aliasing • Jaggedprofiles
Aliasing • Loss of details
Aliasing • Note: thesamplingfrequencydecreaseswithincreasingdistancetotheviewpoint d0 d1 d2 d3 viewpoint
Aliasing • Withincreasingdistancetotheviewerandslopeofthesurface, an ever larger surfaceareafalls in-betweenadjacentrays
Aliasing • Causeofaliasing • Sampling frequencyis not highenoughto cover all details • ItisbelowtheNiquistlimit Shannons Sampling Theorem: The signalhastobesampled at a frequencythatisequaltoorhigherthantwotimesthehighestfrequency in thesignal
Aliasing • Aliasing artefacts • Spatialaliasing • Temporal aliasing
Antialiasing • Howtoavoidaliasingcausedby an undersamplingofthesignal, i.e. thesamplingfrequencyis not highenoughto cover all details • Supersampling - increasesamplingfrequency • Prefiltering - decreasethehighestfrequency in thesignal, i.e. filterthesignalbeforesampling • Postfiltering– filtering after sampling, but just blurrestheimage
Antialiasing • Supersampling- increasesamplingfrequency • Usemorerays per pixel, i.e. virtuallyincreasetheresolutionofthepixel raster • e.g. use 4x4 rays per pixel and computeaverageof all 16 colorsas final pixelcolor • Sharp edgesarewashed out • OK, but doesn´teliminatealiasingbecause sharp edgescontaininfinitelyhighfrequencies
Antialiasing • Supersampling • Regular supersampling
Antialiasing • Filtering: average weighted samples
Antialiasing • Filtering example
Antialiasing • Filtering - jitteredinsteadofregularsampling
Antialiasing • Regular sampling • Visibilityofaliasesalso causedbytheregularsamplinggrid • Human visualsystemis sensitive againstregularstructures, but ratherinsensitiveagainsthigh frequencynoise • Stochasticsupersampling • Place samplesrandomlywithinpixel • Alias frequenciesareconvertedtonoise • But canresult in clustersof sample
Antialiasing • Poisson-disksampling • Random generationofsampleswithlimitfortheminimumdistancebetweensamples • Jitteredsampling • Random jitteringfromregulargridpoints • Stratifiedrandomsampling • Regular partitioningofpixelregion • Onerandom sample per partition
Antialiasing • Comparison • Regular, 1x1Regular 3x3Regular, 7x7Jittered, 3x3Jittered, 7x7
Antialiasing • Example:
Antialiasing • Example:
Antialiasing • Example:
Antialiasing • Example:
Antialiasing • Prefiltering • Antialiasing beforesampling (mainlyused in texturemapping) • Filtering (smoothing) a signaltoremovedetailsbelowthefrequencywhichisusedto sample thesignal
Antialiasing • Prefiltering combines color contributions into a pixel
Antialiasing in texturemapping • Manytexels fall ontoonepixels
Antialiasing in texturemapping • Mip-Mapping:prefilteredlevels of detail (LOD) in a pyramid • At every level:average 2x2texels from thefiner levelinto one texel
Antialiasing in texturemapping • Mip-Mapping: howdoesitwork? • When a fragmentistexturemapped, themip-maplevelatwhichthetexelsizeisequaltothepixelsizeiscomputed • Fromthislevelthetextureisthensampled • Itremainstobeansweredhowtheleveliscomputed
Antialiasing in texturemapping • Wewanttoknowwhatthesizeofonetexelwrtthesizeofonepixelis – thisallowsestimatinghowmanytexels fall intoonepixel
Antialiasing in texturemapping • Computing themip-maplevel:Check screen pixel “size” in texture coordinates less than one texel per pixelwe call this magnification more than one texel per pixelwe call this minification u,v: fragmentstexturecoordinates x,y: pixelcoordinates
Antialiasing in texturemapping without MipMapping with MipMapping
Antialiasing in texturemapping Isotropicfiltering (mipmapping) Anisotropicfiltering
Sample 0 assign Select resolution interpolate Sample 1 Antialiasing in texturemapping • Mip-Mapping • The mip-maponlystores a discretesetoflevels • Ifpixelsizematchestexelsizeat a level in between, itisinterpolatedbetweenthetwoadjacentlevels Bilinear in texture + linear betweenlevels = trilinear
Summary • Quality ofrenderingstronglydepends on antialiasingalgorithmsused • Typically, supersampling in combinationwithprefilteringisused • Supersamplingandmipmapping • Wearenowreadytoimplement a highquality and efficientraytracingalgorithm • Whatcomesnextis an alternative imagesynthesisapproachbased on theprojectionofgeometryontotheimage plane