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

1 / 39
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功