Back-face culling - Wikipedia

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?