   depthbuffer and shader
  Hello,I need some help to understand this behavior.first I setglClearColor(1.0,1.0,1.0,0.0);glClearDepth(0.0);glEnable(GL_DEPTH_TEST);glDepthFunc(GL_GEQUAL);Then I draw a cube with backface culling into a texture.The fbo has a color texture at GL_COLOR_ATTACHMENT0 and adepth texture at GL_DEPTH_ATTACHMENT0fbo.bind();glPushAttrib(GL_VIEWPORT);glViewport(0,0,tex.width(), tex.height());glEnable(GL_CULL_FACE);glCullFace(GL_BACK);cube();fbo.unbind();glPopAttrib();In the shader I can do something like thisuniform sampler2D tex;uniform sampler2D depthtex;void main(void){ vec4 col = texture2D(tex, gl_TexCoord[0].xy); if(col.a != 0.0) {  col = 1.0-col; }}So far so good. Just a simple fragment shader that invertes the color whereeveralpha is not 0. That means in those areas where cube has been draw.As written above the clear colors alpha is set to 0 andthe clear depth is set to 0 as well. Actually that should meanwhere something is draw there is alpha greater than 0 and thedepth value is greater than 0.But If I want to do this here nothing happens.If I move the camera towards the cube and getting insidepart of cubes are clipped away by the nearplane as usual.So there the depth value should be zero. but it isnt.If I change if(depth == 0.0) to if(depth < 0.2) I can seea somepartes colored red but the clipped area isn colored.uniform sampler2D tex;uniform sampler2D depthtex;void main(void){ vec4 col = texture2D(tex, gl_TexCoord[0].xy); float depth = texture2D(depthtex, gl_TexCoord[0].xy); if(col.a != 0.0) {    if(depth == 0.0)    {  col = vec4(1.0,0.0,0.0,1.0);    } }}Why is it not working ?regards,c-mos   
  I'm sorry but I'm really trying to understand what your question is but I can not figure it out. Maybe a picture would help.Anyway one minor thing I see if(col.a != 0.0){col = 1.0-col;}I don't know if you have any alpha test or blending involved, but I'm not sure you really want to set alpha = 1.0 - alpha. You want to invert the colors, but you are inverting alpha as well. If your alpha is 1 it will turn to zero.   ;  Sorry, that my writing was not clear.Here's the next try. This shader was just for testing becauseI want another way backprojection clipped values by the nearplane.First of all, there is no alpha test and no blending enabled.Imagine you set glClearColor(1.0,1.0,1.0,0.0) andglClearDepth(0.0) and glDepthFunc(GL_GEQUAL).When you call glClear(GL_CLEAR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)then the "background" color is set to white with alpha 0and the depthbuffer values are set to 0 as well.Then when drawing a cube the area the cube covers causes alphavalues greater than 0 (here 1.0) and depth values greater than0.I rendered this to a texture. Then I draw a viewport quad andpass the color and depth textures to a shader. In the shader i can dovec4 col = texture2D(tex, gl_TexCoord[0].xy);if(col.a != 0.0){ ...}The if statemant asks for pixels alpha not 0. In my case that means wherethe cube has been drawn. This works because I tested it withif(col.a == 0.0){ gl_FragColor = 1.0-col;}That inverts the color of the background.But I cant do this if statement with depth values.if(depth == 0.0){...}Asking for zero depth values does not work. I need toknow where in the area that the cube covers are zero depth values.Because at this position, there is a hole in the cube. precisely said,this is the position where the nearplane cuts the cube when moving thecamera inside the cube.That's what I dont understand. The depthbuffer value has been initializedwith glDepthClear(0.0) and depth test has been set to glDepthFunc(GL_GEQUAL);So if the whole cube is inside the view frustum its depth values are not 0.But if a part of the cube is clipped by the nearplane then there is a holeand there should the depth values be 0.But I need to know the areas where this hole is for nearplane recunstructionfor kind of scientific rendering.regards,c-mos