Read depth values while stencil testing(same texture) - Stack ...

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

In my opinion there should not be any problems, because i'm not reading the stencil buffer values in the shader. 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 Readdepthvalueswhilestenciltesting(sametexture) AskQuestion Asked 6years,1monthago Modified 6years,1monthago Viewed 779times 0 Iknowthatitisaverybadideatoread/writefrom/tothesametexture/location,becausethiswouldresultinundefinedbehaviour. Butinmycase,ifdepthtestingisdisabledandIreadthedepthvaluesinashader,isitoktodothestenciltestingatthesametimeasreadingthedepthvalueswithinthesametexture? Inmyopinionthereshouldnotbeanyproblems,becausei'mnotreadingthestencilbuffervaluesintheshader.Or,couldtherebyanyhardwarerelatedproblemswhenthetextureisboundforreadinginashaderandOpenGLusesittodothestenciltesting? Thistextureisfilledwithdepth/stencilvalues.Iwan'ttoavoidsomeheavyBRDFlighting(Directionallight)calculationsonspecificpixels(thesky). Examplecode: //Containsthedepth/stenciltexture(deferredDepthStencilTextureID). //TwoFBO'saresharingthesamedepth/stenciltexture. lightAccumulationFBO->bind(); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_EQUAL,1,0xFF); //Disablewritingtothestencilbuffer,i.e.allthebitsiswrite-protected. glStencilMask(0x00); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE);//Additiveblending.Lightaccumulation. glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,deferredDepthStencilTextureID);//GL_DEPTH24_STENCIL8 //Bindothertextureshere... shader.bind(); //Uniformshere... postProcessQuad->renderQuad(); shader.unbind(); //Unbindallthetextureshere. ... glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); lightAccumulationFBO->unbind(); opengltexturesshaderdepth-bufferstencil-buffer Share Follow editedApr22,2016at3:47 karl88 askedApr22,2016at0:45 karl88karl88 31111silverbadge1111bronzebadges 2 Doyouonlydostenciltestinginthisrenderingpass,ordoyouuseastenciloperationthatmodifiesthestencilvaluesaswell? – RetoKoradi Apr22,2016at2:52 Ihaveupdatedmypostwithexamplecode.Ihavenotincludedthestenciloperationinthisrenderingpass.Ihavealsosetthestencilmasklikethis:glStencilMask(0x00); – karl88 Apr22,2016at3:44 Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 1 Butinmycase,ifdepthtestingisdisabledandIreadthedepthvaluesinashader,isitoktodothestenciltestingatthesametimeasreadingthedepthvalueswithinthesametexture? No.WhetheranoperationisdefinedornotisbasedontheimagesattachedtotheFBOandreadfrom.Notthecomponentsofsaidimages.Andno,writemaskingwillnotsaveyoufromundefinedbehavior. Sounlessyourstenciltextureisseparatefromyourdepthtexture,that'snotgoingtowork.Andgoodluckfindinghardwarethatwillallowyoutoseparatedepth/stencilimages. EvenwithGL4.5/NV/ARB_texture_barrier,theanswerisstillno.Thatfunctionalitymakescertainexceptionstotheaboverule,butonlyforoperationsthatareduetofragmentshaderoutputs.Stenciltestoperationsarenotfragmentshaderoutputs,sotheydon'tapply. Share Follow answeredApr22,2016at4:49 NicolBolasNicolBolas 412k6161goldbadges709709silverbadges901901bronzebadges 1 ok,thanksfortheinfo.So,whataremyoptions?Renderaquadandcopyingthedepthinfo.toanotherfbo/texture?Blittingfbos?Whichmethodisbestwhenitcomestoperformance? – karl88 Apr22,2016at5:38 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?Browseotherquestionstaggedopengltexturesshaderdepth-bufferstencil-bufferoraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Related 0 DrawingtothealphachanneloftheframebufferonwithOpenGLwhileignoringRGBvalues? 7 Accessdepth-stenciltextureinashaderprogram 1 Wrongdepthbuffer(totexture)output? 0 OpenGL:BindFBO'sdepthtexturetoacomputeshader HotNetworkQuestions Tryingtouseacaralternatorforapowersource(notforcar) Iworkfromhomeasasoftwareengineerandmyjobishappywithmyperformance.ButI'mputtinginlittleeffort.AmIabadpersonoremployee? GameinJamesBondfilm"FromRussiawithlove" Isthisaninsectnest? SelectonlyonepointinpolygonusingQGIS Pleasehelpmeclarifythissentenceabout'microtones'onGroveMusic Whatdoyoucalladesperateattemptunlikelytosucceed? Canarunascendinglistbemade? HowdoesHebrews11:27sayMoseswasnotafraid? IsitallowedtocopycodeundertheUnityReference-OnlyLicense? Meaningandoriginoftheword"muist" Mathematica13.0simplifiestrigonometricintegralwrong Howdoyouemptyanonlinevirtualdebitcard? Softwareforcreatinghand-writtenslidesthatarerevealedgradually Didmyprofessoractunethicallybypublishingapaperwithafigurefrommythesiswithoutanyacknowledgement? Deleteafilecalled'.env'$'\r' Doubleindictmentforthesameact CanImakeGooglePlayshowmeALLreviewsforanapp? Whydoesthex86nothaveaninstructiontoobtainitsinstructionpointer? WhydoesBendersay"Pleaseinsertgirder"? Igotninety-nineproblems-sohere'sanotherone! QGISreadsblankcellsas"nan"insteadof"NULL" Partitioningalistbasedonacriterionforsublists GAMmodelwarningmessage:stepfailureinthetaestimation morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?