
Rectangular texture lookup in GLSL 1.2
Posted Wednesday, 2 May, 2012 - 16:46 by Norris inHi !
I try to learn more about shaders and post-processing under OpenGL 2 and GLSL.
So, I have learn to use a FrameBuffer and rendering a full-screen quad with the color texture
binded. This works fine; I can see my textured quad and now I try to add a simple shader to
access this texture.
I first tried to just change the "glFragColor" in my fragment shader just for checking that it's
working, that's ok.But I can't access the texels of the texture.The render is always black.
I tried to send the texture by uniform, without success.
This is my code in the Rendering method (sorry, this is VB):
'...setup for 3D rendering... '...code for "render to texture" in a fbo... '...setup for 2D rendering... GL.UseProgram(_MyShaderProg) Dim sceneTexLoc As Integer = GL.GetUniformLocation(_MyShaderProg, "sceneTexture") GL.ActiveTexture(TextureUnit.Texture0) GL.Uniform1(sceneTexLoc, 0) GL.BindTexture(TextureTarget.Texture2D, _FullScreenTex) DrawMesh2D(_PostProcQuad) GL.BindTexture(TextureTarget.Texture2D, 0) SwapBuffers()
and for the fragment shader:
#version 120 uniform sampler2D sceneTexture; void main(void) { vec3 color = vec3(1.0, 0.0, 0.0); vec2 uv = gl_TexCoord[0].xy; color = texture2D(sceneTexture, uv).rgb; gl_FragColor = vec4(color, 1.0); }
Because this is a full-screen texture, so, rectangular and NPOT, could it be a problem for texture lookup in a fragment shader with conventional commands ?
For the moment, I just try to show the texture like before, but without effect and via GLSL.
Thanks for your help !


Comments
Re: Rectangular texture lookup in GLSL 1.2
I got my error.
I just forgot to unbind my shader program after drawing. Sorry for that stupid post.