title: How can I get depth value from depth texture?
body: <p>I have complete-filled depth texture, but it seems not to get a proper value from it.</p>
  
  <p>GLSL code, fragment shader:</p>
  
  <pre><code>uniform sampler2D depth_tex;
  uniform float viewport_w;
  uniform float viewport_h;
  
  void main()
  {
      vec2 coord = vec2(gl_FragCoord.xy);
      float depth = texture2D(depth_tex, vec2(coord.x / viewport_w, coord.y / viewport.h)).r;
      float c = material_amb * depth; // material_amb is preset by host
      out_color = vec4(c, c, c, 1.0f);
  }
  </code></pre>
  
  <p>I expect model's color will be changed by vertices' depth, but I can't see everything. Of course, I can see model without multiplying depth. depth texture's type is GL_DEPTH_COMPONENT, GL_FLOAT. What's the problem? I think a solution to get a depth value from a texture is wrong, but I don't know the reason. Where is a depth value stored in? And How can I get a depth value?</p>