I want to know the original stencil value of a pixel/fragment ...
文章推薦指數: 80 %
[...] Is it that the original stencil value is zero not one? By default the clear value for the stencil buffer is 0. The stencil buffer is ... 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 Iwanttoknowtheoriginalstencilvalueofapixel/fragment.,zeroorone?Ifpossibletogetwhatspecificactionmodifythestencilvalue? AskQuestion Asked 2years,9monthsago Modified 2years,9monthsago Viewed 192times 0 IamconfusedmanythingsaboutstencilbufferinOpenGL.Ireadtheopengltutorialshere,https://learnopengl.com/Advanced-OpenGL/Stencil-testing.Isimplyaddonelinecode glStencilFunc(GL_EQUAL,1,0xFF); andthennothingwillberendered. ifisetthelinecodeas glStencilFunc(GL_NOTEQUAL,1,0xFF); myobjswillberenderedcorrectly. Iwonderwhy?Isitthattheoriginalstencilvalueiszeronotone? Somecodebelow: glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_EQUAL,1,0xFF); //glStencilFunc(GL_NOTEQUAL,1,0xFF); //glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); while(!glfwWindowShouldClose(window)) { glfwPollEvents(); glClearColor(0.1f,0.1f,0.1f,1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); shader.use(); glm::mat4model=glm::mat4(1.0f); glm::mat4view=g_camera.GetViewMatrix(); glm::mat4projection=glm::perspective(g_camera.Zoom,(float)AppGlobal::getInstance()->windowWidth/(float)AppGlobal::getInstance()->windowHeight,0.1f,100.0f); glUniformMatrix4fv(glGetUniformLocation(shader.m_program,"view"),1,GL_FALSE,glm::value_ptr(view)); glUniformMatrix4fv(glGetUniformLocation(shader.m_program,"projection"),1,GL_FALSE,glm::value_ptr(projection)); //Floor glBindVertexArray(planeVAO); glBindTexture(GL_TEXTURE_2D,floorTexture); model=glm::mat4(1.0f); glUniformMatrix4fv(glGetUniformLocation(shader.m_program,"model"),1,GL_FALSE,glm::value_ptr(model)); glDrawArrays(GL_TRIANGLES,0,6); //someotherobjects glBindVertexArray(0); glfwSwapBuffers(window); } c++openglglfwglm-mathstencil-buffer Share Improvethisquestion Follow editedJul30,2019at18:40 Rabbid76 176k2525goldbadges101101silverbadges145145bronzebadges askedJul30,2019at16:17 MengyuChenMengyuChen 7544bronzebadges Addacomment | 1Answer 1 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 3 [...]Isitthattheoriginalstencilvalueiszeronotone? Bydefaulttheclearvalueforthestencilbufferis0. ThestencilbufferisclearedwhenglClear(GL_STENCIL_BUFFER_BIT)iscalled.TheclearvalueforthestencilbuffercanbespecifiedbyglClearStencil.Theinitialvalueis0. Share Improvethisanswer Follow answeredJul30,2019at17:34 Rabbid76Rabbid76 176k2525goldbadges101101silverbadges145145bronzebadges 0 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?Browseotherquestionstaggedc++openglglfwglm-mathstencil-bufferoraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Related 206 WhatdothefollowingphrasesmeaninC++:zero-,default-andvalue-initialization? 93 Howdoesthefragmentshaderknowwhatvariabletouseforthecolorofapixel? 17 Whatisthedifferencebetweenasample,apixelandafragment? 3 PyOpenGL-MinimalglDrawArraysExample 0 IsitpossibletogetpixelsfromOpenGLbufferattheoriginalsize? 0 C++whattypeshouldIuseifIknowtheexacttypefromafewpossible? HotNetworkQuestions ExistenceProblemofpigeonhole,selectingamongasetof50numbers. WhentochangeoilfornewgenerationMazda? WhatisRNAVtransitionandwhatisthedifferencebetweenRNAVtransitionandRNAVSTAR Can'tmultiplywidthin\newcommandforincludegraphics HowdoesHebrews11:27sayMoseswasnotafraid? Isitdangeroustoconsume30mgofZinc(asZincPicolinate)perday? SelectonlyonepointinpolygonusingQGIS WhatpreventsmefrommakingonebigestimatedFederaltaxpaymentonJan15? Alternativestotannininplantbark WhatdoesGandalftheWhitemeanbyhisstrangespeechaboutBoromir? Howtomodelasimpleshoe Isitillegaltorideadrunkhorse? Longestgeometricprogressionofprimes Igotninety-nineproblems-sohere'sanotherone! Isitaredflagforacompanytohave"unlimitedpaidtimeoff"? Wouldn'tMiller'splanetbefriedbyblueshiftedradiation? Audiosplitterwithoutbufferpossible? IsitOKtousemixedDNSservers? Partitioningalistbasedonacriterionforsublists Whatisthemostecologicallysustainablewaytohandleragscoveredinchaingrease? ESTAform:Mentionthecitydistrictinthecontactinformationsection? 'Mapping'thevaluesofalisttovariable AquestionregardingisomorphismincohomologyformodulispaceofstablebundlesoveracompactRiemannsurface Howdoyouemptyanonlinevirtualdebitcard? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-cpp Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1Stencil testing - LearnOpenGL
A stencil buffer (usually) contains 8 bits per stencil value that amounts to a total of 256 diffe...
- 2Shader Specified Stencil Reference Value (Direct3D 12 ...
This method sets the stencil reference value on a per-draw granularity. However, this value can b...
- 3OpenGL - depth and stencil buffers - YouTube
- 4How to Create Masks With the Custom Stencil Buffer - YouTube
- 5I want to know the original stencil value of a pixel/fragment ...
[...] Is it that the original stencil value is zero not one? By default the clear value for the s...