Computer Graphics Chapter 1 Introduction to Computer Graphics 1.
Computer Graphics - Electrical Engineering and Computer...
Transcript of Computer Graphics - Electrical Engineering and Computer...
EECS487:InteractiveComputerGraphicsLecture29:• DistributedRayTracing
RayTracing
Introductionandcontext• raycasting
Recursiveraytracing• shadows• reflection• refraction
Raytracingimplementation
DistributedRayTracing• anti-aliasing• motionblur• depth-of-field• glossysurface• translucency• soft-shadows
WhyDoesRayTracingLookObviouslyComputerGenerated?Crispimages...too“perfect”:• surfacesareperfectlyshiny
• glassisperfectlyclear
• everythinginperfectfocus
• everyobjectiscompletelystill
• eventheshadowshaveperfectsilhouettes
• but...upclose,edgesarejagged
Replaceeachsingleraywithadistributionofmultiplerays�a.k.a.distributionraytracing• averageresultstogether
Multiplerayseverywhere:• multipleprimaryraysthroughapixel:• supersampling:distributeraysspatially• motionblur:distributeraystemporally• depthoffield:distributeraysthroughalens
• multipleshadowraystosampleanarealight• softshadows
• multiplereflectionrays• glossysurfaces(blurryreflection,roughspecular)
• multiplerefractionrays• translucency
“Distributed”RayTracing
multiplesecondaryrays
r n
−dl1
t
l2shadow rays
(primary ray)
Supersampling
Insteadofpointsamplingthecolorofapixelwitharay,wecastmultipleraysfromeye(primaryrays)throughdifferentpartsofonepixelandaveragedowntheresults• forexample,castn×nsub-pixelrays,andaveragetheresultstogether:
c pixel =1n2
csubpixel (i, j )j=0
n−1
∑i=0
n−1
∑
Curless08
Non-fixedSamplingPatterns
Super-samplingdoesn’teliminatealiasing,itsimplypushesittohigherfrequencies
• supersamplingcapturesmorehighfrequencies,butfrequenciesabovethesupersamplingratearestillaliased
• fundamentally,problemisthatthesignalisnotbandlimited�aliasinghappens
Otherthanregular,fixedsamplingpattern,samplingcanalsobestochastic(a.k.a.,random,probabilistic,orMonteCarlo)
Durand08
StochasticSupersamplingSamplestakenatnon-uniformlyspacedrandomoffsets
Replaceslow-frequencyaliasingpatternbynoise,whichislessobjectionabletohumans
However,withrandomsampling,wecouldgetunlucky,e.g.,allsamplesinonecorner• over80%ofthesamplesareblackwhilethepixelshouldbelightgrey
onepixel Durand08
uniform
stochastic
StratifiedSamplingTopreventclusteringoftherandomsamples,dividedomain(pixel)intonon-overlappingregions(sub-pixels)calledstrata
Takeonerandomsampleperstratum
Jitteredsamplingisstratifiedsamplingwithper-stratumsampletakenatanoffsetfromthecenterofeachstratum:• onesampleperstratum• randomlyperturbthesamplelocation• sizeofperturbationvectorlimitedbythesubpixeldistance
• patentedbyPixar!
onepixel
Durand
Aliasinghappensintimeaswellasinspace• thesamplingrateistheframerate:
30Hz(NTSC),25Hz(PAL),24Hz(film)• ifwepoint-sampletime,objectshaveajerky,strobbedlook,e.g.,samplingat¼rotation
• ormovebackward,e.g.,sampledat¾rotation
• seehttp://www.michaelbach.de/ot/mot_wagonWheel/index.html• fastmovingobjectsmovelargedistancesbetweenframes• becarefulwhendoingcollisiondetection!
TemporalAliasing:MotionBlur
Curless,Hanrahan
Filmautomaticallydoestemporalanti-aliasing• photographicfilmintegratesovertheexposuretime• thisshowsupasmotionblurinthephotographs
TemporalAliasing:MotionBlur
Hodgins06,Londonetal.
Toavoidtemporalaliasingweneedtoaverageovertimealso
Sampleobjectstemporally• castmultipleraysfromeyethroughthesamepointineachpixel• eachoftheseraysintersectsthesceneatadifferenttime:r(e, d, t)• averageoutresults
Theresultisstill-framemotionblurandsmoothanimation
TemporalAliasing:MotionBlur
Hodgins06,Durand08,Merrell08
t0 t1 t2
DepthofFieldandAperture
Objectisconsideredinfocusifonan8×10printviewedatadistanceof10”,diameterofC ≤ 0.01”(1930’sstandard!)
LaterhumanstudyshowsthatCshouldbe≤ 0.003”
normankoren.com/Tutorials/MTF6.html
Thinlensequation1/s + 1/d = 1/fwherefislensfocallengtha =apertureC = circleofconfusion
object imageplane
f: front;r:rear
depthoffield:distancesforwhich
C ≤ 0.01”
DepthofFieldRealcamerashavelenseswithfocallengths• onlyoneplaneistrulyinfocus• pointsawayfromthefocusprojectas“circleofconfusion”• thefurtherawayfromthefocusthelargerthecircle
Therangeofdistancesthatappearinfocusisthedepthoffield• smallerapertures(largerf-numbers)resultingreaterdepthoffield
Depthoffieldcanbesimulatedbydistributingprimaryraysthroughdifferentpartsofalensassembly
Hart08
Standardraytracing:• allraysemanatefromB• pixelDusesrayBD• pixelE,forobjectbehind(orinfrontof)thefocalplane,usesrayBE
Distributedraytracing:• raysemanatefromlensplane• pixelDusesraysAD, BD, CD• pixelEaveragesraysAE, BE, CE• tosimulatemoreaccurately,firstrefractprimaryraysthroughlens
B
C
D
E
Putimageplaneatfocalplane
Startraysatlensplane
A
DoF:Implementation
Hart08
Orsimplyselecteyepositionsrandomlyfromasquareregion
DoF:Implementation
/Shirley02
GlossySurfacesRaytracingsimulatesperfectspecularreflection,trueonlyforperfectmirrorsandchromesurfacesMostsurfacesareimperfectspecularreflectors:• surfacemicrofacetsperturbdirectionofreflectedrays• reflectraysinaconearoundperfectreflectiondirection• Phongspecularlightingtriestofakethiswiththemshiexponent
RTR,TP3
GlossyReflections:ImplementationForeachray-objectintersection• insteadofshootingonerayintheperfectspecularreflection(mirror)direction,• stochasticallysamplemultiplerayswithintheconeaboutthespecularangle• strengthofreflectiondropsoffrapidlyawayfromthespecularangle,• probabilityofsamplingthatdirectionshouldfalloffsimilarly
perfectmirror θθ
polishedsurface θθ
Hart08,Yu08,Durand08
GlossyReflections
near farobject object
RTR,Curless09,Hart08
Insteadofmirrorimages:• highlightscanbesoft• blurredreflectionsofobjects
Nearbyobjectsreflectmoreclearlybecausedistributionstillnarrow
Fartherobjectsreflectmoreblurrybecausedistributionhasspread
TranslucencySimilar,butforrefraction• insteadofdistributingraysaroundthereflectionray,distributethemaroundtherefractedray
Transparent Translucent
Merrell08,Curless08 Akenine-Möller02
receiver
occluder/caster
self-shadowing:bothoccluderandreceiver
ShadowsDarknesscausedwhenpartoralloftheilluminationfromalightsourceisblockedbyanoccluder(shadowcaster)
shadowshadow
HardandSoftShadowsPointlightsourcesgiveunrealistichardshadows
Lightsourcesthatextendoveranarea(arealightsources)castsoft-edgedshadows• somepointsseeallthelight:fullyilluminated• somepointsseenoneofthelightsource:theumbra• somepointsseepartofthelightsource:thepenumbra
Durand,Chenney
umbra penumbrapenumbra
arealightsource
occluder
pointlightsource
RayTracingAreaLightSourcetoCreateSoftShadowsCastmultipleshadowraysfromsurface,distributedacrossthesurfaceofthelight:eachraytoadifferentpointonthelightsource• insidetheumbra,noshadowraysgetthroughtolight
• insidethepenumbra,someshadowraysgetthroughandsomepartsofthearelightisvisible
• outsidethepenumbra,allshadowraysgetthrough
Chenney
outsidethepenumbra
insideumbra
inthepenumbra
shadowrays
RayTracingAreaLightSourcetoCreateSoftShadowsAteachpoint,sumthecontributionsofshadowraysfromthatpointtofindthestrengthofshadow:hits/rays=%illuminated
Durand20%illuminated
SamplingAreaLightAnti-aliasing:• breakapixelintoagridofsub-pixelsanddistributeraysoverthesub-pixels
Soft-shadows:• breakanarealightintoagridofN = n×npointlights,eachwith1/N-ththeintensityofthebaselight• samplethelight,notthepixel• eachprimaryraygeneratesmultipleshadowraysperlight
Shirley02
ClassicRecursiveRayTracing
trace(ray) { (point, normal) = ray.intersect(scene); return shade(point, normal) }
shade(pt, normal) { color = 0 for each light source { if(!intersect(shadow_ray, scene)) color += direct_illumination } if(specular) color += F * trace(reflected_ray) // also add transmitted color… return color }
render() { for each pixel { generate primary/viewing ray pixel_color = trace(primary_ray) } }
DistributedArea-LightSampling trace(ray) {
(point, normal) = ray.intersect(scene); return shade(point, normal) }
shade(pt, normal) { color = 0 for each light source {
generate N random shadow rays foreach (shadow ray) {
if(!intersect(shadow_ray, scene)) color += direct_illumination*1/N
} } if(specular) color += F * trace(reflected_ray) // also add transmitted color… return color }
render() { for each pixel { generate primary/viewing ray pixel_color = trace(primary_ray) } }
supersampledraytracing:oneshadowraypereyeraycentered
distributedraytracing:16shadowrayspereyerayuniform
Pharr
SampleDistribution?Uniformdistributiongivesrisetosharptransitions/patternsinsidepenumbra4eyeraysperpixelinbothcases:
StochasticSamplingofAreaLight
Arealightrepresentedasarectanglein3D,eachray-objectintersectionsamplesthearea-lightatrandom:r = c + ξ1a + ξ2 b,where ξ1andξ2arerandomvariablesStratifiedsamplingofthearealightwithsamplesspaceduniformlyplusasmallperturbation{ r(i, j), 0 ≤ i, j ≤ n−1 }
Shirley
a
bc
r(0, 0)
r(3, 3)
arealight
stochasticraytracing:4eyeraysperpixeloneshadowraypereyerayrandom
distributedraytracing:4 eye rays per pixel�16shadowrayspereyerayjitteredPharr
SamplingRate
Aswithstochasticsuper-samplingforanti-aliasing,lightsamplingratemustbehigh,otherwisehigh-frequencynoisebecomesvisible