您的位置:首页 > Web前端

[转]Linear Depth Buffer(线性深度缓冲区)

2012-02-07 14:30 176 查看
[b]TheProblemwithZ-Buffer[/b]Ifyouareagraphicsprogrammer,youareboundtodealwiththeuseofz-bufferforeffects.Forexample,thedepthbuffercanbeusedforperpixelfog,softparticles,motionblur,SSAO,depthoffield,etc.Usingthestandarddepth,i.e.thevaluethatisobtainedbymultiplyingwithWorldViewProjectionmatricesfollowedbyperspectivedivide,isoftennotenough.Themainproblemwithstandarddepthisthatthedepthvalueisnotlinear.Mostofthetime,thefirst10%ofthescene(thenearscene)willbemappedto0.0to0.9range.Inotherwords,90%oftheprecisionisusedupinthefirst10percentoftheviewingdistance.Ifyouralgorithmreliesheavilyondepthcomparison,youarescrewed.Thekeytohandlethisproblemistomakethedepthvaluelinearormakingitalmostlinear.Iwilldescribethetwoapproachesbelow:[b]LinearDepthBuffer[/b]NoticethatmultilyingWorld,View,Projectionmatriceswithyourpositionwillmakeitendsupinclipspace,(x,y,z,w)=(x_in_clip,y_in_clip,z_in_clip,z_in_view)exceptthatw=z_in_view.Wecanexploitthisfactandinsteadofstoringthestandarddepthwhichisobtainedbyz/w=z_in_clip/z_in_view,wecanstorelineardepthvalue.Thereareseveralvariationsformappingz_in_viewlinearly.Forexample,youcando:z_final=z_in_view/camera_far_plane
oryoucanalsodo:z_final=(z_in_view-camera_near_plane)/(camera_far_plane-camera_near_plane)

[b]W-Buffer[/b]
Theideaofw-bufferistoprovideamoredistributedlinearmappingthanforz-buffersbyinvertingthedepthvalue.Bydoingthis,youeffectivelymapthelast90%ofthescene(thefarscene)to0.0to0.9range.Inotherwords,wbuffercanstillproduceartifactswhenmanyoftheobjectsinthesceneareclosetothecamera.Incomparisontoz-buffer,w-bufferhasalotmoreprecisionavailableforobjectsinthemiddletofardistancefromtheviewer.Incodelanguage,youwouldoutput:z_final=1/z_in_view
Inconclusion

I'vediscussedseveraltechniquestoalleviatethenon-linearityofz-buffer.Ihopeitcangiveyoulightwhyyoumayhavealotofartifactsusingthestandardz-buffer.
from:http://www.3dgametechnology.com/index.php?option=com_content&view=article&id=95:linear-depth-buffer&catid=34:articles&Itemid=55

moreflexibledepthbuffercontroltitled"quasi-lineardepthbuffer".
http://dl.acm.org/citation.cfm?id=383530AutodeskCanadaCo.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: