/
DeepShadowMapsTomLokovicEricVeachPixarAnimationStudiosWeintroducedeeps DeepShadowMapsTomLokovicEricVeachPixarAnimationStudiosWeintroducedeeps

DeepShadowMapsTomLokovicEricVeachPixarAnimationStudiosWeintroducedeeps - PDF document

tatiana-dople
tatiana-dople . @tatiana-dople
Follow
374 views
Uploaded On 2016-07-31

DeepShadowMapsTomLokovicEricVeachPixarAnimationStudiosWeintroducedeeps - PPT Presentation

emailtdlpixarcomericvpixarcom Figure1Hairrenderedwithandwithoutselfshadowingthroughdensehairandfog ID: 426844

email:tdl@pixar.com ericv@pixar.com Figure1:Hairrenderedwithandwithoutself-shadowing.throughdensehairandfog. : :: :: ::::: :::: : :::: :::: : :::: :::: : :::: :::: : :: : :::: ::::: :: ::::: :::: : ::

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "DeepShadowMapsTomLokovicEricVeachPixarAn..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

DeepShadowMapsTomLokovicEricVeachPixarAnimationStudiosWeintroducedeepshadowmaps,atechniquethatproducesfast,high-qualityshadowsforprimitivessuchashair,fur,andsmoke.Unliketraditionalshadowmaps,whichstoreasingledepthateachpixel,deepshadowmapsstorearepresentationofthefractionalvisibilitythroughapixelatallpossibledepths.Deepshadowmapshaveseveraladvantages.First,theyarepreltered,whichallowsfastershadowlookupsandmuchsmallermemoryfootprintsthanregularshadowmapsofsimilarquality.Second,theysupportshad- email:tdl@pixar.com,ericv@pixar.com Figure1:Hairrenderedwithandwithoutself-shadowing.throughdensehairandfog. : :: :: ::::: :::: : :::: :::: : :::: :::: : :::: :::: : :: : :::: ::::: :: ::::: :::: : :::: :::: : :::: :::: : :::: ::::::: :::: :: :::: ::::::: :::: : :::: ::::: :: ::::: :::: : :::: N Figure2:Variancecontributionstostratiedsampling.Whenasinglesilhouetteedgepassesthroughthelterregion,plescontributetothevariance.Whenthelterregioniscoveredwithnegeometry,allsamplescontributetothevariance,resultinginamuchlargerexpectederror.Whileshadowmapsareverygoodforrenderingshadowsoflargeobjects,theydonotworkaswellfornelydetailedgeom-etrysuchashair.Thisisbecausestratiedsamplingdoesnotworkverywellwhentherearemanydiscontinuitiescrossingthelterre-gion[7].Asaresult,manymoresamplesarerequiredinordertoreducenoiseartifactssuchassparklingtoanacceptablelevel.Tounderstandwhythisisso,considerFigure2a.Hereweshowanisolatedsilhouetteedgecrossingthelterregionforashadowlookup,evaluatedusingsamplesjitteredovera Np grid.Thedepthofeachsampleisobtainedfromtheshadowmap(whoseresolutionmaybemuchnerthanthesamplegrid).Usingper-centagecloserltering,eachsamplecontributeseither0or1totheaverageshadowvaluedependingontherelativevaluesoftheshadowmapandthetestpointInthissituation,observethattheonlysamplesthatcontributetothevariancearetheoneswhosecellsarecrossedbythesilhouetteedge.Thereareonlyofthese,andfurtheranalysis[7]showsthattheexpectederrorinthiscaseis.Thusstrat-icationyieldsmuchbetterresultsnearlargesilhouetteedgesthanunstratiedMonteCarlosampling,whichhasanexpectederrorofInthecaseofhairorfur,however,thelterregioniscrossedbymanysilhouetteedges(seeFigure2b).Inthiscase,everyoneofthecellsiscrossedbyanedge,andthecorrespondingexpectederror.Thusinthecaseofverynegeometry,stratiedsamplingisnobetterthanunstratiedsampling.Theseerrorboundshaveadramaticeffectonthenumberofsam-plesrequiredtoreducenoisebelowagiventhreshold.Forexample,toachieveanexpectederrorof1%,approximately=140plesareneedednearanisolatedsilhouette,while=2500plesarerequirednearapointthatis50%obscuredbydensefur.Furthermore,ifthesameamountofshadowdetailisdesiredinbothcases(i.e.thesameltersizeinworldspace),thentheunderlyingshadowmapresolutionmustbeincreasedbythesamefactor.Togainanybenetfromstratication,theshadowmapwouldneedtobeneenoughtoresolvethesilhouettesofindividualhairs,andthelterregionsmallenoughthatonlyafewedgescrossit.Sincetheseconditionsarerarelysatisedinpractice,shadowmapsforhigh-qualityhairrenderingaretypicallylargeandslow.Webrieymentionsomeotherpossibleshadowtechniques(the Theseestimatesassumethatthesilhouetteedgeishorizontalandhasarandomverticalposition,inwhichcasetheconstantfactorsfortheexpectederrorare respectively.classicsurveyis[13]).Raycastingcangenerateaccurateshadows,butonfurryobjectswithmillionsofhairsitistooexpensiveintermsoftimeandmemory.Thisisparticularlytruewhenhairre-ceivesshadowsfromfogorsmoke,sinceraymarchingisperformedonceforeveryhairsample.Itisalsodifcult,otherthanbyusinganexpensivearealightsource,to“soften”shadowsforartisticpur-poses.Inthecaseofstandardshadowmapsthiscanbeachievedbysimplyincreasingthelterwidth.KajiyaandKayusedray-castshadowsonavolumetrichairrepresentation[2],buttheirrenderingtimeswererelativelylong.Anotherpossibleapproachtohairself-shadowingistoprecom-putetheshadowdensityasa3Dtexture.Thistechniquehasbeenusedwithsomesuccessforclouds(e.g.[3])andforhybridvolumeandsurfacerenderingofmedicaldatasets[5].Themaindrawbackofthisapproachisthat3Dtextureshavearelativelycoarseresolu-tion,andinparticulartheyhavelimitedrangeandlowaccuracyin(whichcreatesbiasproblems).A3Dtexturewithsufcientdetailtocaptureaccuratesurfaceshadowsofcomplexgeometrywouldbeprohibitivelylarge.Multi-layerZ-buffers[6]andlayereddepthimages[10]storein-formationatmultipledepthsperpixel,butaregearedtowardren-deringopaquesurfacesfromnewviewpointsratherthanshadowevaluation.KeatingandMax[4]applymulti-layerdepthimagestotheproblemofshadowpenumbras,buttheirtechniqueotherwisehasthesamelimitationsasordinaryshadowmaps.3DeepShadowMaps3.1DenitionAdeepshadowmapisarectangulararrayofpixelsinwhicheverypixelstoresavisibilityfunction.Intuitively,avisibilityfunctionisdenedbyconsideringabeamoflightthatstartsattheshadowcam-eraoriginandpassesthroughthegivenpixel.Thefunctionvalueatagivendepthissimplythefractionofthebeam'sinitialpowerthatpenetratestothatdepth.Notethatthebeamisnotnecessar-ilysquare;itcanbeshapedandweightedaccordingtoanydesiredpixellter.Figure3givesseveralexamples,showinghowvisibilityfunctionscanaccountforsemitransparentsurfaces,pixelcoverage,andsmoke.Eachvisibilityfunctionstartsoffwithavalueof1,anddecreaseswithdepthasvarioustypesofblockersareencountered.Ifalllightisblocked,thefunctiondropsofftoavalueof0.Tomakethisdenitionmoreprecise,consideraraythatstartsattheshadowcameraoriginandpassesthroughthepointx;ytheimageplane.Somefractionofthelightemittedalongthisraywillbeattenuatedbysurfacesorbyvolumetricscatteringandab-sorption.Thefractionoflightthatpenetratestoagivendepthknownasthetransmittancex;y;z.Werefertoasatrans-mittancefunctionwhenwewishtoconsiderthetransmittanceataxedimagepointx;yasafunctionofThevisibilityfunctionforeachpixelisnowobtainedbylter-ingthenearbytransmittancefunctionsandresamplingatthepixelcenter.Thisiseasiertounderstandifwerestrictourattentiontoaparticulardepth.Thetransmittanceateverypointinthis-planeisgivenbyx;y;z,andthevisibilityfunctionforeachpixelisobtainedbylteringthesevalues:s;t s;j t;zdsdt;where 21 isthepixelcenter,isthedesiredbandlimitingpixellter(centeredaroundtheorigin),andisthelterradius.Thisdenitionissimilartoordinaryimageltering,exceptthatitappliestoeveryvalueseparately.Noticethatvisibilityfunctionsarecloselyrelatedtothealphachannelsusedforimagecompositing.Thealphachannelofanim- Astackofsemitransparentobjects Partialcoveragebyopaqueblockers (c)VolumeattenuationduetosmokeFigure3:Visibilityfunctionsinatland.Eachdiagramshowsabeamoflightthatstartsattheshadowcameraorigin(i.e.thelightsource)andpassesthroughasinglepixelofthedeepshadowmap,accompaniedbythatpixel'svisibilityfunction.Thebeam'spowerisreducedasitpassesthroughconsecutivesemitransparentsurfaces.Theblockersareopaque,buteachcoversonlypartofthepixel'sarea;theemphasizedsegmentsofthefunctioncorrespondtovisibleportionsoftheblockers.Passagethroughsmokereducesthebeam'spowerinamorecontinuousmanner.ageaccountsforattenuationduetobothsemitransparentsurfacesandpartialcoverageofpixels,butisequaltothefractionoflightblockedratherthanthefractionoflighttransmitted.Thealphachannelalsostoresjustasinglevalueperpixel,correspondingtothelightblockedattheplane.Thustherelationshipbe-tweenvisibilityfunctionsandalphachannelscanbeexpressedas:Adeepshadowmapisequivalenttocomputingtheapproximatevalueofatalldepths,andstoringtheresultasafunctionof.Inthiswayeachpixelcontainsthecombinedattenuationandcoverageinformationforeverydepth.3.2SamplingInthissectionwedescribehowdeepshadowmapscanbegeneratedusingthefacilitiesofanystandardrenderer.Ourstrategyissimi-lartoordinaryimagesampling.Togenerateadeepshadowmap,weselectasetofsamplepointsacrosstheshadowcamera'simageplane(forexample,16samplesperpixelonajitteredgrid).Foreachsamplepointwedeterminethecorrespondingtransmittancefunction,whichdescribesthelightfalloffalongaparticularpri-maryray.Finally,thevisibilityfunctionforeachpixeliscomputedbytakingaweightedcombinationofthetransmittancefunctionsatnearbysamplepoints.Werstdescribehowtocomputeasingletransmittancefunc-tion.Givenanimagepointx;y,wecomputethesurfacesandvolumeelementsintersectedbythecorrespondingprimaryray.Thesurfaceintersectionscanbefoundusingeitheraraytraceroranor-dinaryscanconversionrenderer,andweassumethatthepropertiesofvolumetricobjectscanbeevaluatedatanypointsdesired.Thetransmittancefunctionatthepointx;ycanthenbeexpressedastheproductofasurfacetransmittancefunctionandatransmittancefunction,asdescribedbelow.Surfacetransmittanceisestimatedusingallofthesurfacein-tersectionsalongtheprimaryrayatx;y.Eachsurfacehithasadepthvalueandanopacity.Thesearecompositedintheusualway,startingwithatransparencyof1andmultiplyingbyateachsurfacehit,toyieldapiecewiseconstantfunctionFigure4a).Noticethateachsurfacehitgeneratestwoverticeswiththesamevalue,inordertorepresentthediscontinuousstepsasapiecewiselinearcurve.The“vertices”atrepresentedimplicitlyandarenotpartoftheoutput. Thewastedspaceinthisrepresentationisremovedduringthecompres-sionphase,whichapproximatestheaverageofmanydiscretestepswithasinglelinearsegment.Atrue“step”inthecompressedoutputfunctionwouldoccuronlyforasurfaceexactlyparalleltothe (b)(c)(d)tkttsv Figure4:Constructingatransmittancefunction.Theobjectin-tersectionsalongagivenrayyieldthesurfacetransmittancefunction,whichhasadiscontinuityatthedepthofeachsurface.Theex-tinctionfunctionisobtainedbysamplingtheatmosphericdensityatregularintervalsalongtheray.TheextinctionfunctionisintegratedandexponentiatedtoyieldthevolumetransmittanceThesur-facetransmittanceandvolumetransmittancearemultipliedtoobtainthenaltransmittancefunctionforeachray.Toestimatethevolumetransmittance,wesampletheatmo-sphericdensityatregularintervalsalongtheray.Eachvolumesam-plehasadepthvalueandanextinctioncoefcientthatmea-suresthelightfalloffperunitdistancealongtheray.Welinearlyinterpolatebetweenthesesamplestoyieldtheextinctionfunction(seeFigure4b).Thefractionoflightthatpenetratestoagivendepthisthengivenbytheformula)=exp(Sincethisfunctionisnotpiecewiselinear,weapproximateitbyevaluatingthetransmittanceateachvertexoftheextinctionfunc-tionandlinearlyinterpolating.Wedothisbycomputingthetrans-mittanceofeachlinearsegmentas=expandcompositingaswedidforthesurfacetransparencies,exceptthatweinterpolatebetweenverticesratherthanforcingdiscrete Iftheshadowcameraisnotorthographic,acorrectionfactorisneededforeachraytoaccountfortherelationshipbetweendepthanddistance. steps.Thisyieldsthevolumetransmittancefunction(seeFig-ure4c).Wethenmergethesurfaceandvolumecomponentsbymultiplyingthem:(seeFigure4d).Sincethisfunctionisagainnotpiecewiselinear,weevaluateitatthecombinedverticesofandinterpolatelinearlybetweenthem.Finally,wedescribehowthetransmittancefunctionsarecom-binedtoyieldthevisibilityfunctionforanentirepixel.Ateachdepththenearbytransmittancefunctionsarelteredjustlikeordinaryimagesamples:(1)whereisthenumberoftransmittancefunctionswithinthel-terradiusaround 21 ,andisthenormalizedlterweightforeachcorrespondingsamplepoint.Theresultisapiecewiselinearfunctionthathasapproximatelytimesasmanyverticesasthetransmittancefunctionsdo.Thisfunctiontakesintoaccountnotonlythelightattenuationduetosemitransparentsur-facesandfog,butalsothefractionalcoverageofthesefeatures.3.3CompressionVisibilityfunctionssampledinthiswaymayhavealargenumberofvertices,dependingonthelterradiusandthenumberofsamplespershadowpixel.Fortunatelythesefunctionsaregenerallyquitesmooth,makingthemeasilycompressed.Thecompressedfunc-tionsarestoredasanarrayofoating-pointpairs,eachcontainingvalueandafractionalvisibilityItisveryimportantthatthecompressionmethodpreservethevaluesofimportantfeatures,sinceevensmallerrorsincanleadtoundesirableself-shadowingartifacts.Themethodmustalsobeappropriatefortheunboundeddomainn;1).Thesefactsprecludetheuseofcompressionmethodsbasedonaxedorhier-archicalsetofbasisfunctions(e.g.awaveletbasis).Italsoimpliesthattheerrormetricsareunsuitable,sincevisibilityer-rorsareimportanteveniftheyoccuroveraverysmallrangeofvalues.Insteadweusetheerrormetric(maximumerror),andcompressfunctionsusingthesimplegreedyalgorithmdescribedbelow.Givenavisibilityfunctionandanerrortolerance(seeFig-ure5a),ouralgorithmoutputsanewvisibilityfunctionsuchthatforallandwheretypicallyhasamuchsmallernumberofcontrolpoints(Figure5d).Themainfeatureofthealgorithmisthatitisincremen-tal:Itreadsandwritescontrolpointsoneatatimeinincreasingorder,andrequiresonlyaconstantamountofstateinformation.Thebasicideaisthatateachstep,thealgorithmdrawsthelongestpossiblelinesegmentthatstayswithintheerrorbounds(similartohittingaballthroughasmanywicketsaspossibleinagameofcroquet).Theoriginofthecurrentsegmentisxed,andweonlyneedtochoosethedirectionandlengthofthesegment.Tosimplifytheimplementation,werestricttheoutputvaluestobeasubsetoftheinputvalues.Lettheoriginofthecurrentoutputsegmentbe.Ateverystepwemaintaintherangeofpermissibleslopesopesmlo;mhi]forthesegment.Eachnewcontrolpointoftheinputfunctionimposesaconstraintonthecurrentsloperangebyforcingtheseg-menttopassthroughthetargetwindowdenedbythewedgefromthesegmentorigintothetwopoints(seeFigure5b).Thecurrentsloperangeisinitializedtoto�1;1],andisintersected 1010zz 10z 10z Figure5:Ourcompressionalgorithm.Apiecewiselinearcurveandanillustrationofitserrorbound.Eachinputvertexdenesatargetwindowthatconstrainstheslopeofthenextoutputsegment.Thecurrentsloperangeisintersectedwitheachtargetwindowuntilitwouldbecomeempty.Theoutputsegmentisextendedtothecurrentvaluewithaslopeequaltothemidpointofthecurrentsloperange,andthisprocessisrepeated.witheachtargetwindowinsuccessionuntilfurtherprogresswouldmakeitempty(seeFigure5c).Wethenoutputthelinesegmentwithslopeterminatingatthevalueofthelastcontrolpointvisited.Theendpointofthissegmentbecomestheoriginofthenextsegment,andtheentireprocessisrepeated.Notethatthemidpointsloperuleattemptstocentereachsegmentwithintheallowableerrorbounds.Thisalgorithmisfast,simpletoimplement,andrequirescon-stantstorage.Slightlybetterapproximationscouldbeobtainedbydoingaleast-squarestoncethevaluesofthecontrolpointshavebeenchosen.However,thebasicalgorithmsatisesthegivenerrorcriteriaandgeneratesverygoodapproximationsinpractice.3.4LookupsLiketextures,deepshadowsareaccessedbyapplyingareconstruc-tionandresamplingltertoarectangulararrayofpixelvalues.Inourcasethepixelvaluesareobtainedbyevaluatingthevisibilityfunctionsataconstantdepth.Givenapointx;y;zatwhichtoperformthelookupandatwo-dimensionallterkernel,thelteredshadowvalueisgivenbyx;y;z where x;j isthelterweightforpixeli;j,andthesumisoverallpixelswithinthelterradius. Evaluatingeachvisibilityfunctionrequiresasearchthroughitsdatapointstodeterminewhichsegmentcontainsthegivenvalue.Thiscanbedoneusingalinearorbinarysearch,dependingonthenumberofdatapoints.Inourimplementation,wetakeadvantageofthefactthatmanyshadowlookupsareoftendoneatnearbyvaluesbystoringapointerwitheachpixeltothemostrecentlyac-cessedsegment.Oneachlookupwesearchlinearlyeitherforwardorbackwardfromthispositioninordertoreducetheaveragecostofvisibilityfunctionevaluations.4DiscussionOneofthemainadvantagesofdeepshadowsoverregularshadowmapsisthattheysupportpreltering.Eachdeepshadowmappixelsummarizesmanyindividualdepthsamplesinsuchawaythateval-uatingthevisibilityfunctionatagivenvalueisequivalenttoper-centagecloserlteringallofthedepthsampleswithinthepixel'slterradius(towithinthetoleranceusedforcompression).Pre-lteringisimportantbecauseaccurateshadowsrequirelargenum-bersofdepthsamples,aswesawinSection2.Thisisequallytrueforbothordinaryshadowmapsanddeepshadowmaps.Althoughdeepshadowsdonotreducethenumberofdepthsam-plesthatmustbetakenfromthescene,theygreatlyreducetheamountofdatathatmustbeaccessedduringltering.Forexample,recallthatinordertocomputeashadowofdensehairwithanex-pectederrorof1%,approximately=2500samplesareneeded.Usingadeepshadowmapwith250samplesperpixel,wewouldneedtolteronly=10pixelstoachievetherequiredaccuracy.Furthermoredeepshadowscanbemip-mapped(seeSection5.3),andthusaccurateshadowsrequireonlyaconstantnumberofpixelaccessesevenwhenlterwidthsareverylarge.Prelteringnotonlymakesshadowlookupsfaster,butalsoal-lowsdeepshadowstobemuchsmallerthantheequivalenthigh-resolutiondepthmap.Thisisanadvantagewhendeepshadowmapsarewritten,stored,andcachedinmemory.Notethatthead-vantagesofprelteringarecompletelydependentoncompression.Ifwedidnotcompressthevisibilityfunctionsatall,theneachpixelwouldcontainthedatafromalltheunderlyingsamplesandwouldnotbeanysmaller.Fortunately,atanysamplingratethereisanerrortolerancethatallowssignicantcompressionwithoutcompromisingshadowquality.Specically,recallfromSection2thatshadowsofdetailedgeometryhaveanexpectederrorof,whereisthenumberofsamplesperdeepshadowpixel.Thiserrorisameasureofthenoiseinherentinthesampledvisibilityfunction.Sincethereisnopointinpreservingnoise,thissuggeststhatisasuitabletoleranceforcompression.Thetoleranceweactuallyuse ,whichisabouthalfofthemaximumexpectednoisemagnitudeof Usingthistolerance,wecanshowthatdeepshadowsareasymp-toticallymuchsmallerthanregularshadowmaps.Sinceeachvisi-bilityfunctiondecreasesmonotonicallyfrom1to0(assumingthatthelterfunctionhasnonegativelobes),andthefunctiondecreasesbyatleastthecompressiontoleranceateachvertex,thecompressedfunctioncanhaveatmostvertices.Thecorrespondingregularshadowmapusesstorageforthedepthvaluesineachpixel,andsothedeepshadowmapmustbesmallerbyatleastafac-torof Recallthattheexpectederrorisonlywhentheshadowgeometryissimple,whichsuggeststhatacompressiontoleranceofistoolargeinthiscase.Butsincemustbechosenlargeenoughtocontrolthenoiseartifactsintheworst-casepixels,thereislittlebenettocompressingmoreaccuratelythanthis.Thecompressionratiosareevenbetterwhenthevisibilityfunc-tionsareasymptoticallypiecewisesmooth(whichistheusualcase).AsimpleTaylorseriesargumentshowsthatinthiscasethecom-pressionerrordecreasesquadraticallyinthenumberofoutputver-tices,sothatfunctionscanbecompressedwithatoleranceofusingonlyvertices.Thusdeepshadowmapsaretypicallysmallerthantheirregularcounterpartsbyatleastafac-torof.Thisisasubstantialadvantagewhenmanysamplesperpixelareused(say=250Themaindisadvantageofdeepshadowmapsisthattheyaresig-nicantlymoreexpensivetocomputethanaregularshadowmapofthesamepixelresolution(becausemanymoresamplesperpixelaretaken).Thiscontradictstheconventionalassumptionthatshadowmapgenerationischeap[9].Ontheotherhand,theyaretypi-callynomoreexpensivetocomputethanashadowmapwiththesamenumberofdepthsamples,andtheyareconsiderablycheapertostoreandaccess.Notethatgeneratingmoredepthsamplesisrel-ativelyinexpensiveinascanlinerenderer,sinceitdoesnotincreasetheshadingcost.Anotherpotentialissuewithdeepshadowsisbias.Becausel-teringisperformedataconstantdepth,largeobjectsmaysufferfromincorrectself-shadowing.Althoughthisartifactalsooccurswithnormalshadowmaps,deepshadowsexacerbatetheproblembecausetheyencouragetheuseoflargelterwidths.However,itisimportanttorealizethatthebiasproblemsarenoworsethantheywouldbeforanordinaryshadowmapatthesamelterwidth.Themainlimitationofdeepshadowmapscomparedtohigh-resolutionordinaryshadowmapsisthattheminimumlterwidthislarger(becauseeachdeepshadowpixelsummarizesmanydepthsamples).However,thiscanbeconsideredanadvantage:Itprovidesdeepshadowswithanextradegreeoffreedomtocontrolthetradeoffbetweenshadowdetailandnoise.Thedeepshadowresolutionshouldbechosenaccordingtotheminimumlterwidthdesired(i.e.shadowdetail),whilethenumberofsamplesperpixelshouldbedeterminedbythemaximumacceptablenoise.Thisstrat-egyallowsthedepthsamplesthatarerequiredonlyforaccuracypurposestoberepresentedverycompactly,withbiasproblemsthatarenoworsethantheywouldbeforaregularshadowmapofthesamepixelresolution.5ImplementationIssues5.1IncrementalUpdatesRecallthateachvisibilityfunctionisdenedastheweightedav-erageofpiecewiselineartransmittancefunctions,accordingtoequation(1).Thena¨vewaytogeneratethisfunctionistosortalloftheinputverticesandprocesstheminorder,evaluatingthecontributingfunctionsateachvertex.Unfortunatelythisapproachcomplexity:thereareinputvertices,andworkisneededtocomputetheweightedaverageateachone.ThisisquiteinefcientwhenlargenumbersofsamplesperpixelareInstead,wedescribeansweepalgorithmthathasaconstantupdatecostpervertex.Thealgorithmiseasiertounder-standifwerstsupposethatthetransmittancefunctionsarepiece-wiseconstant.Inthiscase,wecanefcientlycomputetheoutputfunctionasfollows.At,theweightedaverageiseasilycom-putedas.Wethenprocessalloftheinputverticesinorder,whichcanbedoneintimepervertexbystoringthenextvertexofeachtransmittancefunctioninaheap.Foreveryvertex,weupdatethecurrentsumbysimplysubtract-ingoutthistransmittancefunction'soldcontributionandaddinginitsnewcontribution.Thatis, whereisthelterweightforthechosentransmittancefunction,istheoldvalueofthisfunctionandisitsnewvalue.Thismethodcanbeextendedtopiecewiselinearfunctionsbyusingasimilartechniquetokeeptrackoftheoutputfunction'scur-rentvalueandslope.Theupdateforeachvertexconsistsoftwosteps:First,weextendtheoutputfunction(usingitscurrentposi-tionandslope)tothevalueofthenextinputvertex,andthenweupdatethecurrentoutputslopeusingthemethoddescribedabove.(Verticalstepsarehandledasaspecialcase,byupdatingthecurrentpositionratherthanthecurrentslope.)Thistechniqueismuchmoreefcientthancomputingtheweightedaveragesdirectly,andmakesthealgorithmpracticalevenwhenverylargenumbersofsamplesperpixelareused.Notethatallofthetransmittancefunctionsdonotneedtobestoredsimul-taneouslyasthedeepshadowmapisrendered;itissufcienttostoreonlythepreviousseveralscanlines,asdeterminedbythelterradius.5.2ColoredShadowsColoredshadowsaresupportedbysimplyencodingadifferentvis-ibilityfunctionforeachcolorchannel(oneeachforred,green,andblue).Thecompressionalgorithmprocessesallthechannelssimul-taneously,andstartsanewsegmentwheneveranyofthethreefunc-tionswouldexceeditserrorthreshold.Theoutputisasequenceoftuplesz;V.Noticethatwiththisrepresentation,three-channelmapsareonlytwiceaslargeasone-channelmaps.Toreducestorageevenfurther,ourformatallowseachpixeltoencodeeitheroneorthreevisibilityfunctionsdependingonitsneeds.Ifallthreechannelshappentobethesame,westoreonlyonechannelandsetaagindicatingthatthispixelismonochrome.5.3Mip-mappingSincedeepshadowmapsarelteredliketextures,itisstraight-forwardtoapplymip-mapping[12].Startingwiththehighest-resolutiondeepshadowmap,eachnewmip-maplevelisobtainedbyaveraginganddownsamplingthepreviouslevelbyafactoroftwo.Eachpixelisdenedbytakingtheaverageoffourvisibilityfunctions,andrecompressingtheresult.Toavoidtheaccumulationoftoomucherror,thecompressiontolerancecanbereducedoneachsuccessivelevel.Forexam-ple,iftheerrorthresholdiscutifhalfeachtime,thetotalerrorwillbeatmosttwicethatpermittedforthehighest-resolutionmap.ThismethodcorrespondstotheanalysisofSection4,whichsug-geststhatthecompressiontoleranceshouldbeinthenumberofcontributingdepthsamples.Thestoragepersampleincreasessomewhatatcoarserlevels,butsincethefunctionsbe-ingcompressedareasymptoticallypiecewisesmooth,theircom-pressedsizeis(seeSection2).Thisimpliesthatthenumberofverticespervisibilityfunctiondoublesonceforeverytwomip-maplevels,andthatthefullmip-mapisapproximately timesaslargeasthebaselevel(ratherthantheratioforanordinarymip-map).Mip-mappeddeepshadowsarelteredjustlikemip-mappedtex-tures,includinganisotropiclters,lerpingbetweenlevels,etc.[1].5.4TilingandCachingWestoredeepshadowmapsinatiledformat,similartothosefortextures[8].Thisletsusloadandcacheonlythedeepshadowmaptilesthatareactuallyaccessed.Oneimportantdifferenceisthatunliketextures,deepshadowmaptilesandpixelsrequirevaryingamountsofstorageinmemory.Todealwiththis,ourleformatincludesatiledirectorythatspeci-esthestartingoffsetandsizeofeverytile.Similarly,eachtilehasatableindicatingthestartingpositionandsizeofeverypixel.Tilecachingishandledbyprovidingaxednumberoftileslots;whenatilefaultoccurs,theslotchosenforreplacementisresizedifnec-essarytoholdtheincomingtile.Inthisway,eachtileslotgrowstoaccommodatethelargesttileithasseen.(Optionallythetileslotscouldalsoberesizedwhentheincomingtileissignicantlysmaller.)5.5MotionBlurItiseasytosupportmotionblurindeepshadowmapsbysimplyassociatingarandomtimewitheveryshadowimagesample(anditscorrespondingtransmittancefunction).Whenthesesamplesareaveragedtogetherintovisibilityfunctions,theyaccountfortheav-eragecoverageovertimeaswellasovertheimageplane.Whilemotionblurisalsopossiblewithordinaryshadowmaps,itisveryexpensivebecauseofthelargelterwidthsneededforadequateanti-aliasing.Deepshadowmapsdomuchofthislteringinadvance,andthusreducethenumberofpixelsthatneedtobeaccessedforeachlookup.Motion-blurredshadowsproducedinthiswayarestrictlycor-rectonlywhenthereceivingobjectisstationarywithrespecttotheshadowcamera.Inparticular,movingobjectscastincorrectshad-owsontoothermovingobjects(andontothemselves).Thishappensbecausethedeepshadowmapeffectivelyblursanobject'sshadowovertheentireshutterinterval,allowingoneobjecttocastshadowsontootherobjectsatadifferenttimes.However,eventheabilitytocastshadowsontostationaryobjectsisuseful,andtheresultsareoftenacceptableevenwhenthereceivingobjectismoving.6ResultsWehaveimplementeddeepshadowmapsinahighlyoptimizedscanlinerendererthatalsosupportstraditionalshadowmaps.Wepresentexperimentscomparingthesetwotechniquesintermsoftimeandstoragespace.Wealsoillustratetwoadditionalcapabili-tiesofdeepshadows:volumetricshadowsandinexpensivemotionblur.Figure6ashowsaballcoveredwith50,000hairs.Theindividualhairsaresignicantlynarrowerthanapixel,andcombinetoformtuftsandcurlsofvariousdensities.Thesceneisilluminatedbythreespotlights,eachofwhichcastsshadows.Wehaverenderedthissceneundervariousconditionstocom-paretheperformanceofdeepshadowmapswithtraditionalshadowmaps.Figure6bshowsamagniedviewoftheshadowcastbythehairball,renderedusinganormalshadowmap.Shadowlteringwasdoneusing16samplesperlookuponajitteredgrid;usingmoresamplesdoesnotincreasetheshadowqualityduetothecoarseresolutionoftheunderlyingshadowmap.Thisimagehasobviousnoiseartifactsthatwouldbeunacceptableifanimated.Inordertoeliminatetheseartifacts,Figure6cwasrenderedusingashadowmapwith400samplesperlookupforpercentagecloserltering.Thenoiseartifactsaremuchimproved,butshadowlteringtimesweremuchlonger(559seconds19seconds).Fig-ure6dwasrenderedusingadeepshadowmapwith256samplesperpixel(thesamenumberofdepthsamplesasthepre-viouscase).Eventhoughthedeepshadowsweremuchfaster(37seconds)andrequiredonlyone-sixththestoragespace,theshadowqualityisactuallyslightlybetterthantheshadowmapim-age(becausedeepshadowsconsidereverydepthsampleratherthanrandomlyselectingasubsetofthemforltering).Figure7summarizestheresultsofsimilartestsatvariousmax-imumnoiselevels.Eachrowcomparesadeepshadowmaptoanormalshadowmapwiththesamenumberofdepthsamples;inthedeepshadowthiswasachievedbyholdingtheresolutionconstantatandadjustingthenumberofsamplesperpixel(asshown Ballwith50,000hairs Normalshadowmap (c)kNormalshadowmap DeepshadowmapFigure6:Hairballandmagniedshadowsdemonstratingnoisefromvariousmethods. Time(sec) Space(MB) Samples Error Normal Deep Normal Deep 2 25.00% 34 45 0.34 0.49 4 12.50% 39 46 1.34 0.79 8 6.25% 60 45 5.34 1.18 16 3.12% 145 46 21.34 1.53 32 1.56% 554 46 85.34 1.84 64 0.78% 2414 45 341.34 2.20 Figure7:ComparisonofdeepshadowsandnormalshadowsforthesceneinFigure6.Theerrorcolumnshowstheexpectederror associatedwiththegivensamplingdensity.intherstcolumn).Thiscolumnalsorepresentsthenumberofsamplesusedfornormalshadowmapltering,chosentoachievethesameaccuracyasthedeepshadowmapatitsminimumltersize.Thesecondcolumnshowsthecorrespondingworst-caseex-pectederrorlevelof ;thedeepshadowswerecompressedusinganerrortoleranceofhalfthisamount.Alltestsusedthesameabsolutelterwidth,equaltothepixelsizeofashadowmap.Theshadowevaluationtimesweremeasuredbyrenderinganimageusingeachtechniqueandsubtractingthetimeforanimagewithoutshadows.Observethatnormalshadowmapsbecomemuchmoreexpen-siveastheerrorthresholddecreases,whilethedeepshadowmaplteringtimesarevirtuallyconstant.Normalshadowmapsareonlyfasteratandfewersamples,samplingratesthataremuchtoolowforuseinanimations.Inourimplementationdeepshadowshavenotbeenasextensivelyoptimizedasnormalshadowmaps,anditislikelythatfurtherspeedimprovementswillbefound.Shadowgenerationtimewassimilarforbothmethodsandisnotshown;thecompressionoverheadfordeepshadowswasnegligible.Noticethatdeepshadowmapsgrowveryslowlyinsizeastheer-rorthresholddecreases.Thedeepshadowsizesdonotincludemip-mapoverhead,whichwouldmakethemapproximately1.5timeslarger(seeSection5.3).Figure8plotsthegrowthofthedeepshadowmapsizewithrespecttothenumberofdepthsamplesperpixel.About40%ofthepixelsinthisdeepshadowmapcontainhair,whiletherestcontainsimplegeometry.Noticethattheaver-agenumberofverticespercompressedvisibilityfunctioncloselymatchesthebehaviorpredictedinSection4.Figure9showshowbothmethodsperformwhenaxedaccu-racyisdesired,butprogressivelylargerlterwidthsareapplied.Inthiscasethenumberofltersamplesfornormalshadowmapscanbeheldxed.Asingleshadowmapofeachtypewasrenderedtosupportthesmallestdesiredltersize,andthesameshadowmapswereusedtorenderprogressivelylargerblurs.Thelteringtime 1000200030004000 510avg. vertices per pixel theoretical Figure8:Theoreticalandobservedgrowthratesofdeepshadowmaps.(ThetheoreticalgrowthrateofistakenfromSection4.) 0.020.040.06 05001000time (seconds) normal Figure9:Filteringtimeasafunctionoflterwidth(expressedasafractionoftheshadowmapsize).Whilebothmethodsaccessaconstantnumberofpixelsperlookup,largerlterwidthsresultinworsecachecoherencefornormalshadowmapsandslightlybettercachecoherencefordeepshadowmaps.forthenormalshadowmapgrowsrapidlywiththeamountofblur,eventhoughthenumberofltersampleswasheldconstantatThiscanbeattributedtoworsecacheperformanceasthelterre-gionspanslargerandlargerportionsoftheshadowmap.Withthedeepshadowmap,ontheotherhand,mip-mappingallowsthelter-ingtimestobevirtuallyconstant.(Intheorythecacheperformanceofdeepshadowsisactuallybetteratverylargelterwidths,sincethelower-resolutionmip-maplevelscontainfewerpixels.)Figure10illustratestheimportanceofself-shadowingtotheap-pearanceofvolumetricobjects,whileFigure11demonstratesthatasingledeepshadowmapcanbeusedforbothvolumetricandsur-faceshadows.Finally,Figure12demonstratestheartifactsthatoc-curwhenshadowsarenotmotionblurred;thiseffectappearsasstrobingwhenanimated.Unlikenormalshadowmaps,deepshad-owsallowmotionblurtobeaddedwithoutincurringanextralter-ingcost. Figure10:Cloudwithandwithoutself-shadowing. Figure11:Acloudwithpipes.Noticetheshadowscastfromsurfacesontovolumetricobjectsandviceversa.Asingledeepshadowmapcontainstheshadowinformationforthecloudaswellasthepipes.7ConclusionandFutureWorkAnicefeatureofdeepshadowmapsistheirgenerality:theysupportordinarysurfaces,volumetricobjects,densefur,andevenmotionblur,effectsthatwouldnormallybehandledusingdifferenttech-niques.Withdeepshadowstheycanallbecombinedinasinglecompactdatastructure,andrenderedefcientlyunderawiderangeofviewingandlteringconditions.Carryingthisideafurther,deepshadowmapsareanattractiverepresentationforarbitraryvolumetricdata:fogdensities,approx-imateilluminationinformation,andsoon.Inthiscontext,adeepshadowmapcanbeviewedasatwo-dimensionalfunctionimagepiecewiselinearone-dimensionalfunctions.Thisrepresentationissparsein,whichallowsittotakeadvantageofanysmoothnessintherawdata,whileitisdiscretein(andallowsbinarysearchin)inordertofacilitatefastlookups.Thedomaincaneasilybemappedtoafrustumoranorthographicspace,andhastheadvantageofhavinganarbitraryextentandresolutioninoneofitsdimensions.Three-dimensionallteringwouldbeaneasyex-tension,sincetheadjacentdatavaluesincanbefoundwithoutsearchingandtherepresentationissparseinthisdirection.Althoughthefunctionimagerepresentationmaynotachievequiteasmuchcompressionasathree-dimensionaloctreeorwaveletexpansion,anditisnotquiteasfasttoindexasathree-dimensionalgrid,itisanexcellentcompromisethatretainsmostofthebenetsofbothoftheseextremes.Weexpectthatdeepshadowmapsandtheirunderlyingrepresentationwillndotherinterestingapplica-tionsinthefuture. Figure12:Rapidlymovingspherewithandwithoutmotionblur.AcknowledgementsThankstoAdamWoodburyformodelingthecloudinFigure10,ChristianHillandBradWinemillerforproductionhelp,andRobCookandMattPharrforvaluablecommentsonearlydraftsofthepaper.References[1]PaulS.Heckbert.Surveyoftexturemapping.IEEEComputerGraphicsandApplications,6(11):56–67,November1986.[2]JamesT.KajiyaandTimothyL.Kay.Renderingfurwiththreedimensionaltextures.InComputerGraphics(SIGGRAPH'89Proceedings),volume23,pages271–280,July1989.[3]JamesT.KajiyaandBrianP.VonHerzen.Raytracingvolumedensities.InComputerGraphics(SIGGRAPH'84Proceed-ings),volume18,pages165–174,July1984.[4]BrettKeatingandNelsonMax.Shadowpenumbrasforcom-plexobjectsbydepth-dependentlteringofmulti-layerdepthimages.InEurographicsRenderingWorkshop1999,pages205–220,NewYork,June1999.Springer-Verlag.[5]MarcLevoy.DisplayofSurfacesfromVolumeData.Ph.D.thesis,UniversityofNorthCarolinaatChapelHill,1989.[6]NelsonMax.Hierarchicalrenderingoftreesfromprecom-putedmulti-layerZ-buffers.InEurographicsRenderingWorkshop1996,pages165–174,NewYork,June1996.[7]DonP.Mitchell.Consequencesofstratiedsamplingingraphics.InSIGGRAPH96Proceedings,pages277–280.Ad-disonWesley,August1996.[8]DarwynR.Peachey.Textureondemand.Unpublishedmanuscript,1990.[9]WilliamT.Reeves,DavidH.Salesin,andRobertL.Cook.Renderingantialiasedshadowswithdepthmaps.InComputerGraphics(SIGGRAPH'87Proceedings),volume21,pages283–291,July1987.[10]JonathanW.Shade,StevenJ.Gortler,Li-weiHe,andRichardSzeliski.Layereddepthimages.InSIGGRAPH98Proceed-ings,pages231–242.AddisonWesley,July1998.[11]LanceWilliams.Castingcurvedshadowsoncurvedsur-faces.ComputerGraphics(SIGGRAPH'78Proceedings)12(3):270–274,August1978.[12]LanceWilliams.Pyramidalparametrics.ComputerGraphics(SIGGRAPH'83Proceedings),17(3):1–11,July1983.[13]AndrewWoo,PierrePoulin,andAlainFournier.Asurveyofshadowalgorithms.IEEEComputerGraphicsandApplica-tions,10(6):13–32,November1990.

Related Contents


Next Show more