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
延伸文章資訊
- 1WebGL着色器内置变量gl_PointSize - gl_FragCoord - CSDN博客
gl_FragColor, 片元颜色值, vec4. gl_FragCoord, 片元坐标,单位像素, vec2. gl_PointCoord, 点渲染模式对应点像素坐标, vec2 ...
- 2varying 傳遞著色資訊
至今為止的範例,片段著色器的gl_FragColor 都是寫死的,然而attribute 只能用在頂點著色器中,若想自行指定顏色資訊,應當如何傳遞給片段著色器? 著色器的設計, ...
- 3GLSL着色器- 游戏开发环境 - MDN Web Docs
这个着色器的作用是设置 gl_FragColor 变量, 也是一个GLSL内置变量: void main() { gl_FragColor = makeCalculationsToHaveCol...
- 4使用shaders 在WebGL 上色
替fragment 上色. 我們重新回顧一下,之前我們的fragment shader 如下:. const fsSource = ` void main() { gl_FragColor = ...
- 5一起幫忙解決難題,拯救IT 人的一天
昨天提到fragment shader 輸出gl_FragColor gl_FragColor // vec4 ... gl_FragColor = vec4(1.0, 1.0, 0.0, 1....