LearnOpenGL - Depth Testing
文章推薦指數: 80 %
The x and y components of gl_FragCoord represent the fragment's screen-space coordinates (with (0,0) being the bottom-left corner). The gl_FragCoord variable ... Ifyou'rerunningAdBlock,pleaseconsiderwhitelistingthissiteifyou'dliketosupportLearnOpenGL;andnoworries,Iwon'tbemadifyoudon't:) IntroductionGettingstartedOpenGLCreatingawindowHelloWindowHelloTriangleShadersTexturesTransformationsCoordinateSystemsCameraReviewLightingColorsBasicLightingMaterialsLightingmapsLightcastersMultiplelightsReviewModelLoadingAssimpMeshModelAdvancedOpenGLDepthtestingStenciltestingBlendingFacecullingFramebuffersCubemapsAdvancedDataAdvancedGLSLGeometryShaderInstancingAntiAliasingAdvancedLightingAdvancedLightingGammaCorrectionShadowsShadowMappingPointShadowsNormalMappingParallaxMappingHDRBloomDeferredShadingSSAOPBRTheoryLightingIBLDiffuseirradianceSpecularIBLInPracticeDebuggingTextRendering2DGameBreakoutSettingupRenderingSpritesLevelsCollisionsBallCollisiondetectionCollisionresolutionParticlesPostprocessingPowerupsAudioRendertextFinalthoughtsGuestArticlesHowtopublish2020OITIntroductionWeightedBlendedSkeletalAnimation2021CSMSceneSceneGraphFrustumCullingTessellationHeightmapTessellationDSACoderepositoryTranslationsAbout BTC 1CLGKgmBSuYJ1nnvDGAepVTKNNDpUjfpRa ETH/ERC20 0x1de59bd9e52521a46309474f8372531533bd7c43 WelcometoOpenGL WelcometotheonlinebookforlearningOpenGL!WhetheryouaretryingtolearnOpenGLforacademicpurposes,topursueacareerorsimplylookingforahobby,thisbookwillteachyouthebasics,theintermediate,andalltheadvancedknowledgeusingmodern(core-profile)OpenGL.TheaimofLearnOpenGListoshowyouallthereistomodernOpenGLinaneasy-to-understandfashionwithclearexamples,whilealsoprovidingausefulreferenceforlaterstudies. Sowhyreadthesechapters? Throughouttheinternettherearethousandsofdocuments,books,andresourcesonlearningOpenGL,however,mostoftheseresourcesareonlyfocusedonOpenGL'simmediatemode(commonlyreferredtoastheoldOpenGL),areincomplete,lackproperdocumentation,orarenotsuitedforyourlearningpreferences.Therefore,myaimistoprovideaplatformthatisbothcompleteandeasytounderstand. Ifyouenjoyreadingcontentthatprovidesstep-by-stepinstructions,clearexamples,andthatwon'tthrowyouinthedeepwithmillionsofdetails,thisbookisprobablyforyou.Thechaptersaimtobeunderstandableforpeoplewithoutanygraphicsprogrammingexperience,butarestillinterestingtoreadforthemoreexperiencedusers.Wealsodiscusspracticalconceptsthat,withsomeaddedcreativity,couldturnyourideasintoreal3Dapplications.Ifalloftheprevioussoundslikesomeonethatcouldbeyou,thenbyallmeans,pleasecontinue. Whatwillyoulearn? ThefocusofthesechaptersareonModernOpenGL.Learning(andusing)modernOpenGLrequiresastrongknowledgeofgraphicsprogrammingandhowOpenGLoperatesunderthehoodtoreallygetthebestofyourexperience.Sowewillstartbydiscussingcoregraphicsaspects,howOpenGLactuallydrawspixelstoyourscreen,andhowwecanleveragethatknowledgetocreatesomefunkylookingeffects. Ontopofthecoreknowledgewewilldiscussmanyusefultechniquesthatyoucanuseforyourapplications,like:traversingascene,createbeautifullighting,loadcustom-madeobjectsfromamodellingprogram,docoolpost-processingtechniques,andmuchmore.WealsofeatureawalkthroughserieswhereweactuallycreateasmallgamebasedonourobtainedOpenGLknowledge,soyouwillreallygetafeelofwhatit'sliketoactuallydographicsprogramming. Wheretostart LearnOpenGLisfree,andwillalwaysbefree,foranyonewhowantstostartwithgraphicsprogramming.Allcontentisavailablehereatthemenutoyourleft.SimplyhittheIntroductionbuttonandyou'rereadytostartyourjourney! LearnOpenGL-printedition Thecontenthasbeenthoroughlyrevised,numeroustimes,overthecourseof7yearstohavefinallybeenaggregatedintoaphysicalcopyavailableforprint.There'sbeenalotofworkputintothephysicalcopy,treatingitasthefirst-classcitizenitis.Boththebookandwebsiteareequals,theircontentisthesame. Aseverythingisfreelyavailableonline,gettingthephysicalcopysupportsmeasanauthor;andlet'snotforgetthatcertaincharmofprintedpaper.ThebookisavailableforsaleonAmazonUS,AmazonUK,Barnes&Noble,andmanyother(online)retailers.Notethatatsomeretailersthebookis ridiculouslyoverpriced;makesureitmatchesroughly$60USdollars,orwaitabituntillthepricesbalancethemselvesout. LearnOpenGL-onlineprintedition-FreePDF I'verevisedthesourcefilesforthephysicalprinteditionandcleanedthemuptobeavailableforonlinereadingaswell,forthosethatpreferitscontentinasingularPDFformat.Usethisformatifyou'dliketoreadduringtravel,writenotes,orprintitoutyourself.Insimilarstyletothewebsite,thisversionis,andwillalwaysbe,freelyavailable. Notethat,similartothephysicalcopy,links/urlsarewrittenoutfullyorasfootnotes,videosshowstaticimages,andthere'snofunctionhoverpop-ups;alltoaccountforthecontentbeingmostlyoffline. Ifyouwanttokeepuptodateonthesiteandbook'sprogressand/orotherLearnOpenGLnews,pleasefollowmeonTwitter. HI
延伸文章資訊
- 1gl_FragCoord 的含义 - 知乎专栏
gl_FragCoord.w 是裁剪空间clip.w 的倒数即1/clip.w , 由上面的透视投影矩阵的推导过程可以看出,为了凑透视除法, clip.w 值就是眼坐标系z 值的负数,也 ...
- 2高级GLSL
如果着色器中没有像 gl_FragDepth 变量写入,它就会自动采用 gl_FragCoord.z 的值。 我们自己设置深度值有一个显著缺点,因为只要我们在片段着色器中对 gl_FragDep...
- 3What does (gl_FragCoord.z / gl_FragCoord.w) represent?
z / gl_FragCoord.w is not the camera-space (or world-space) distance to the camera. Nor is it the...
- 4How to access depth buffer values? - Or: gl_FragCoord.z vs ...
gl_FragCoord.z is the window-space depth value of the current fragment. It has nothing to do with...
- 5LearnOpenGL - Depth Testing
The x and y components of gl_FragCoord represent the fragment's screen-space coordinates (with (0...