If I use the formula that wolframalpha gives, it gives us a closer result then we were getting before but the position is still off by a bit. I debugged a pixel in PIX and the position came out to (101.089287, 618.003845, -55.915211, -105.442390). Our blocks are 10 units big. The pixel I was debugging should have had a value close to (0, 600, 0). The Y axis (our up axis) is pretty close, but the other 2 are off by a bit.
This is how the log depth is encoded in the gbuffer:
output.Position.z = log(0.001 * output.Position.z + 1) / log(0.001 * FarPlane + 1) * output.Position.w;
The vertex shader of the point light also adjusts the light's z position in the same way. And this is how the position is reconstructed in the light:
input.ScreenPosition.xy /= input.ScreenPosition.w;
float2 texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);
//read depth
float depthVal = DepthMap.Sample(depthSampler, texCoord).r;
depthVal = (pow(0.001 * FarPlane + 1, depthVal) - 1) / 0.001;
//Compute screen-space position
float4 position = float4(input.ScreenPosition.xy, depthVal, 1.0f);
// transform to world space
position = mul(position, InvertViewProjection);
position /= position.w;
Every time I debug a pixel, the attenuation always equals 0 since the position it calculates is out of the lights range. This is what it ends up looking like: