浏览代码

Make sure NdotV does not reach 0

/main
GitHub 8 年前
当前提交
27ac46fa
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 12
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl

12
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


float GetShiftedNdotV(inout float3 N, float3 V, bool twoSided)
{
float NdotV = dot(N, V);
if (!twoSided && NdotV < 0.0)
float limit = 1e-6;
if (!twoSided && NdotV < limit)
const float magic = 1e-5f;
// We do not renormalize the normal because { abs(length(N) - 1.0) < magic }.
N += (-NdotV + magic) * V;
NdotV = magic;
// We do not renormalize the normal because { abs(length(N) - 1.0) < limit }.
N += (-NdotV + limit) * V;
NdotV = limit;
}
return NdotV;

正在加载...
取消
保存