Set Up Screen-Space Quad

edited May 2014 in GLSL / Shaders

In order to perform render to texture (framebuffer) operations for post processing glow it is required to render to a quad that covers the entire screen ( OpenGL example and explanation: http://antongerdelan.net/opengl/framebuffers.html )... This is accomplished, according to their vertex shader sample, by passing the UNTRANSFORMED vertices, however this doesn't seem to work... any clues on how to do this particular step... Thanks in advance (PS also tried to use transformed too)

shader( m_shaderTexturedQuadFacing );
texture( graphicsFrameBuffer );
beginShape(TRIANGLE_STRIP);         
  vertex( -1.0,-1.0, 0.0, 0.0, 0.0 );
  vertex(  1.0,-1.0, 0.0, 1.0, 0.0 );
  vertex(  1.0, 1.0, 0.0, 1.0, 1.0 );
  vertex(  1.0, 1.0, 0.0, 1.0, 1.0 );
  vertex( -1.0, 1.0, 0.0, 0.0, 1.0 );
  vertex( -1.0,-1.0, 0.0, 0.0, 0.0 );
endShape();

vertex shaders:

#define PROCESSING_TEXLIGHT_SHADER

uniform mat4 transform;
uniform mat4 texMatrix;
uniform vec4 lightPosition;

attribute vec4 vertex;
attribute vec2 texCoord;

varying vec4 vertTexCoord;

void main()
{
  gl_Position = vertex;
  vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
}

frag shader:

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

uniform sampler2D texture;
varying vec4 vertTexCoord;

void main()
{
  gl_FragColor = texture2D(texture, vertTexCoord.st);
}
Sign In or Register to comment.