您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > Real-time Atmospheric Effects in Games
Real-timeAtmosphericEffectsinGamesReal-timeAtmosphericEffectsinGamesCarstenWenzelOverviewOverview•Introduction•Scenedepthbasedrendering•Atmosphericeffectsbreakdown–Skylightrendering–Fogapproaches–Softparticles–Cloudrendering–Volumetriclightningapproximation–Otherinterestingstuff•ConclusionsIntroductionIntroduction•Atmosphericeffectsareimportantcuesofrealismespeciallyinoutdoorscenes•Createasenseofdepth•HelpincreaselevelofimmersionMotivationMotivation•Atmosphericeffectshavealwaysbeensubjecttocoarseapproximationduetotheirinherentmathematicalcomplexity•IncreasedpowerandflexibilityofGPUsallowstoimplementmoresophisticatedmodelsinreal-time•HowtomapthemefficientlyonHW?•CryEngine2showcaseCryEngine2VideoCryEngine2Video*RelatedWorkRelatedWork•DeferredShading(Hargreaves2004)•AtmosphericScattering(Nishitaetal1993)•CloudRendering(Wang2003)SceneDepthBasedRendering:MotivationSceneDepthBasedRendering:Motivation•Manyatmosphericeffectsrequireaccessingscenedepth•HybridrenderingapproachakintoDeferredShading[Hargreaves04]•Canbeusedwithvarietyofrenderingapproaches–DeferredShadingisnotarequirement–CryEngine2usestraditionalrenderingstyle–Simplyapplyscenedepthbasedrenderingforspecificeffects•Approach:–Layoutper-pixelscenedepthfirst–MakeitavailabletofollowingrenderingpassestobeabletoreconstructworldspacepositionDeferredshadinggeneralidea:Noredundantshadingcostbyrenderinggeometryfistandshadelater.Whilerenderinggeometrysaveoutallnecessaryshadingattributestoafatframebuffer(position-depth,normal,diffuse/speccolor,etc.).Atalaterstageapplyshadingusingattributesstoredin“fat”framebuffer.SceneDepthBasedRendering:BenefitsSceneDepthBasedRendering:Benefits•Decouplerenderingofopaquescenegeometryandapplicationofothereffects–Atmosphericeffects–Post-processing–More•Canapplycomplexmodelswhilekeepingtheshadingcostmoderate–Featuresareimplementedinseparateshaders–Helpsavoidinghardwareshaderlimits–AllowsbroaderuseoftheseeffectsbymappingthemtoolderhardwareSceneDepthBasedRendering:ConcernsSceneDepthBasedRendering:Concerns•Troublechild:Alpha-transparentobjects–Theproblem:onlyonecolor/depthvaluestored;however,pixeloverdrawcausedbyalphatransparentobjectspotentiallyunbound–WorkaroundforspecificeffectswillbementionedlaterSceneDepthBasedRendering:APIandHardwareConcernsSceneDepthBasedRendering:APIandHardwareConcerns•UsuallycannotdirectlybindZ-Bufferandreversemap•Writelineareye-spacedepthtotextureinstead•Floatformatvs.RGBA8•SupportingMulti-SampleAnti-AliasingistrickyRecoveringWorldSpacePositionfromDepthRecoveringWorldSpacePositionfromDepth•Manydeferredshadingimplementationstransformapixel’shomogenousclipspacecoordinatebackintoworldspace–3dp4ormul/madinstructions•There’softenasimpler/cheaperway–Forfullscreeneffectshavethedistancefromthecamera’spositiontoitsfourcornerpointsatthefarclippingplaneinterpolated–Scalethepixel’snormalizedlineareyespacedepthbytheinterpolateddistanceandaddthecameraposition(onemadinstruction)SkyLightRenderingSkyLightRendering•MixedCPU/GPUimplementationof[Nishita93]•Goal:Bestqualitypossibleatreasonableruntimecost–Tradinginflexibilityofcameramovement•Assumptionsandconstraints:–Cameraisalwaysontheground–Skyinfinitelyfarawayaroundcamera–Win:Skyupdateisview-independent,updateonlyovertimeSkyLightRendering:CPUSkyLightRendering:CPU•SolveMie/Rayleighin-scatteringintegral–For128x64samplepointsontheskyhemispheresolve…–Usingthecurrenttimeofday,sunlightdirection,Mie/Rayleighscatteringcoefficients–Storetheresultinafloatingpointtexture•Distributecomputationoverseveralframes–Eachupdatetakesseveralsecondstocompute()()()()()()()∫=−−−baacPPPPtPPtHhsveegFKIIλλθλλλ,,0,(1)Pa–Startpointofintegration(inourcontext:viewer)Pb–Endpointofintegration(inourcontext:atmospheretopalongviewdirection)Pc–SunP–PointalongpathPaPbIv(λ)–inscatteredlightalongpathPaPbIs(λ)–sunintensityI(λ)–scatteringcoefficientF(θ,g)–Phasefunctionh–HeightofPovergroundH0–Scaleheightt(s,λ)–OpticaldepthfunctionSkyLightRendering:GPUSkyLightRendering:GPU•Mapthefloattextureontotheskydome•Problem:low-restextureproducesblockyresultsevenwhenfiltered–Solution:MoveapplicationofphasefunctiontoGPU(F(θ,g)inEq.1)–Highfrequencydetails(sunspot)nowcomputedper-pixel•Next-GenGPUsshouldbeabletosolveEq.1viapixelshaderandrendertotexture–Integralisaloopof~200asminstructionsiterating32times–Finalexecution~6400instructionstocomputein-scatteringforeachsamplepointontheskyhemisphereGlobalVolumetricFogGlobalVolumetricFog•Nishita’smodelstilltooexpensivetomodelfog/aerialperspective•Wanttoprovideanatmospheremodel–Toapplyitseffectsonarbitraryobjectsinthescene•Developedasimplermethodtocomputeheight/distancebasedfogwithexponentialfall-offGlobalVolumetricFogGlobalVolumetricFog(2)f–fogdensitydistributionb–globaldensityc–heightfall-offv–viewrayfromcamera(o)totargetpos(o+d),t=1F–fogdensityalongv()()()()()()()()()()()dttvfzcdzyxcoTzzyyxxczTetvFcdedddbedtdtdotdotdofdttvfdtotvbezyxfzzvvvvvvv∫−−−−=−++=+++=+==∫∫1,,,,22210GlobalVolumetricFog:ShaderImplementationGlobalVolumetricFog:ShaderImplementationfloatComputeVolumetricFog(inflo
本文标题:Real-time Atmospheric Effects in Games
链接地址:https://www.777doc.com/doc-3100155 .html