Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
What is the range of
gl_FragCoord.xy
? I know
gl_FragCoord
s are screen coordinates but what is the actual range?
( 0, width - 1 )
or
( 1, width )
? And what kind of error (if any) would glsl compiler generate say I did something like
gl_FragCoord.x - 5
when i do some fragcoord based calculation?
ps: I don't need normalization.
–
I did a test to the actual range of
gl_FragCoord.xy
, by using the following shader code and
glReadPixels(0, 0, 1024, 1024, GL_RED, GL_FLOAT, xxx)
to get the output of the shader from my framebuffer object, and the FBO had attached a texture which's internal format is
GL_R32F
.
out highp vec4 Output;
void main()
Output = vec4(gl_FragCoord.xy, 0.0, 1.0);
The actual result is: gl_FragCoord.xy is in the range [0.5, 1023.5], not [0.0, 1023.0].
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.