2013-12-05 14:56:34 +01:00
|
|
|
#include "Defines.hlsli"
|
|
|
|
|
|
|
|
//assumes ProperfloatTexCoords
|
|
|
|
float3 ToVpos(float2 texCoord)
|
|
|
|
{
|
|
|
|
//Get proper UV
|
2013-12-18 20:28:06 +01:00
|
|
|
float2 UV = texCoord / Pixels;
|
2013-12-05 14:56:34 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
float4 ViewPos = float4(0,0,0,0);
|
2013-12-05 14:56:34 +01:00
|
|
|
// Get the depth value for this pixel
|
|
|
|
ViewPos.z= DepthTexture[texCoord].x;
|
|
|
|
//Get X/w
|
|
|
|
ViewPos.x = UV.x * 2 - 1;
|
|
|
|
//Get Y/w
|
2013-12-18 20:28:06 +01:00
|
|
|
//ViewPos.y = -(UV.y * 2) + 1;
|
2013-12-05 14:56:34 +01:00
|
|
|
ViewPos.y = 1 - 2 * UV.y;
|
|
|
|
ViewPos.w = 1;
|
|
|
|
|
|
|
|
//Un project
|
2013-12-18 20:28:06 +01:00
|
|
|
ViewPos = mul(InvProj, ViewPos);
|
2013-12-05 14:56:34 +01:00
|
|
|
return ViewPos.xyz / ViewPos.w;
|
|
|
|
}
|