Using gl_FragColor vs. out vec4 color? - Stack Overflow

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

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  



請為這篇文章評分?