Shadow mapping - Wikipedia

文章推薦指數: 80 %
投票人數:10人

Shadow mapping or shadowing projection is a process by which shadows are added to 3D computer graphics. This concept was introduced by Lance Williams in ... Shadowmapping FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch Methodtodrawshadowsincomputergraphicimages Scenewithshadowmapping Scenewithnoshadows Shadowmappingorshadowingprojectionisaprocessbywhichshadowsareaddedto3Dcomputergraphics.ThisconceptwasintroducedbyLanceWilliamsin1978,inapaperentitled"Castingcurvedshadowsoncurvedsurfaces."[1]Sincethen,ithasbeenusedbothinpre-renderedandrealtimescenesinmanyconsoleandPCgames. Shadowsarecreatedbytestingwhetherapixelisvisiblefromthelightsource,bycomparingthepixeltoaz-buffer[2]ordepthimageofthelightsource'sview,storedintheformofatexture. Contents 1Principleofashadowandashadowmap 2Algorithmoverview 2.1Creatingtheshadowmap 2.2Shadingthescene 2.2.1Lightspacecoordinates 2.2.2Depthmaptest 2.2.3Drawingthescene 3Shadowmapreal-timeimplementations 4Shadowmappingtechniques 4.1Simple 4.2Splitting 4.3Warping 4.4Smoothing 4.5Filtering 4.6SoftShadows 4.7Assorted 5Miscellaneous 6Seealso 7Furtherreading 8References 9Externallinks Principleofashadowandashadowmap[edit] Ifyoulookedoutfromasourceoflight,alloftheobjectsyoucanseewouldappearinlight.Anythingbehindthoseobjects,however,wouldbeinshadow.Thisisthebasicprincipleusedtocreateashadowmap.Thelight'sviewisrendered,storingthedepthofeverysurfaceitsees(theshadowmap).Next,theregularsceneisrenderedcomparingthedepthofeverypointdrawn(asifitwerebeingseenbythelight,ratherthantheeye)tothisdepthmap. Thistechniqueislessaccuratethanshadowvolumes,buttheshadowmapcanbeafasteralternativedependingonhowmuchfilltimeisrequiredforeithertechniqueinaparticularapplicationandthereforemaybemoresuitabletoreal-timeapplications.Inaddition,shadowmapsdonotrequiretheuseofanadditionalstencilbufferandcanbemodifiedtoproduceshadowswithasoftedge.Unlikeshadowvolumes,however,theaccuracyofashadowmapislimitedbyitsresolution. Algorithmoverview[edit] Renderingashadowedsceneinvolvestwomajordrawingsteps.Thefirstproducestheshadowmapitself,andthesecondappliesittothescene.Dependingontheimplementation(andthenumberoflights),thismayrequiretwoormoredrawingpasses. Creatingtheshadowmap[edit] Scenerenderedfromthelightview. Scenefromthelightview,depthmap. Thefirststeprendersthescenefromthelight'spointofview.Forapointlightsource,theviewshouldbeaperspectiveprojectionaswideasitsdesiredangleofeffect(itwillbeasortofsquarespotlight).Fordirectionallight(e.g.,thatfromtheSun),anorthographicprojectionshouldbeused. Fromthisrendering,thedepthbufferisextractedandsaved.Becauseonlythedepthinformationisrelevant,itiscommontoavoidupdatingthecolorbuffersanddisablealllightingandtexturecalculationsforthisrendering,inordertosavedrawingtime.Thisdepthmapisoftenstoredasatextureingraphicsmemory. Thisdepthmapmustbeupdatedanytimetherearechangestoeitherthelightortheobjectsinthescenebutcanbereusedinothersituations,suchasthosewhereonlytheviewingcameramoves.(Iftherearemultiplelights,aseparatedepthmapmustbeusedforeachlight.) Inmanyimplementationsitispracticaltorenderonlyasubsetoftheobjectsinthescenetotheshadowmapinordertosavesomeofthetimeittakestoredrawthemap.Also,adepthoffsetwhichshiftstheobjectsawayfromthelightmaybeappliedtotheshadowmaprenderinginanattempttoresolvestitchingproblemswherethedepthmapvalueisclosetothedepthofasurfacebeingdrawn(i.e.,theshadow-castingsurface)inthenextstep.Alternatively,cullingfrontfacesandonlyrenderingthebackofobjectstotheshadowmapissometimesusedforasimilarresult. Shadingthescene[edit] Thesecondstepistodrawthescenefromtheusualcameraviewpoint,applyingtheshadowmap.Thisprocesshasthreemajorcomponents,thefirstistofindthecoordinatesoftheobjectasseenfromthelight,thesecondisthetestwhichcomparesthatcoordinateagainstthedepthmap,andfinally,onceaccomplished,theobjectmustbedrawneitherinshadoworinlight. Lightspacecoordinates[edit] Visualizationofthedepthmapprojectedontothescene Inordertotestapointagainstthedepthmap,itspositioninthescenecoordinatesmustbetransformedintotheequivalentpositionasseenbythelight.Thisisaccomplishedbyamatrixmultiplication.Thelocationoftheobjectonthescreenisdeterminedbytheusualcoordinatetransformation,butasecondsetofcoordinatesmustbegeneratedtolocatetheobjectinlightspace. Thematrixusedtotransformtheworldcoordinatesintothelight'sviewingcoordinatesisthesameastheoneusedtorendertheshadowmapinthefirststep(underOpenGLthisistheproductofthemodelviewandprojectionmatrices).Thiswillproduceasetofhomogeneouscoordinatesthatneedaperspectivedivision(see3Dprojection)tobecomenormalizeddevicecoordinates,inwhicheachcomponent(x,y,orz)fallsbetween−1and1(ifitisvisiblefromthelightview).Manyimplementations(suchasOpenGLandDirect3D)requireanadditionalscaleandbiasmatrixmultiplicationtomapthose−1to1valuesto0to1,whicharemoreusualcoordinatesfordepthmap(texturemap)lookup.Thisscalingcanbedonebeforetheperspectivedivision,andiseasilyfoldedintotheprevioustransformationcalculationbymultiplyingthatmatrixwiththefollowing: [ 0.5 0 0 0.5 0 0.5 0 0.5 0 0 0.5 0.5 0 0 0 1 ] {\displaystyle{\begin{bmatrix}0.5&0&0&0.5\\0&0.5&0&0.5\\0&0&0.5&0.5\\0&0&0&1\end{bmatrix}}} Ifdonewithashader,orothergraphicshardwareextension,thistransformationisusuallyappliedatthevertexlevel,andthegeneratedvalueisinterpolatedbetweenotherverticesandpassedtothefragmentlevel. Depthmaptest[edit] Depthmaptestfailures. Oncethelight-spacecoordinatesarefound,thexandyvaluesusuallycorrespondtoalocationinthedepthmaptexture,andthezvaluecorrespondstoitsassociateddepth,whichcannowbetestedagainstthedepthmap. Ifthezvalueisgreaterthanthevaluestoredinthedepthmapattheappropriate(x,y)location,theobjectisconsideredtobebehindanoccludingobjectandshouldbemarkedasafailure,tobedrawninshadowbythedrawingprocess.Otherwise,itshouldbedrawnlit. Ifthe(x,y)locationfallsoutsidethedepthmap,theprogrammermusteitherdecidethatthesurfaceshouldbelitorshadowedbydefault(usuallylit). Inashaderimplementation,thistestwouldbedoneatthefragmentlevel.Also,careneedstobetakenwhenselectingthetypeoftexturemapstoragetobeusedbythehardware:ifinterpolationcannotbedone,theshadowwillappeartohaveasharp,jaggededge(aneffectthatcanbereducedwithgreatershadowmapresolution). Itispossibletomodifythedepthmaptesttoproduceshadowswithasoftedgebyusingarangeofvalues(basedontheproximitytotheedgeoftheshadow)ratherthansimplypassorfail. Theshadowmappingtechniquecanalsobemodifiedtodrawatextureontothelitregions,simulatingtheeffectofaprojector.Thepictureabovecaptioned"visualizationofthedepthmapprojectedontothescene"isanexampleofsuchaprocess. Drawingthescene[edit] Finalscene,renderedwithambientshadows. Drawingthescenewithshadowscanbedoneinseveraldifferentways.Ifprogrammableshadersareavailable,thedepthmaptestmaybeperformedbyafragmentshaderwhichsimplydrawstheobjectinshadoworlighteddependingontheresult,drawingthesceneinasinglepass(afteraninitialearlierpasstogeneratetheshadowmap). Ifshadersarenotavailable,performingthedepthmaptestmustusuallybeimplementedbysomehardwareextension(suchasGL_ARB_shadow),whichusuallydonotallowachoicebetweentwolightingmodels(litandshadowed),andnecessitatemorerenderingpasses: Rendertheentiresceneinshadow.Forthemostcommonlightingmodels(seePhongreflectionmodel)thisshouldtechnicallybedoneusingonlytheambientcomponentofthelight,butthisisusuallyadjustedtoalsoincludeadimdiffuselighttopreventcurvedsurfacesfromappearingflatinshadow. Enablethedepthmaptestandrenderthescenelit.Areaswherethedepthmaptestfailswillnotbeoverwrittenandwillremainshadowed. Anadditionalpassmaybeusedforeachadditionallight,usingadditiveblendingtocombinetheireffectwiththelightsalreadydrawn.(Eachofthesepassesrequiresanadditionalpreviouspasstogeneratetheassociatedshadowmap.) TheexamplepicturesinthisarticleusedtheOpenGLextensionGL_ARB_shadow_ambienttoaccomplishtheshadowmapprocessintwopasses. Shadowmapreal-timeimplementations[edit] Oneofthekeydisadvantagesofreal-timeshadowmappingisthatthesizeanddepthoftheshadowmapdeterminethequalityofthefinalshadows.Thisisusuallyvisibleasaliasingorshadowcontinuityglitches.Asimplewaytoovercomethislimitationistoincreasetheshadowmapsize,butduetomemory,computationalorhardwareconstraints,itisnotalwayspossible.Commonlyusedtechniquesforreal-timeshadowmappinghavebeendevelopedtocircumventthislimitation.TheseincludeCascadedShadowMaps,[3]TrapezoidalShadowMaps,[4]LightSpacePerspectiveShadowmaps,[5]orParallel-SplitShadowmaps.[6] Alsonotableisthatgeneratedshadows,evenifaliasingfree,havehardedges,whichisnotalwaysdesirable.Inordertoemulaterealworldsoftshadows,severalsolutionshavebeendeveloped,eitherbydoingseverallookupsontheshadowmap,generatinggeometrymeanttoemulatethesoftedgeorcreatingnonstandarddepthshadowmaps.NotableexamplesofthesearePercentageCloserFiltering,[7]Smoothies,[8]andVarianceShadowmaps.[9] Shadowmappingtechniques[edit] Simple[edit] SSM"Simple" Splitting[edit] PSSM"ParallelSplit"https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html CSM"Cascaded"http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf Warping[edit] LiSPSM"LightSpacePerspective"https://www.cg.tuwien.ac.at/research/vr/lispsm/ TSM"Trapezoid"http://www.comp.nus.edu.sg/~tants/tsm.html PSM"Perspective"http://www-sop.inria.fr/reves/Marc.Stamminger/psm/ CSSM"CameraSpace"http://bib.irb.hr/datoteka/570987.12_CSSM.pdf Smoothing[edit] PCF"PercentageCloserFiltering"https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html Filtering[edit] ESM"Exponential"http://www.cad.zju.edu.cn/home/jqfeng/papers/Exponential%20Soft%20Shadow%20Mapping.pdf CSM"Convolution"https://doclib.uhasselt.be/dspace/bitstream/1942/8040/1/3227.pdf VSM"Variance"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.104.2569&rep=rep1&type=pdf SAVSM"SummedAreaVariance"https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps SMSR"ShadowMapSilhouetteRevectorization"http://bondarev.nl/?p=326 SoftShadows[edit] PCSS"PercentageCloser"http://developer.download.nvidia.com/shaderlibrary/docs/shadow_PCSS.pdf SSSS"Screenspacesoftshadows"http://www.crcnetbase.com/doi/abs/10.1201/b10648-36 FIV"FullsphereIrradianceVector"http://getlab.org/publications/FIV/ Assorted[edit] ASM"Adaptive"http://www.cs.cornell.edu/~kb/publications/ASM.pdf AVSM"AdaptiveVolumetric"https://web.archive.org/web/20101208213624/http://visual-computing.intel-research.net/art/publications/avsm/ CSSM"CameraSpace"http://free-zg.t-com.hr/cssm/ DASM"DeepAdaptive" DPSM"DualParaboloid"http://sites.google.com/site/osmanbrian2/dpsm.pdf DSM"Deep"http://graphics.pixar.com/library/DeepShadows/paper.pdf FSM"Forward"http://www.cs.unc.edu/~zhangh/technotes/shadow/shadow.ps LPSM"Logarithmic"http://gamma.cs.unc.edu/LOGSM/ MDSM"MultipleDepth"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.59.3376&rep=rep1&type=pdf RTW"Rectilinear"http://www.cspaul.com/wiki/doku.php?id=publications:rosen.2012.i3d RMSM"ResolutionMatched"http://www.idav.ucdavis.edu/func/return_pdf?pub_id=919 SDSM"SampleDistribution"https://web.archive.org/web/20101208212121/http://visual-computing.intel-research.net/art/publications/sdsm/ SPPSM"SeparatingPlanePerspective"http://image.diku.dk/projects/media/morten.mikkelsen.07.pdf SSSM"ShadowSilhouette"http://graphics.stanford.edu/papers/silmap/silmap.pdf Miscellaneous[edit] ShadowDepthMaps(SDM)[10] Perspectiveshadowmaps(PSMs) LightSpacePerspectiveShadowMaps(LSPSMs) CascadedShadowMaps(CSMs)[11] VarianceShadowMaps(VSMs)[12] Seealso[edit] Shadowvolume,anothershadowingtechnique Raycasting,aslowertechniqueoftenusedinraytracing Photonmapping,amuchslowertechniquecapableofveryrealisticlighting Radiosity,anotherveryslowbutveryrealistictechnique Furtherreading[edit] SmoothPenumbraTransitionswithShadowMapsWillemH.deBoer Forwardshadowmappingperformstheshadowtestineye-spaceratherthanlight-spacetokeeptextureaccessmoresequential. References[edit] ^ LanceWilliams."Castingcurvedshadowsoncurvedsurfaces"(PDF).Retrieved2020-12-22.{{citejournal}}:Citejournalrequires|journal=(help) ^Akenine-Möller,Tomas;Haines,Eric;Hoffman,Naty(2018-08-06).Real-TimeRendering,FourthEdition.CRCPress.ISBN 978-1-351-81615-1. ^ "Cascadedshadowmaps"(PDF).NVidia.Retrieved2008-02-14{{inconsistentcitations}}{{citejournal}}:Citejournalrequires|journal=(help)CS1maint:postscript(link) ^ TobiasMartin;Tiow-SengTan."Anti-aliasingandContinuitywithTrapezoidalShadowMaps".Retrieved2008-02-14.{{citejournal}}:Citejournalrequires|journal=(help) ^ MichaelWimmer;DanielScherzer;WernerPurgathofer."LightSpacePerspectiveShadowMaps".Retrieved2008-02-14.{{citejournal}}:Citejournalrequires|journal=(help) ^ FanZhang;HanqiuSun;OskariNyman."Parallel-SplitShadowMapsonProgrammableGPUs".GPUGems3.ArchivedfromtheoriginalonJanuary17,2010.Retrieved2008-02-14. ^ "ShadowMapAntialiasing".NVidia.Retrieved2008-02-14. ^ EricChan,FredoDurand,MarcoCorbetta."RenderingFakeSoftShadowswithSmoothies".Retrieved2008-02-14.{{citejournal}}:Citejournalrequires|journal=(help)CS1maint:multiplenames:authorslist(link) ^ WilliamDonnelly;AndrewLauritzen."VarianceShadowMaps".Retrieved2008-02-14. ^"CommonTechniquestoImproveShadowDepthMaps".Msdn.microsoft.com.RetrievedNovember7,2021. ^"CascadedShadowMaps".Msdn.microsoft.com.RetrievedNovember7,2021. ^Donnelly,William;Lauritzen,Andrew(14March2006)."Varianceshadowmaps".AssociationforComputingMachinery.pp. 161–165.doi:10.1145/1111411.1111440.Retrieved7November2021–viaACMDigitalLibrary. Externallinks[edit] HardwareShadowMapping,nVidia ShadowMappingwithToday'sOpenGLHardware,nVidia Riemer'sstep-by-steptutorialimplementingShadowMappingwithHLSLandDirectX ImprovementsforShadowMappingusingGLSL NVIDIAReal-timeShadowAlgorithmsandTechniques ShadowMappingimplementationusingJavaandOpenGL Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Shadow_mapping&oldid=1058038041" Categories:ShadingHiddencategories:CS1errors:missingperiodicalCS1maint:postscriptCS1maint:multiplenames:authorslistArticleswithshortdescriptionShortdescriptionmatchesWikidata Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk English Views ReadEditViewhistory More Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Inotherprojects WikimediaCommons Languages العربيةČeštinaDeutschفارسیItalianoPortuguêsРусский中文 Editlinks



請為這篇文章評分?