I have a depth texture and I'm trying to output the view space positions on the screen.
I'm using an orthographic camera. as you see there is a plane and a red mesh, what I get is a quad and I don't see the vertices in view positions in color.
here is the result
float3 position_in_view_space(float2 uv)
{
float z = depth_tex.SampleLevel(depth_sampler, uv, 0.0f).x;
// Get x/w and y/w from the viewport position
float x = uv.x * 2 - 1;
float y = (1 - uv.y) * 2 - 1;
float4 vProjectedPos = float4(x, y, z, 1.0f);
// Transform by the inverse projection matrix
float4 vPositionVS = mul(vProjectedPos, inv_proj);
// Divide by w to get the view-space position
return vPositionVS.xyz / vPositionVS.w;
}
float3 position_from =position_in_view_space(tex_coord.xy);
output.color = float4(position_from, 1.0);
return output;