Considerations for RealWorld Applications with GPUl论文翻译.docx
《Considerations for RealWorld Applications with GPUl论文翻译.docx》由会员分享,可在线阅读,更多相关《Considerations for RealWorld Applications with GPUl论文翻译.docx(14页珍藏版)》请在冰豆网上搜索。
ConsiderationsforRealWorldApplicationswithGPUl论文翻译
ConsiderationsforReal-WorldApplicationswithGPU
LevelofDetail
Inanideal3Dscene,allpolygonswouldshowupataboutthesamesizeonthescreen.Inpractice,though,thisrarelyhappens.Theterraintechniquepresentedsofarhascreatedatessellationthatissomewhatuniforminworldspace,butdefinitelynotuniforminscreenspace.Asaresult,distantpolygonsappearverytiny(onepixelorlessinsize),whichiswasteful,andintroducesaliasingartifacts.Toalleviatethisproblem,we'dliketodivideblocksintothreegroups:
close,medium,andfar.Blocksatcloserangewillhavepolygonsataregularsize,andblocksatamediumdistancewillhavelargerpolygons(inworldspace).Finally,blocksatafardistancewillhavethelargestpolygons.Toimplementthisapproach,wecanchoosefromtwobasicschemes:
oneinwhichlower-level-of-detail(LOD)blockshavefewerpolygonsinthem,andanotherwherelower-LODblockssimplyrepresentalargerspace.
Inthe"fewerpolygons"scheme,allblocksremainat1x1x1inworldspace,butfarawayblockshaveasmallerinternalgridsize(163or83insteadof323).Unfortunately,thisschemecausesthenumberofblockstobloatveryquickly,whichrapidlydecreasesperformance—forboththerenderingand,especially,thegenerationofblocks.
The"biggerblocks"schemeisabetterapproach.Here,allblockshaveaconstant323internalgridsize,buttheworld-spacesizeoftheterrainthattheblocksrepresentchanges,basedontheirdistancefromtheviewer.Nearbyblockswilloccupyacubethatis1x1x1inworldspace,whilelargerblocks(forterrainthatisfartheraway)willcovera2x2x2cubeinworldspaceandsomeevenlargercubes(4x4x4)outtoagreatdistance.Atdrawtime,wedrawthelarge(faraway)blocksfirst,thenthemediumblocks,thenthefineblocks(1x1x1)overtop.Becausethenumberofblocksremainsmanageable,thisisthepreferredscheme.
AswithmanyLODschemes,however,switchingasectionofterrainfromoneLODtoanothercreatesasudden,visualpoppingartifact.TheeasiestwaytodealwiththisproblemistodrawbothLODsduringthetransitionperiod.DrawthelowLODfirstandslowlyalpha-fadethehigher-LODblockin,orout,oversomeshortperiodoftime.However,thisworkswellonlyifthez-buffer(depth)valuesateverypixelareconsistentlycloserforthehigher-LODblock;otherwisethehigher-LODblockwon'talpha-blendoverthelower-LODblock.
Therefore,somesmallamountofnegativebiasonthez(depth)valueshouldbeusedinthevertexshaderwhenwe'redrawinghigher-LODblocks.Evenbetter,wecangeneratethelower-LODblocksbyusingasmallnegativebiasinthedensityfunction.Thisapproachisotropically"erodes"theblocksandissimilartoshrinkingthesurfacealongitssurfacenormals(butbetter,becauseitdoesnotresultinanypinchpoints).Asaresult,thehigher-LODchunkswillusuallyencasethelower-LODchunks,andwillnothavez-fightingproblemswhenalphablendingoverthetopofthem.
Collisions
Inaninteractiveorgameenvironment,manymovableobjects—suchasinsects,birds,characters'feet,andsoon—mustbeabletodetect,andrespondto,collisionswiththeterrain."Intelligent"flyingcreaturesmightneedtocastraysoutaheadoftime(asthedragonfliesdointhe"Cascades"demo)inordertosteerclearofterrainfeatures.Andsurface-crawlingobjects—suchasgrowingvines(ahiddenfeatureinthe"Cascades"demo),spiders,orflowingwater—muststicktotheterrainsurfaceastheymovearound.Thrownorlaunchedobjectsalsoneedtoknowwhentheyhittheterrain,sothattheycanstopmoving(suchasaspearhittingtheground),bouncing(asinasoccerball),ortriggeringsomekindofevent.
Theseobject-terraininteractionsareeasytocomputeiftheobject'smotionisprimarilydrivenbytheGPUfromwithinashader.It'seasiesttodothiscomputationusingageometryshader,whereasmallbuffercontainingasingleelement(vertex)foreachmovingobjectisrunthroughthegeometryshaderforeachframe.Inorderforthegeometryshadertoknowabouttheterrain,thedensityfunctionmustbeplacedinaseparatefilethatcanbeincluded(via#include)byothershaders.Thegeometryshadercanthenincludethefileandusethefunction,queryingitwhenneeded,totestifapointinspaceisinsideoroutsideoftheterrain.
Forexample,ifasoccerballweresailingtowardtheterrain,thegeometryshadercouldtestthedensityfunctionatthepreviousframe'spositionandatthenewframe'sposition.Iftheballwaspreviouslyintheairbutthenewpositionwouldbeinsidetheterrain,thentheexactlocationwheretheballfirsthitthesurfacecouldbedeterminedbyaninterpolationofthedensityvaluetofindwhereitwouldequalzero.Orwecoulduseaniterativerefinementtechnique,suchasintervalhalving.Oncewefindtheexactpointofcollision,wecancomputethegradientatthatpoint(viasixmoresamples).Finally,knowingthevelocityoftheballandthenormaloftheterrain,wecancomputethebouncedirection,andthenwecanoutputthepropernewpositionandvelocityoftheball.
Lighting
Ifthesoccerballofthepreviousexamplefallsintoacave,theviewerwillexpectittolookdarkerbecauseofthegeneralocclusionofambientlightthatishappeninginsidethecave(assumingit'snotamagical,light-producingsoccerball).Fortunately,thisiseasilyaccomplishedbycastingambientocclusionraysoutfromthecenteroftheobjectforeachframe(iftheobjectismoving),justliketheraycastingwhenwegenerateasingleterrainvertex.
Theonlydifferenceisthatherethedensityfunctionmustbeusedinsteadofthedensityvolume,becausethedensityvolumedataforthisblockislikelylonggone.Usingthedensityfunctionismuchslower,butiftheseocclusionraysarecastforonlyafewdozenmoving,visibleobjectsperframe,theimpactisnotnoticeable.
GPU技术对实际应用的考虑
在理想的三维场景中,所有的多边形会在屏幕中以大致相同的大小显示。
实际上,这种情况极少发生。
目前,我们提到的地形技术所创建的细节在世界空间中是均匀的,但显然在屏幕空间中并非如此。
在屏幕中,远处的多边形显得很小(一个或小于一个像素),这是一种浪费,并且会产生走样失真。
要解决这种问题,我们可以将块分为三组:
近处、中间和远处。
近处的地形将拥有正常大小的多边形,中间距离的块有较大的多边形(在世界坐标系中)。
最后,远处的块包含最大的多边形。
要实现这种方法,我们有两种方案供选择:
一种是低细节层次的块包含较少的多边形:
另一种是低细节层次的块表示一个更大的空间。
在“较少多边形”方案中,所有的块在世界空间里保持1×1×1的大小,但远处的块有更小的内部网格尺寸(用163或83来代替323)。
遗憾的是,这个方案会导致块的数目迅速膨胀,从而迅速地降低了渲染以及生成地形块的性能。
“更大地形块”方案是个更好的解决方法。
在这种方案中,所有的块有不变的323内部网格尺寸,但块所表示的地形在世界空间的尺寸则会基于它们距视点的距离而变化。
近处的块会占据世界空间中1×1×1大小的立方空间,而更大的块(对应于远处的地形)会占据世界空间中2×2×2的立方空间,最远距离的块则占据的空间更大(4×4×4)。
在绘制时,我们首先绘制(较远的)大块,然后绘制中等距离的块,最后则绘制最小的块。
由于块的数目保持为可控状态,因此这是个更好的方案。
然而,对于许多LOD方案来说,从一个LOD切换到另一个地形区域会产生突然地、视觉上的跳动失真。
最简单的解决方法是在跳转大的时候同时绘制这两个LOD。
首先绘制低层次,然后在一个很短的时间段内使其随着高层次的绘制渐变消失。
然而,这种方法仅在每个像素的z-buffer(深度)距离高层次块较近时效果较好;否则高层次块不会自然地在低层次块上做alpha混合。
因此,当我们绘制高层次块时,应当在顶点着色器中对z(深度)值进行微小的负向修正。
更好的解决方法是,我们可以通过对密度函数进行小的负向修正来创建低层次块。
这个方法会等方向性地“侵蚀”LOD块,很类似于沿着表面法线将表面进行收缩(但效果更好,因为不会造成任何尖点)。
这样的结果是。
高层次的块会逐渐代替低层次的块,同时不会在进行alpha混合时出现z深度冲突的问题。
1、碰撞
在一个交互的或游戏环境中,许多可移动的对象,如昆虫、鸟、角色的腿等,必须能够被探测并能够对于地形的碰撞进行响应。
“智能”的飞行生物或许需要在这种时刻之前就发出射线(如同在“Cascades”演示中的蜻蜓一样)来判别各种地形特征。
而贴着地表的对象——例如,生长着的藤蔓(“Cascades”演示中的隐藏特性),蜘蛛或流动的水,则必须在移动的时候紧贴着地形表面。
被扔出去或者被发射出去的对象同样需要知道它们何时碰撞到了地形,从而可以停止移动(如长矛碰到了地面)、弹起(如足球)或触发一些事件。
若对象的动作主要由GPU内的着色器来驱动,那么这些对象与地形的交互非常容易计算。
最简单的计算方法是使用几何体着色器,其中一个小缓冲区保存着每帧经过几何体着色器的每个移动对象的单个元素(顶点)。
要使几何体着色器得到地形信息,必须将密度函数存放于一个单独的文件中,以使得其他着色器可以将其包含(通过#include的方式)。
然后几何体着色器便可以包含这个文件,并使用函数根据需要进行查询,来测试空间中的一点是否在地形之内或之外。
例如,若一个足球正沿着地形滚下,几何体着色器可以在前一帧的位置和当前的位置测试密度函数。
若球之前在空中,而当前处于地形之内,那么球首次碰撞到地面的位置能够通过对密度函数进行插值的方法计算出来。
或者我们可以使用一种相对而言更好的方法,如区间分半法。
一旦找到了碰撞的位置,就可以计算该点的梯度(通过6次或更多的采样)。
得到球的速度和地形的法线后,就可以计算反弹方向,输出新的位置以及球的速度。
2、光照
若前面的例子中的球落入了一个洞中,观察者会期望其由于洞内对环境光的遮挡而看起来变暗(假设它不是一个神奇的、发光的足球)。
幸运的是,这可以通过每帧(若对象在运动)从对象的中央发出环境遮挡光线来实现,该方法类似于我们创建单个地形顶点时投射光线的方法。
唯一的不同之处在于,此处使用密度函数来代替密度空间,因为此块的密度空间的数据很可能早已过时了。
使用密度函数要慢许多,但如果这些遮挡光线仅仅是每帧从几个正在运动的、可见的对象中发出的,这方面的影响就可以忽略不计。
ASurveyofDeformableModelingin
ComputerGraphics
Abstract:
Thispaperpresentsasurveyoftheworkdoneinmodelingdeformableobjectswithinthecomputergraphicsresearchcommunity.Theresearchhasalonghistoryandawidevarietyofapproacheshavebeenused.Thispaperorganizesthediversityofresearchbythetechniqueusedratherthanbytheapplication,althoughapplicationsarediscussedthroughout.Thispaperpresentssomepurelygeometricapproachesformodelingdeformableobjects,butfocusesonphysicallybasedapproaches.Inthelattercategoryaremass-springmodels,finiteelementmodels,approximatecontinuummodels,andlowdegreeoffreedommodels.Specialemphasisisplacedonfiniteelementmodels,whichofferthegreatestaccuracy,buthaveseenlimiteduseincomputergraphics.Thepaperalsosuggestsimportantareasforfutureresearch.
1.Introduction
Computershavebecomeanindispensabletoolinmodelingandsimulation.Ascomputationalpowerincreases,usersandapplicationsaredemandingeverincreasinglevelsofrealisminthesedomains.Thistrendisparticularlyapparentincomputergraphicswheremoresophisticatedgeometricshapesandphysicalobjectsarebeingmodeledinthecontextofcomplexphysicalenvironments.Inparticular,theabilitytomodelandmanipulatedeformableobjectsisessentialtomanyapplications.Approachesformodelingobjectdeformationrangefromnon-physicalmethods—whereindividualorgroupsofcontrolpointsorshapeparametersaremanuallyadjustedforshapeeditinganddesign—tomethodsbasedoncontinuummechanics—whichaccountfortheeffectsofmaterialproperties,externalforces,andenvironmentalconstraintsonobjectdeformation.
Deformableobjectmodelinghasbeenstudiedincomputergraphicsformorethantwodecades,acrossarangeofapplications.Incomputer-aideddesignandcomputerdrawingapplications,deformablemodelsareusedtocre