hello,

i´m having this problem for quite some time, i want to be able to get a valid world coordinate from a sample pixel from the depth texture in the fragment shader, i´m rendering the geometry throught 3 textures : normal, difuse and depth.

I just wanted to be able some how to “test” if i´m doing the right calculations to see if in fact the position is “true”.

I´ll post the vertex shader and the pixel shader, but right now i get nothing but a black screen if i try to “see any world space position” maybe i´m doing something really wrong…

Vertex Shader:

```
varying vec2 TexCoord;
varying vec4 Position;
void main()
{
gl_Position = ftransform();
TexCoord = vec2(gl_MultiTexCoord0);
Position = gl_Position;
}
```

Fragment Shader:

```
uniform sampler2D NormalTex;
uniform sampler2D DiffuseTex;
uniform sampler2D DepthTex;
uniform mat4 ModelViewInv;
uniform mat4 ProjInv;
varying vec2 TexCoord;
varying vec4 Position;
void main()
{
vec4 viewport = vec4(0,0,512,512);
vec2 Cam = vec2(1.0,325.0);
vec4 normal = texture2D(NormalTex,TexCoord);
vec4 difuse = texture2D(DiffuseTex,TexCoord);
float depth = texture2D(DepthTex,TexCoord).r;
//compute screen-space position
vec4 position;
position.x = TexCoord.x * 2.0 - 1.0;
position.y = -TexCoord.x * 2.0 - 1.0;
position.z = depth;
position.w = 1.0;
//transform to world space
position = position * ModelViewInv * ProjInv;
position /= position.w;
gl_FragData[0] = difuse * normal * position;
}
```