2014-01-08 07:01:59 +01:00
|
|
|
#ifndef PosHelper
|
|
|
|
#define PosHelper
|
2013-12-05 14:56:34 +01:00
|
|
|
#include "Defines.hlsli"
|
|
|
|
|
|
|
|
//assumes ProperfloatTexCoords
|
2014-01-08 07:01:59 +01:00
|
|
|
float3 ToVpos(int2 texCoord, float2 UV)
|
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
|
2014-01-08 07:01:59 +01:00
|
|
|
ViewPos.x = UV.x;
|
2013-12-05 14:56:34 +01:00
|
|
|
//Get Y/w
|
2013-12-18 20:28:06 +01:00
|
|
|
//ViewPos.y = -(UV.y * 2) + 1;
|
2014-01-08 07:01:59 +01:00
|
|
|
ViewPos.y = UV.y;
|
2013-12-05 14:56:34 +01:00
|
|
|
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;
|
2014-01-08 07:01:59 +01:00
|
|
|
}
|
|
|
|
#endif
|