浏览代码

Fix a subtle line light bug

/main
Evgenii Golubev 8 年前
当前提交
ccc496ee
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 10
      Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl

10
Assets/ScriptableRenderLoop/ShaderLibrary/AreaLighting.hlsl


float tLDDL2 = l2rcpD / (d * d + l2 * l2);
float intWt = LineFwt(tLDDL2, l2) - LineFwt(tLDDL1, l1);
float intP0 = LineFpo(tLDDL2, l2rcpD, rcp(d)) - LineFpo(tLDDL1, l1rcpD, rcp(d));
// Guard against numerical precision issues.
return max(intP0 * normal.z + intWt * tangent.z, 0.0);
return intP0 * normal.z + intWt * tangent.z;
}
// Computes 1.0 / length(mul(ortho, transpose(inverse(invM)))).

float width = ComputeLineWidthFactor(invM, B);
if (P2.z <= 0.0)
if (P1.z > P2.z)
// Convention: 'P2' is above the horizon.
// Convention: 'P2' is above 'P1', with the tangent pointing upwards.
Swap(P1, P2);
}

// Integrate the clamped cosine over the line segment.
float irradiance = LineIrradiance(l1, l2, P0, T);
return INV_PI * width * irradiance;
// Guard against numerical precision issues.
return max(INV_PI * width * irradiance, 0.0);
}
#endif // UNITY_AREA_LIGHTING_INCLUDED
正在加载...
取消
保存