just a short question, because I found lots of different oppinions about it.
When rendering to a FBO texture, can I use gl_FragCoord in my Fragment Shader to get the x and y pixel screencoordinate? (FBO texture is same size as OpenGL-Window)
I heard about that it should give unpredictable results…
gl_FragCoord will return the texture coordinates you assigned to the vertex you’re processing - as usual.
Since when gl_FragCoord return texture coordinates? oO
I thought it will return window-space coordinates, actually (I would still prefer the device-independent coordinates). No idea how it works with FBO, why won’t you try it out?
gl_FragCoord returns the pixel position of a fragment even with FBO’s. In order to turn this into a normalized texture coordinate you would need to divide by the dimensions of the screen aligned quad you rendered (if that’s how you generated fragments). It doesn’t sound like you care about that though.
Of course, using gl_FragCoord to get texture coordinates is usually not recommended, especially on previous generation hardware. Use an interpolator instead.