View Full Version : texture coordinates for full-screen effect
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?
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?
12-21-2006, 09:29 AM
no. let's say u_kTexture0 is the texture i rendered the scene to.
uniform sampler2D u_kTexture0;
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?
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
12-21-2006, 10:10 AM
oha so simple.. works thanks :) what counterparts?
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.