浏览代码

simplify zBuf to linear and prep for remaining simplifcation

simplify zBuf to linear and prep for remaining simplifcation
/main
mmikk 8 年前
当前提交
23c478d1
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. 12
      Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl

12
Assets/ScriptableRenderLoop/fptl/LightingUtils.hlsl


float GetLinearDepth(float zDptBufSpace) // 0 is near 1 is far
{
float3 vP = float3(0.0f,0.0f,zDptBufSpace);
float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
return v4Pres.z / v4Pres.w;
// todo (simplify): m22 is zero and m23 is +1/-1 (depends on left/right hand proj)
float m22 = g_mInvScrProjection[2].z, m23 = g_mInvScrProjection[2].w;
float m32 = g_mInvScrProjection[3].z, m33 = g_mInvScrProjection[3].w;
return (m22*zDptBufSpace+m23) / (m32*zDptBufSpace+m33);
//float3 vP = float3(0.0f,0.0f,zDptBufSpace);
//float4 v4Pres = mul(g_mInvScrProjection, float4(vP,1.0));
//return v4Pres.z / v4Pres.w;
}

正在加载...
取消
保存