Danbias/Code/OysterGraphics/Shader/Passes/Light/PosManipulation.hlsli

23 lines
446 B
HLSL
Raw Normal View History

2014-01-08 07:01:59 +01:00
#ifndef PosHelper
#define PosHelper
#include "Defines.hlsli"
//assumes ProperfloatTexCoords
2014-01-08 07:01:59 +01:00
float3 ToVpos(int2 texCoord, float2 UV)
{
float4 ViewPos = float4(0,0,0,0);
// 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;
//Get Y/w
//ViewPos.y = -(UV.y * 2) + 1;
2014-01-08 07:01:59 +01:00
ViewPos.y = UV.y;
ViewPos.w = 1;
//Un project
ViewPos = mul(InvProj, ViewPos);
return ViewPos.xyz / ViewPos.w;
2014-01-08 07:01:59 +01:00
}
#endif