浏览代码

Switch to node-centered sampling

/Branch_Batching2
Evgenii Golubev 7 年前
当前提交
898504c3
共有 1 个文件被更改,包括 9 次插入16 次删除
  1. 25
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs

25
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringProfile.cs


}
// Apply the three-sigma rule, and rescale.
// Increase the value a bit due to our (low) number of samples.
Color stdDev1 = ((1.0f / 3.0f) * (1.0f / 0.8f) * distanceScale) * scatterDistance1;
Color stdDev2 = ((1.0f / 3.0f) * (1.0f / 0.8f) * distanceScale) * scatterDistance2;
Color stdDev1 = ((1.0f / 3.0f) * distanceScale) * scatterDistance1;
Color stdDev2 = ((1.0f / 3.0f) * distanceScale) * scatterDistance2;
// Our goal is to blur the image using a filter which is represented
// as a product of a linear combination of two normalized 1D Gaussians

Vector3 weightSum = new Vector3(0, 0, 0);
int numSamplesPlus2 = numSamples + 2;
float step = 1.0f / (numSamplesPlus2 - 1);
float step = 1.0f / (numSamples - 1);
for (int i = 0, s = 0; s < numSamplesPlus2; s++)
for (int i = 0; i < numSamples; i++)
// Skip the leftmost and the rightmost samples due to the low weight.
if (s == numSamplesPlus2 / 2 || s == numSamplesPlus2 - 1) continue;
// Generate 'u' on (0, 0.5] and (0.5, 1).
float u = (i <= numSamples / 2) ? 0.5f - i * step // The center and to the left
: i * step; // From the center to the right
// Generate 'u' on (0, 0.5] and (0.5, 1).
float u = (s < numSamplesPlus2 / 2) ? 0.5f - s * step // The center and to the left
: s * step; // From the center to the right
u = Mathf.Clamp(u, 0.001f, 0.999f);
float pos = GaussianCombinationCdfInverse(u, maxStdDev1, maxStdDev2, lerpWeight);
float pdf = GaussianCombination(pos, maxStdDev1, maxStdDev2, lerpWeight);

weightSum.x += m_FilterKernel[i].x;
weightSum.y += m_FilterKernel[i].y;
weightSum.z += m_FilterKernel[i].z;
i++;
}
// Renormalize the weights to conserve energy.

}
// Apply the three-sigma rule, and rescale.
// Increase the value a bit due to our (low) number of samples.
float s = (1.0f / 3.0f) * (1.0f / 0.8f) * SubsurfaceScatteringProfile.distanceScale;
float s = (1.0f / 3.0f) * SubsurfaceScatteringProfile.distanceScale;
Vector4 stdDev1 = new Vector4(s * m_ScatterDistance1.colorValue.r, s * m_ScatterDistance1.colorValue.g, s * m_ScatterDistance1.colorValue.b);
Vector4 stdDev2 = new Vector4(s * m_ScatterDistance2.colorValue.r, s * m_ScatterDistance2.colorValue.g, s * m_ScatterDistance2.colorValue.b);
Vector4 tintCol = new Vector4(m_TintColor.colorValue.r, m_TintColor.colorValue.g, m_TintColor.colorValue.b);

正在加载...
取消
保存