I'm running the tutorial 35 from olgdev.atspace.co.uk, and it's so strange that the result is a blank screen. This tutorial is performing the first step of Deferred Shading, which means decoupling of geometry calculations and lighting calclation. This process includes following steps.

  1. Bouding logical texture to Frame Buffer Object
  2. Rendering 1: Only writing vertex attributes to such textures.
  3. Rendering 2: Copy data from such textures, which included inside Frame Buffer Object onto the screen.

At the first step, I bound the texture to the Frame Buffer Object as following:

    // Create the FBO
glGenFramebuffers(1, &m_fbo);    
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);

// Create the buffer textures
glGenTextures(ARRAY_SIZE_IN_ELEMENTS(m_textures), m_textures);
glGenTextures(1, &m_depthTexture);
//Set up texture format and bound to FBO
for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures) ; i++) {
    glBindTexture(GL_TEXTURE_2D, m_textures[i]);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0);

// depth
glBindTexture(GL_TEXTURE_2D, m_depthTexture);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0);

GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, 
                         GL_COLOR_ATTACHMENT3 };
//Set such textures as the output receiver from Fragment Shader
glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers);

The next is rendering processing, including two main steps.

virtual void RenderSceneCB()

    DSGeometryPass(); //The first step ==> Only write vertex attributes to logical texture
    DSLightPass(); //The second: copy data from such textures to the screen.



At the first step, the fragment shader only pass on vertex attributes to the logical texture, which before bound to the Frame Buffer Object. This is the rendering code

void DSGeometryPass()



    Pipeline p;
    p.Scale(0.1f, 0.1f, 0.1f);
    p.Rotate(0.0f, m_scale, 0.0f);
    p.WorldPos(-0.8f, -1.0f, 12.0f);
    p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp());

And this is the shader code

struct FSOutput  //Fragment shader
    vec3 WorldSpacePos;    //which will be copied to position texture.
    vec3 Diffuse;          //which will be copied to diffuse texture.
    vec3 Normal;           //which will be copied to normal texture.
    vec3 TexCoord;         //which will be copied to texCoord texture.
shader FSmain(in VSOutput FSin, out FSOutput FSout)                                 
    FSout.WorldSpacePos = FSin.WorldSpacePos;                   
    FSout.Diffuse      = texture(gColorMap, FSin.TexCoord).xyz; 
    FSout.Normal       = normalize(FSin.Normal);                       
    FSout.TexCoord     = vec3(FSin.TexCoord, 0.0);              

Therefore, the results we got from Fragment Shader are four textures, which is then copied onto the screen and should be seen as following four texture
(source: atspace.co.uk)

However,the screen is going to blank. I used gDeDebugger for finding the values of such fours textures after Fragment Shader performed, and it shows that all of thems is blank. blank texture http://s10.postimg.org/y2dwd2h1j/texture.png My question is why the Fragment shader pass a blank input to the four textures? I hope to see your answer. Many Thanks!


1 Answer 1


Check if you have mipmaps enabled on the texture samplers ( GL_LINEAR_MIPMAP_LINEAR, etc ).

If the texture is incomplete (only 1 mipmap level is rendered to by the FBO at a time) and mipmaps are enabled on the sampler you'll get white textures.

  • Switch to GL_LINEAR or GL_NEAREST
  • set GL_TEXTURE_MAX_LEVEL​ to 0 so it only use the first mipmap (same as no mipmapping)
  • or call glGenerateMipmap after calling glBindTexture.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .