gl_FragCoord - OpenGL 4 Reference Pages - Khronos Group

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

Available only in the fragment language, gl_FragCoord is an input variable that contains the window relative coordinate (x, y, z, 1/w) values for the ... Name gl_FragCoord—containsthewindow-relativecoordinatesofthecurrentfragment Declaration in vec4 gl_FragCoord ; Description Availableonlyinthefragmentlanguage,gl_FragCoordisaninputvariablethatcontainsthe windowrelativecoordinate(x,y,z,1/w)valuesforthefragment.Ifmulti-sampling, thisvaluecanbeforanylocationwithinthepixel,oroneofthefragmentsamples. Thisvalueistheresultoffixedfunctionalitythatinterpolatesprimitivesaftervertex processingtogeneratefragments.Thezcomponentisthedepthvaluethatwouldbeusedforthe fragment'sdepthifnoshadercontainedanywritestogl_FragDepth. gl_FragCoordmayberedeclaredwiththeadditionallayoutqualifieridentifiers origin_upper_leftorpixel_center_integer.By default,gl_FragCoordassumesalower-leftoriginforwindowcoordinates andassumespixelcentersarelocatedathalf-pixelcenters.Forexample,the(x,y)location (0.5,0.5)isreturnedforthelower-left-mostpixelinawindow.Theoriginof gl_FragCoordmaybechangedbyredeclaringgl_FragCoord withtheorigin_upper_leftidentifier.Thevaluesreturnedcanalsobe shiftedbyhalfapixelinbothxandybypixel_center_integersoit appearsthepixelsarecenteredatwholenumberpixeloffsets.Thismovesthe(x,y)valuereturnedby gl_FragCoordof(0.5,0.5)bydefaultto(0.0,0.0)with pixel_center_integer. Ifgl_FragCoordisredeclaredinanyfragmentshaderinaprogram,itmustberedeclared inallfragmentshadersinthatprogramthathavestaticuseofgl_FragCoord.Redeclaring gl_FragCoordwithanyacceptedqualifieraffectsonlygl_FragCoord.x andgl_FragCoord.y.Ithasnoeffectonrasterization,transformationoranyotherpart oftheOpenGLpipelineorlanguagefeatures. VersionSupport OpenGLShadingLanguageVersion VariableName 1.10 1.20 1.30 1.40 1.50 3.30 4.00 4.10 4.20 4.30 4.40 4.50 gl_FragCoord ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ SeeAlso gl_FragDepth Copyright Copyright©2011-2014KhronosGroup. Thismaterialmaybedistributedsubjecttothetermsandconditionssetforthin theOpenPublicationLicense,v1.0,8June1999. http://opencontent.org/openpub/.



請為這篇文章評分?