PDA

View Full Version : texture coordinates for full-screen effect



Vexator
12-21-2006, 07:24 AM
when rendering full-screen effects, one usually renders the effect to a texture and then blends a full-screen quad with this texture applied over the scene. for an effect i'm working on atm, i'd prefer to use this texture in a shader directly instead.. but how would i compute the texture coordinates most efficiently for each fragment then?

.. thanks!

Mars_999
12-21-2006, 08:50 AM
If I understand you correctly, you want to render a RTT to a quad on the screen? If its a single quad why wouldn't it be 0-1 coordinates?

Vexator
12-21-2006, 09:29 AM
no. let's say u_kTexture0 is the texture i rendered the scene to.


uniform sampler2D u_kTexture0;

void main()
{
vec2 kCoordinates = ???;

gl_FragColor = texture2D( u_kTexture0, kCoordinates )
}how would i have to calculate kCoordinates so that the output is the same as if i had rendered a full-screen quad with the texture applied?

Nicolas Lelong
12-21-2006, 09:38 AM
vec2 kCoordinates = 0.5 * (gl_FragCoord.xy + vec2(1.0));should do the trick, even if it has some objectionable counterparts

Vexator
12-21-2006, 10:10 AM
oha so simple.. works thanks :) what counterparts?