Force depth test against a specific depth value, instead of ...

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

Not the answer you're looking for? Browse other questions tagged opengl glsl opengl-3 depth-testing or ask your own question. The Overflow Blog. 2022DeveloperSurveyisopen!Takesurvey. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore Forcedepthtestagainstaspecificdepthvalue,insteadoffragment'sactualdepth AskQuestion Asked 2years,6monthsago Modified 2years,6monthsago Viewed 249times 1 IwanttodrawsomeprimitivesbehindeverythingthatwrotetothedepthbufferbyusingglDepthFunc(GL_EQUAL)andwritingtoeverypixelthathasadepthof1.0(thehighestanddefaultvalue) However,forthistoworkIhavetoignorethecalculatedZ-depthonmyprimitives,forcingthemtotestasifitwere1.0forallofthem. Whatwouldbetheeasiestwaytoforceallfragmentsinaspecificdrawtotestashavingaz-depthof1.0regardlessoftheactualz-depthcalculatedinthevertexshader? openglglslopengl-3depth-testing Share Improvethisquestion Follow editedNov6,2019at19:22 Rabbid76 176k2525goldbadges101101silverbadges145145bronzebadges askedNov6,2019at19:10 AnneQuinnAnneQuinn 11.6k77goldbadges5050silverbadges8989bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 2 Ifyouwantthatallfragmentshaveadepthof1.0,theyou'vetoensure,thatthezcomponentofthenormalizeddevicecoordinateis1.0. Thenormalizeddevicecoordinateiscalculatedbyaperspectivedivideformtheclipcoordinate(thinkaboutthatasgl_Position.xyz/gl_Position.w). Setgl_Position.zequalgl_Position.w,aftertheclipcoordinateisset,thatcausesthatgl_Position.z/gl_Position.wis1.0: gl_Position.z=gl_Position.w; Butnote,thedepthofafragmentcanalsobesetinthefragmentshader,byassigningavaluetogl_FragDepth: (OfcoursethispreventsthattheEarlyFragmentTestcantakeplace) gl_FragDepth=1.0; Share Improvethisanswer Follow answeredNov6,2019at19:19 Rabbid76Rabbid76 176k2525goldbadges101101silverbadges145145bronzebadges Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedopenglglslopengl-3depth-testingoraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Related 20 drawthedepthvalueinopenglusingshaders 0 HowdoIdepth-testforacertainrange? 5 Howtoachievedepthvalueinvariancebetweentwopasses? 0 OpenGL:Specifywhatvaluegetswrotetothedepthbuffer? 3 Drawingoverterrainwithdepthtest? 0 Openglnothingisbeingwrittentodepthbuffer 1 IsitpossibletodepthtestagainstadepthtextureIamalsosampling,inthesamedrawcall? HotNetworkQuestions DidSauroneverconsiderthattheValarand/orEruIlúvatarmaynotallowhimtoconquerMiddle-earth? Deleteafilecalled'.env'$'\r' Whatdisadvantagesaretheretoencryptinganentireharddriveorahomedirectory? IsitOKtousemixedDNSservers? WhentochangeoilfornewgenerationMazda? UnabletomountaLinuxRAIDarray Isitdangeroustoconsume30mgofZinc(asZincPicolinate)perday? Differencebetweenproductsandcoproducts. Isitillegaltorideadrunkhorse? SignalprocessinginPythonvsC++(Bandpassfilter) AquestionaboutCubeNuroadRaceFE'shubdynamo? Movingplayerinsideofmovingspaceship? Audiosplitterwithoutbufferpossible? Meaningofclappingattheendofmass Whatdoyoucalladesperateattemptunlikelytosucceed? Whatmakesaluminumaerospacegrade? GN:Howtopassaninstancer'slocalizedtexturecolortoitsinstances? Waystomakeanalienatmospherebreathable,butuncomfortable? WhatdoesGandalftheWhitemeanbyhisstrangespeechaboutBoromir? Alternativestotannininplantbark Ihaveanarmadaofteleportingskyfortresses.DoIstillneedanavy? MostcommoncommandtocompileaLaTeXdocument? HowcanItellwhich3rdpartyflashesarecompatiblewithCanon'sSL3missingpinhotshoemount? Howdoyouemptyanonlinevirtualdebitcard? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-c Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?