
FBO to texture to Shader - Twice
Posted Monday, 14 June, 2010 - 00:34 by szamil inHi,
I have trubble with sending more than two texture to the fragment shader. I have something like this:
private void Render()//Render! { //..some sets GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, textureId1); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, textureId2); //enable shader GL.UseProgram(shader_program_pass2); GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, fboId1); GL.PushAttrib(AttribMask.ViewportBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //draw something GL.Uniform1(GL.GetUniformLocation(shader_program_pass1, "text0"), 0); GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, fboId2); GL.PushAttrib(AttribMask.ViewportBit); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //draw something again GL.Uniform1(GL.GetUniformLocation(shader_program_pass1, "text1"), 1); GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); GL.UseProgram(shader_program_pass1); //draw using shader with textures GL.UseProgram(0); //draw with no shader //swap glControl.SwapBuffers(); }
Please. help!
Thanks.


Comments
Re: FBO to texture to Shader - Twice
Are you getting an error? How does the rendering differ from what you expected?
Try using the debug version of OpenTK.dll, which will inform you of any OpenGL errors as soon as they happen.
It would also help if you posted the shader source.
Re: FBO to texture to Shader - Twice
Thanks for reply!
What I get is exactly the same textures in both samplers. Sorry for not mention it before. Shaders are as simple as they can be. They map textures from samplers on cube.
Re: FBO to texture to Shader - Twice
You are binding pass2 but querying the uniforms for pass1. Doesn't look right.
Re: FBO to texture to Shader - Twice
Its ok, I use one shader to render the texture, then another to work on this texure and mapping. Pass1 is about to work on textures, pass2 is to produce these textures...
Or maybe I cannot work simultonously on two shaders?
Re: FBO to texture to Shader - Twice
You can only work with a single shader at a time:
GL.Uniform*()affects the program that is currently bound withGL.UseProgram().In other words, you need to bind pass1 before changing its uniforms (and then bind pass2 if you wish to render with that).
Re: FBO to texture to Shader - Twice
Yeah, that is working now! Thank you very much!
Now I switch shader with
GL.UseProgram()before I pass the texture to shader, and after IGL.Uniform*()I switch back. I'll make it more clear (one FBO, one switch at the end) and post it here.Again thanks for help. I am really appreciate!
Re: FBO to texture to Shader - Twice
You are welcome. :)