gl_FragCoord - OpenGL 4 Reference Pages - Khronos Group
文章推薦指數: 80 %
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/.
延伸文章資訊
- 1glsl gl FragCoord 與螢幕關係 - w3c學習教程
gl_fragcoord根據glsl language spec的解釋為: ... 由於是2d渲染,最終每個fragment的gl_fragcoord的z接近0.0, 而w 為1.0, 而它的x...
- 2关于GLSL的gl_FragCoord、gl_FragDepth以及深度计算
gl_FragCoord和gl_FragDepth分别是片元着色器的输入和输出变量。gl_FragCoord是个vec4,四个分量分别对应x, y, z和1/w。其中,x和y是当前片元的窗口 ...
- 3高级GLSL
其中两个我们已经打过交道了: gl_Position 和 gl_FragCoord ,前一个是顶点着色器的输出向量,后一个是片段着色器的变量。 我们会讨论几个有趣的GLSL内建变量,并向你解释 ...
- 4关于gl_FragCoord的理解 - CSDN博客
记录一下在使用gl_FragCoord的一些知识点先上shader来看效果 ... void main() { vec2 uv = gl_FragCoord.xy/u_resolution; g...
- 5gl_FragCoord - OpenGL 4 Reference Pages - Khronos Group
Available only in the fragment language, gl_FragCoord is an input variable that contains the wind...