Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: How can I use the texture in the framebuffer as the new texture?

  1. #11
    Junior Member Newbie
    Join Date
    Jun 2018
    Posts
    6
    I see what you mean, but I don't know how to do it.

    If I write
    Code :
    glUseProgram(shader_image_programme_HB);
    the shader's output must be written in the texture bound to the framebuffer right ? I did that in 5, so it must be written in "intermediateTexture".

    After that, I write
    Code :
    intermediateTexture = glGetUniformLocation(shader_image_programme_VB, "srcTex");
    glUniform1i(intermediateTexture, 1);

    But what about destinationTexture ? I can't do a sampler uniform for this texture

  2. #12
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,928
    Quote Originally Posted by PrevostP View Post
    If I write
    Code :
    glUseProgram(shader_image_programme_HB);
    the shader's output must be written in the texture bound to the framebuffer right ? I did that in 5, so it must be written in "intermediateTexture".
    That part is correct.

    Quote Originally Posted by PrevostP View Post
    After that, I write
    Code :
    intermediateTexture = glGetUniformLocation(shader_image_programme_VB, "srcTex");
    glUniform1i(intermediateTexture, 1);
    Part 6 was:
    Code :
    glUseProgram(shader_image_programme_HB);
    glUniform1i(intermediateTexture, 1);
    Which is affecting the HB shader, not the VB shader. The glUseProgram() is correct, but you don't need another glUniform() call. You've already set srcTex to the source texture in step 4, and the intermediate texture is attached to the framebuffer; it isn't accessed from the shader via a sampler uniform.

    Quote Originally Posted by PrevostP View Post
    But what about destinationTexture ? I can't do a sampler uniform for this texture
    The second pass works the same as the first pass, but with the textures "shifted" one place: the intermediate texture is bound to a texture unit and passed to the shader via a sampler uniform, the destination texture is attached to the framebuffer.

    The third pass is similar: the destination texture is bound to a texture unit and passed to the shader via a sampler uniform, the framebuffer is the default framebuffer (the window), not a framebuffer object. If you don't need the blurred image in a texture, the third pass could be omitted, i.e. you can perform the vertical blur from the intermediate texture directly to the window.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •