Back-face culling - Wikipedia
文章推薦指數: 80 %
In computer graphics, back-face culling determines whether a polygon of a graphical object is visible. It is a step in the graphical pipeline that tests ... Back-faceculling FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch OntheleftamodelwithoutBFC;ontherightthesamemodelwithBFC:back-facesareremoved. Incomputergraphics,back-facecullingdetermineswhetherapolygonofagraphicalobjectisvisible.Itisastepinthegraphicalpipelinethattestswhetherthepointsinthepolygonappearinclockwiseorcounter-clockwiseorderwhenprojectedontothescreen.Iftheuserhasspecifiedthatfront-facingpolygonshaveaclockwisewinding,butthepolygonprojectedonthescreenhasacounter-clockwisewindingthenithasbeenrotatedtofaceawayfromthecameraandwillnotbedrawn. Theprocessmakesrenderingobjectsquickerandmoreefficientbyreducingthenumberofpolygonsfortheprogramtodraw.Forexample,inacitystreetscene,thereisgenerallynoneedtodrawthepolygonsonthesidesofthebuildingsfacingawayfromthecamera;theyarecompletelyoccludedbythesidesfacingthecamera. Ingeneral,back-facecullingcanbeassumedtoproducenovisibleartifactinarenderedsceneifitcontainsonlyclosedandopaquegeometry.Inscenescontainingtransparentpolygons,rear-facingpolygonsmaybecomevisiblethroughtheprocessofalphacomposition.Inwire-framerendering,back-facecullingcanbeusedtopartiallyaddresstheproblemofhiddenlineremoval,butonlyforclosedconvexgeometry. Arelatedtechniqueisclipping,whichdetermineswhetherpolygonsarewithinthecamera'sfieldofviewatall. AnothersimilartechniqueisZ-culling,alsoknownasocclusionculling,whichattemptstoskipthedrawingofpolygonsthatarecoveredfromtheviewpointbyothervisiblepolygons. Innon-realisticrenderscertainfacescanbeculledbywhetherornottheyarevisible,ratherthanfacingawayfromthecamera."invertedhull"or"frontfaceculling"canbeusedtosimulateoutlinesortoonshaderswithoutpost-processingeffects.[1] Implementation[edit] Onemethodofimplementingback-facecullingisbydiscardingalltriangleswherethedotproductoftheirsurfacenormalandthecamera-to-trianglevectorisgreaterthanorequaltozero ( V 0 − P ) ⋅ N ≥ 0 {\displaystyle\left(V_{0}-P\right)\cdotN\geq0} wherePistheviewpoint,V0isthefirstvertexofatriangleandNisitsnormal,definedasacrossproductoftwovectorsrepresentingsidesofthetriangleadjacenttoV0 N = ( V 1 − V 0 ) × ( V 2 − V 0 ) {\displaystyleN=\left(V_{1}-V_{0}\right)\times\left(V_{2}-V_{0}\right)} Sincecrossproductisnon-commutative,definingthenormalintermsofcrossproductallowstospecifynormaldirectionrelativetotrianglesurfaceusingvertexorder(winding): ( V 1 − V 0 ) × ( V 2 − V 0 ) = − ( V 2 − V 0 ) × ( V 1 − V 0 ) {\displaystyle\left(V_{1}-V_{0}\right)\times\left(V_{2}-V_{0}\right)=-\left(V_{2}-V_{0}\right)\times\left(V_{1}-V_{0}\right)} Ifpointsarealreadyinviewspace,Pcanbeassumedtobe(0,0,0),theorigin. − V 0 ⋅ N ≥ 0 {\displaystyle-V_{0}\cdotN\geq0} Itisalsopossibletousethismethodinprojectionspacebyrepresentingtheaboveinequalityasadeterminantofamatrixandapplyingtheprojectionmatrixtoit.[2] Anothermethodexistsbasedonreflectionparity,whichismoreappropriatefortwodimensionswherethesurfacenormalcannotbecomputed(alsoknownasCCWcheck). Letaunittriangleintwodimensions(homogeneouscoordinates)bedefinedas U 0 = [ 0 0 1 ] , U 1 = [ 1 0 1 ] , U 2 = [ 0 1 1 ] {\displaystyleU_{0}={\begin{bmatrix}0\\0\\1\end{bmatrix}},U_{1}={\begin{bmatrix}1\\0\\1\end{bmatrix}},U_{2}={\begin{bmatrix}0\\1\\1\end{bmatrix}}} Thenforsomeothertriangle,alsointwodimensions, V 0 = [ x 0 y 0 1 ] , V 1 = [ x 1 y 1 1 ] , V 2 = [ x 2 y 2 1 ] {\displaystyleV_{0}={\begin{bmatrix}x_{0}\\y_{0}\\1\end{bmatrix}},V_{1}={\begin{bmatrix}x_{1}\\y_{1}\\1\end{bmatrix}},V_{2}={\begin{bmatrix}x_{2}\\y_{2}\\1\end{bmatrix}}} defineamatrixthattransformstheunittriangle: M = [ x 1 − x 0 x 2 − x 0 x 0 y 1 − y 0 y 2 − y 0 y 0 0 0 1 ] {\displaystyleM={\begin{bmatrix}x_{1}-x_{0}&x_{2}-x_{0}&x_{0}\\y_{1}-y_{0}&y_{2}-y_{0}&y_{0}\\0&0&1\end{bmatrix}}} sothat: M U 0 = V 0 {\displaystyleMU_{0}=V_{0}} M U 1 = V 1 {\displaystyleMU_{1}=V_{1}} M U 2 = V 2 {\displaystyleMU_{2}=V_{2}} DiscardthetriangleifmatrixMcontainedanoddnumberofreflections(facingtheoppositewayoftheunittriangle) | M | < 0 {\displaystyle\left|M\right|<0} TheunittriangleisusedasareferenceandtransformationMisusedasatracetotellifvertexorderisdifferentbetweentwotriangles.Theonlywayvertexordercanchangeintwodimensionsisbyreflection.Reflectionisanexampleofinvolutoryfunction(withrespecttovertexorder),thereforeanevennumberofreflectionswillleavethetrianglefacingthesameside,asifnoreflectionswereappliedatall.Anoddnumberofreflectionswillleavethetrianglefacingtheotherside,asifexactlyafteronereflection.Transformationscontaininganoddnumberofreflectionsalwayshaveanegativescalingfactor,likewise,thescalingfactorispositiveiftherearenoreflectionsorevenanumberofthem.Thescalingfactorofatransformationiscomputedbydeterminantofitsmatrix. References[edit] ^https://jorick.vanderhoeven.ch/assets/files/sketch-shading.pdf[bareURLPDF] ^DavidH.Eberly(2006).3DGameEngineDesign:APracticalApproachtoReal-TimeComputerGraphics,p.69.MorganKaufmannPublishers,UnitedStates.ISBN 0122290631. Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Back-face_culling&oldid=1076631295" Categories:3DrenderingComputergraphicsalgorithmsHiddencategories:AllarticleswithbareURLsforcitationsArticleswithbareURLsforcitationsfromMarch2022ArticleswithPDFformatbareURLsforcitations Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk English Views ReadEditViewhistory More Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Languages DeutschفارسیItalianoNederlandsPortuguês Editlinks
延伸文章資訊
- 1What is Back-face Culling? - Computer Hope
Back-face culling is a method in computer graphics programming which determines whether a polygon...
- 2learnopengl学习笔记——面剔除(face culling) - CSDN博客
这正是面剔除(Face Culling)所做的。OpenGL能够检查所有面向(Front Facing)观察者的面,并渲染它们,而丢弃那些背向(Back Facing)的面,节省我们很多 ...
- 3A Compact Method for Backface Culling - Gamasutra
Backface culling is an important part of how a 3D engine performs visibility checks. Its purpose ...
- 4剔除(Culling) | 逍遙文工作室
其中在遊戲設計中,剔除又可細分為三類:不可見剔除(visibility culling)、遮擋剔除(occlusion culling)、背面剔除(backface culling)。
- 5Face culling - LearnOpenGL
face culling does. OpenGL checks all the faces that are · front facing towards the viewer and ren...