浏览代码

Use lerp(max1, max2) to determine the radius rather than the average

/main
Evgenii Golubev 8 年前
当前提交
061001e0
共有 1 个文件被更改,包括 4 次插入10 次删除
  1. 14
      Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs

14
Assets/ScriptableRenderLoop/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs


// For now, we use an ad-hoc approach.
// We truncate the distribution at the radius of 3 standard deviations.
float averageRadius1 = Mathf.Sqrt(m_filter1Variance.r)
+ Mathf.Sqrt(m_filter1Variance.g)
+ Mathf.Sqrt(m_filter1Variance.b);
float averageRadius2 = Mathf.Sqrt(m_filter2Variance.r)
+ Mathf.Sqrt(m_filter2Variance.g)
+ Mathf.Sqrt(m_filter2Variance.b);
float radius = Mathf.Lerp(averageRadius1, averageRadius2, m_filterLerpWeight);
float maxRadius1 = 3 * Mathf.Sqrt(Mathf.Max(m_filter1Variance.r, m_filter1Variance.g, m_filter1Variance.b));
float maxRadius2 = 3 * Mathf.Sqrt(Mathf.Max(m_filter2Variance.r, m_filter2Variance.g, m_filter2Variance.b));
float radius = Mathf.Lerp(maxRadius1, maxRadius2, m_filterLerpWeight);
// The formula for the interval [a, b] is given here:
// https://en.wikipedia.org/wiki/Gaussian_quadrature#Change_of_interval
// Ref: http://keisan.casio.com/exec/system/1329114617
float[] unitAbscissae = { 0.0f, 0.40584515f, -0.40584515f, 0.74153118f, -0.74153118f, 0.94910791f, -0.94910791f };
float[] unitWeights = { 0.41795918f, 0.38183005f, 0.38183005f, 0.27970539f, 0.27970539f, 0.12948496f, 0.12948496f };

for (int i = 0; i < numSamples; ++i)
{
// Perform the change of interval: {a, b} = {-radius, radius}.
// Ref: https://en.wikipedia.org/wiki/Gaussian_quadrature#Change_of_interval
float weight = radius * unitWeights[i];
float position = radius * unitAbscissae[i];

正在加载...
取消
保存