   [DirectX 10] Reconstructing pixel position
  I'm implementing the light pre pass and it works ok with directional lights but I'm pretty sure that the pixel position isnt being reconstructed the right way because my box is in position [0.0f, 0.0f, 0.0f] and after position reconstruction I get positions of [125071.539f, -69786.188f, -72.659f, 0.008f]This is how I create the GBuffer:cbuffer cbPerObject{float4x4 gWorld;float4x4 gWVP; };Texture2D gSpecMap;Texture2D gNormalMap;SamplerState gTriLinearSam{Filter = MIN_MAG_MIP_LINEAR;AddressU = Wrap;    AddressV = Wrap;};struct VS_IN{float3 posL: POSITION;float3 tangentL : TANGENT;float3 normalL  : NORMAL;float2 texC: TEXCOORD;};struct VS_OUT{float4 posH: SV_POSITION;float3 tangentW : TEXCOORD0;   float3 normalW  : TEXCOORD1;   float2 texC: TEXCOORD2;float2 depth    : TEXCOORD3;};struct PS_OUT{float4 normal : SV_TARGET0;float4 depth  : SV_TARGET1;};VS_OUT VS(VS_IN vIn){VS_OUT vOut;vOut.tangentW = mul(float4(vIn.tangentL, 0.0f), gWorld);vOut.normalW = mul(float4(vIn.normalL, 0.0f), gWorld);// Transform to homogeneous clip space.vOut.posH = mul(float4(vIn.posL, 1.0f), gWVP);// Output vertex attributes for interpolation across triangle.vOut.texC  = float4(vIn.texC, 0.0f, 1.0f);vOut.depth.x = vOut.posH.z;vOut.depth.y = vOut.posH.w;return vOut;}PS_OUT PS(VS_OUT pIn){PS_OUT pOut;float4 spec    = gSpecMap.Sample( gTriLinearSam, pIn.texC );float3 normalT = gNormalMap.Sample( gTriLinearSam, pIn.texC );// Map [0,1] --> [0,256]spec.a *= 256.0f;float specPower  = max(spec.a, 10.0f);normalT = 2.0f*normalT - 1.0f;// build orthonormal basisfloat3 N = normalize(pIn.normalW);float3 T = normalize(pIn.tangentW - dot(pIn.tangentW, N)*N);float3 B = cross(N,T);float3x3 TBN = float3x3(T, B, N);float3 bumpedNormalW = normalize(mul(normalT, TBN));  pOut.normal.rgb = 0.5f * (normalize(bumpedNormalW) + 1.0f);pOut.normal.a = specPower;pOut.depth = pIn.depth.x / pIn.depth.y;return pOut;}technique10 GBufferTech{    pass P0    {   SetVertexShader( CompileShader( vs_4_0, VS() ) );   SetGeometryShader( NULL );   SetPixelShader( CompileShader( ps_4_0, PS() ) );    }}This is how I create the Light Buffer (reconstruct position):#include "Lighting.fx"cbuffer cbPerFrame{float3 gEyePosW;float4x4 gInvViewProj;Light gLight;int gLightType;}//normal map with specular powerTexture2DMS<float4,8> gNormalMap;Texture2DMS<float4,8> gDepthMap;struct VS_IN{float3 posL : POSITION;float2 texC : TEXCOORD;};struct VS_OUT{float4 posH  : SV_POSITION;float2 texC  : TEXCOORD0;};VS_OUT VS(VS_IN vIn){VS_OUT vOut;vOut.posH = float4(vIn.posL, 1.0f);vOut.texC = vIn.texC;return vOut;}float4 PS(VS_OUT pIn) : SV_TARGET{float4 normalData = gNormalMap.Load(pIn.posH.xy, 0);float3 normal = 2.0f * normalize(normalData.xyz) - 1.0f;float4 specPower = float4(0.0f,0.0f,0.0f,0.0f);specPower.a = normalData.a * 255.0f;float depth = gDepthMap.Load(pIn.posH.xy, 0).r;float4 position = float4(0.0f,0.0f,depth,1.0f);position.x = pIn.posH.x * 2.0f - 1.0f;position.y = -(pIn.posH.y * 2.0f - 1.0f);//position.z = depth;//position.w = 1.0f;position = mul(position, gInvViewProj);position /= position.w;Surface v = {position, normal, specPower};float4 litColor;if(gLightType == 0){   litColor = ParallelLight(v, gLight, gEyePosW);}return litColor;}technique10 LightBufferTech{    pass P0    {   SetVertexShader( CompileShader( vs_4_0, VS() ) );   SetGeometryShader( NULL );   SetPixelShader( CompileShader( ps_4_0, PS() ) );    }}
  We had a thread on this general topic yesterday, here.   ;  I know, but I still cant get it working...   ;  Me, too. I can do it in ViewSpace (I think...), but then I have two problems:How do I calculate Lights from there?orHow to put it into world space?Must be the LightPosition also in ViewSpace? And if so, how do I do that? Just multiply it with the ViewMatrix? Or what?   