0

I am using OpenGL 4.0, formerly was using 3.3 I have a fragment shader with 3 outputs -each one is vec3 .I am writing these outputs to some FBO then trying to test the content using The glBlitFramebuffer() method.I am getting the empty screen.Now ,I figured out that setting the outputs to be of vec4 type works correctly.I don't understand why! My FBO textures are set to RGB32F so they should be able to accept vec3 from fragments. Here is my FBO setup (That is Java LWJGL wrapper but it doesn't matter here):

    _fbo = glGenFramebuffers();
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);


    glGenTextures(m_textures);
    _depthTexture = glGenTextures();


   for (int i = 0; i < GBUFFER_NUM_TEXTURES; i++) {


        glBindTexture(GL_TEXTURE_2D, m_textures.get(i));//
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, height, 0, GL_RGB, GL_FLOAT, (ByteBuffer) null);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i , GL_TEXTURE_2D,m_textures.get(i), 0);//

    }

    // depth
    glBindTexture(GL_TEXTURE_2D, _depthTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer) null);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _depthTexture, 0);





    DrawBuffers = BufferUtils.createIntBuffer(GBUFFER_NUM_TEXTURES);

      DrawBuffers.put(0, GL_COLOR_ATTACHMENT0);
      DrawBuffers.put(1, GL_COLOR_ATTACHMENT1);
      DrawBuffers.put(2, GL_COLOR_ATTACHMENT2);



     glDrawBuffers(DrawBuffers);
ZnArK
  • 1,533
  • 1
  • 12
  • 23
Michael IV
  • 11,016
  • 12
  • 92
  • 223

0 Answers0