Using gl_FragColor vs. out vec4 color? - Stack Overflow
文章推薦指數: 80 %
Writing to gl_FragColor specifies the fragment color that will be used by the subsequent fixed functionality pipeline. If subsequent fixed ... 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 Usinggl_FragColorvs.outvec4color? AskQuestion Asked 3years,10monthsago Modified 1year,5monthsago Viewed 18ktimes 19 4 Thereseemstobealotofambiguityaboutgl_FragColorbeingdeprecated.Forexample,itismissingintheGLSL4.40specification,butitisincludedintheGLSL4.60specification. Whatisthesafest,mostcompatible,mostsupportedstrategy?Usinggl_FragColorordefiningashaderoutputlikeoutvec4color? openglglslshader Share Improvethisquestion Follow editedDec7,2020at16:26 Rabbid76 176k2525goldbadges101101silverbadges145145bronzebadges askedJul21,2018at19:53 IntellectualKittyIntellectualKitty 44311goldbadge44silverbadges1212bronzebadges Addacomment | 2Answers 2 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 8 Yes,gl_FragColorisdeprecated.Youshouldusethefollowingsyntax: layout(location=0)outvec4diffuseColor; ItisincludedintheGLSL4.60specunderthesection7.1.7.CompatibilityProfileBuilt-InLanguageVariables.Thatmeans,ifyoucreateacorecontextthisvariablewillnotbeavailable. Share Improvethisanswer Follow answeredJul21,2018at20:02 daridari 2,1471010silverbadges1818bronzebadges 1 7 youdidn'tspecifywhat"outvec4color"means,youinsteadtalkingaboutsomethingelsecalled"diffuseColor"whichidon'tknowwhatitiseither – TheNegative Aug11,2019at4:11 Addacomment | 5 IfyouwouldreadthetheGLSL4.40specificationcarefully,thenyouwouldfindgl_FragCoordinchapter"7.1.1CompatibilityProfileBuilt-InLanguageVariables",asitisintheGLSL4.60specification. Thefollowingfragmentoutputvariablesareavailableinafragmentshaderwhenusingthecompatibilityprofile: outvec4gl_FragColor; outvec4gl_FragData[gl_MaxDrawBuffers]; Writingtogl_FragColorspecifiesthefragmentcolorthatwillbeusedbythesubsequentfixedfunctionalitypipeline.Ifsubsequentfixedfunctionalityconsumesfragmentcolorandanexecutionofthefragmentshaderexecutabledoesnotwriteavaluetogl_FragColorthenthefragmentcolorconsumedisundefined. Thismeansyoucan'tusegl_FragColor,inanOpenGLCoreprofileContext,becauseitisdeprecated,butitwouldstillbeavailableinacompatibilityprofile. Themodernwayofwritingtotheoutputbuffersfromafragmentshader,istodeclareuser-definedoutputvariablesandtouseLayoutQualifiers. Share Improvethisanswer Follow editedJul21,2018at20:33 answeredJul21,2018at20:14 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?Browseotherquestionstaggedopenglglslshaderoraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Visitchat Related 11 Fragmentshaders:outputvariables 2 GLSL3.3resources 1 iOSfragmentshaderswithmultipleoutputs 5 Namesof`out`variablesinafragmentshader 1 NULLchecksinGLSL 9 'outcan'tbeusedwithnon-varying'shadercompileerroronNvidiadriver,Intelworksfine,AMDhasanothererror 24 OpenGL:layoutqualifier? 0 SetcolorperspriteusingSpriteBatchandvertexcolor? 3 OpenGLtextureisallblackwhenrenderedwithshader HotNetworkQuestions Isitdangeroustoconsume30mgofZinc(asZincPicolinate)perday? Can"LaCorrida"mean"TheBullfight"? Non-committingauthenticatedencryptionschemesvscommittingauthenticatedencryptionschemes ShouldIrevealmyslidesbit-by-bitwhengivingapresentation/lecture? Whyweremarijuanarestrictionsimplementedinthe1970smoresuccessfulinSouthKoreathanintheUnitedStates? Canarunascendinglistbemade? Isitaredflagforacompanytohave"unlimitedpaidtimeoff"? WhyisMIDIgainbasedonafactorof40? Waystomakeanalienatmospherebreathable,butuncomfortable? QGISreadsblankcellsas"nan"insteadof"NULL" Whatdisadvantagesaretheretoencryptinganentireharddriveorahomedirectory? Haveastronomerstakenintoaccountthefactthatred-shiftedlightfromfar-awaystarsisalsoveryoldwhenstudyingtheexpansionoftheuniverse? GenerateAll8Knight'sMoves WhatdoesChaosTaxmean? HowcanItellwhich3rdpartyflashesarecompatiblewithCanon'sSL3missingpinhotshoemount? ProbleminNewton'sPrincipiamentionedbyV.I.Arnol'd WhatdoesGandalftheWhitemeanbyhisstrangespeechaboutBoromir? Whatis"aerospacegrade"? Differencebetweenproductsandcoproducts. Meaningofclappingattheendofmass CanWgatebewrittenonlyusingH,T? WhattapeformatdidtheNintendoFamicomDataRecorderuse? Tryingtouseacaralternatorforapowersource(notforcar) Howcanaprivatekeybeimportedtoadescriptorwallet? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-c Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1GLSL着色器- 游戏开发环境 - MDN Web Docs
这个着色器的作用是设置 gl_FragColor 变量, 也是一个GLSL内置变量: void main() { gl_FragColor = makeCalculationsToHaveCol...
- 2WebGL着色器内置变量gl_PointSize - gl_FragCoord - CSDN博客
gl_FragColor, 片元颜色值, vec4. gl_FragCoord, 片元坐标,单位像素, vec2. gl_PointCoord, 点渲染模式对应点像素坐标, vec2 ...
- 3Using gl_FragColor vs. out vec4 color? - Stack Overflow
Writing to gl_FragColor specifies the fragment color that will be used by the subsequent fixed fu...
- 4[Day9] webGL 修羅道- 特效實戰及總結 - iT 邦幫忙
我們把處理過後的紋理座標和sampler 結合在一起,並且傳值給 gl_FragColor 。 完整的fragment shader 會長這樣: precision mediump float;...
- 5找gl_FragColor相關社群貼文資訊| 服飾貼文懶人包-2022年1月
關於「gl_FragColor」標籤,搜尋引擎有相關的訊息討論:. 使用shaders 在WebGL 上色- Web APIs | MDN。 ARRAY_BUFFER, new Float32A...