-
FBO and GLSL
Hi,
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....
Greetings,
Sebastian
-
Member
Regular Contributor
Re: FBO and GLSL
gl_FragCoord will return the texture coordinates you assigned to the vertex you're processing - as usual.
-
Senior Member
OpenGL Pro
Re: FBO and GLSL
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?
-
Re: FBO and GLSL
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.
-
Member
Regular Contributor
-
Senior Member
OpenGL Guru
Re: FBO and GLSL
Of course, using gl_FragCoord to get texture coordinates is usually not recommended, especially on previous generation hardware. Use an interpolator instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules