depth:
Code:
//Vertex Shader:
Output.Position = mul(inPos, matWorldViewProj);
Output.Position2D = Output.Position;

//Pixel Shader
depth = ((PSIn.Position2D.z-0)/maxDepth); //maxdepth = camera.clip_far



reconstruct world space position from depth:
Code:
float4x4 matMtl : matWorldViewProjInv;

//Pixel Shader
   //compute world position
   float4 vp = float4(inTex.xy * float2(2, -2) - float2(1, -1), depth, 1);
   float4 v = mul(vp, matMtl);
   float3 position = v.xyz/v.w;
	
   //calculate ROUGH normals from position
   float3 normal = cross(ddx(position),ddy(position));



might not be the fastest method, but works just fine laugh


Shade-C EVO Lite-C Shader Framework