Jump to content

  • Log In with Google      Sign In   
  • Create Account

Trouble reading from depth-texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 mv348   Members   -  Reputation: 253

Like
0Likes
Like

Posted 28 July 2013 - 09:46 PM

In my last post I stated that I was having trouble with rendering to a depth texture. But I believe the following has demonstrated that the render to texture is successful and the issue is I can't read from the texture after the rendering is complete. 

 

I used glReadPixels to check if my depth texture is being cleared. I used the following after calling glClear:
 
glBindFramebuffer(GL_READ_FRAMEBUFFER,  m_fbo);
 
float depth;
glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
 
printf("depth value is %f",depth);
 
 
The print message outputs whatever clear depth I've set before calling glClear (with the fbo bound as the draw buffer), so I at least now know that the depth texture IS being written to. The problem is I just can't get my shaders to read from it! Here is where the texture is sampled:
 
 

float mapSample = (texture( gCascadedShadowMap, TexCoord).x);
 
FragColor =   vec4(mapSample,mapSample,mapSample,1);

 
 
I am well aware of the usual faintness of the depth-texture rendering, that's why I'm using glClear() with a depth value of around 0.5. I should be seeing a mid-gray screen when I render, but instead I just see blackness. If I set other textures to gCascadedShadowMap, however, it draws the texture to the screen correctly.
 
Any help or ideas would be greatly appreciated!

Edited by mv348, 28 July 2013 - 09:49 PM.


Sponsor:

#2 Rld_   Members   -  Reputation: 1519

Like
0Likes
Like

Posted 29 July 2013 - 03:56 AM

Are you actually binding the texture that is associated with your framebuffer?



#3 mv348   Members   -  Reputation: 253

Like
0Likes
Like

Posted 29 July 2013 - 10:17 PM

Yep! I set 7 as the active texture unit, bind the texture,and then set 7 as the value of the gCascadedShadowMap texture uniform.

 

I was hoping someone might now what possible things could 'block' the texture from being read from? Are their constraints on the bind states of the frame buffer objects? I've tried binding and unbinding the relevant frame buffers in various places, but I'm sure I've not exhausted the possibilities.



#4 WiredCat   Members   -  Reputation: 383

Like
0Likes
Like

Posted 02 August 2013 - 07:15 PM

provide the code


Edited by ___, 02 August 2013 - 07:16 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS