Hi! well, here’s another question… i’m trying to compute the fragment “position” from the depth (all in the fragment shader).
I have the depth texture (previously used as depth buffer in a FBO) i loaded as texture, so i’m trying to use that… i also have the screen size (ssize) and a texture that goes from 0 to 1 in both axis (gl_TexCoord[0]) in worldspace coordinates, so i tried to do: (in the fragment)
pos.z = -z_near - (depth * (z_far - z_near));
pos.x = (gl_TexCoord[0].s - 0.5) * 2.0 * viewport_size.x / z_near * -pos.z;
pos.y = (gl_TexCoord[0].t - 0.5) * 2.0 * viewport_size.y/ z_near * -pos.z;
however, this doesn’t seem to be working properly… is my understanding of the depth buffer wrong?