View Full Version : FBO and GLSL
08-31-2006, 04:24 AM
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....
08-31-2006, 09:02 AM
gl_FragCoord will return the texture coordinates you assigned to the vertex you're processing - as usual.
08-31-2006, 03:40 PM
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?
08-31-2006, 03:55 PM
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.
08-31-2006, 04:24 PM
d'oh i misread sry -.-
08-31-2006, 08:01 PM
Of course, using gl_FragCoord to get texture coordinates is usually not recommended, especially on previous generation hardware. Use an interpolator instead.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.