浏览代码

Add an SSS_CLAMP_BLEED option

/RenderPassXR_Sandbox
Evgenii Golubev 7 年前
当前提交
288c9b13
共有 1 个文件被更改,包括 14 次插入13 次删除
  1. 27
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader

27
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader


#define SSS_PASS 1
#define SSS_BILATERAL 1
#define SSS_DEBUG 0
#define SSS_CLAMP_BLEED 0
#define SSS_DEBUG 0
#define MILLIMETERS_PER_METER 1000
#ifdef SSS_MODEL_BASIC
#define CENTIMETERS_PER_METER 100

return /* 0.25 * */ S * (expOneThird + expOneThird * expOneThird * expOneThird);
}
// Computes F(x)/P(x), s.t. x = sqrt(r^2 + t^2).
float3 ComputeBilateralWeight(float3 S, float r, float t, float rcpPdf)
// Computes F(x)/P(x). Rescaling of the PDF is handled by 'totalWeight'.
float3 ComputeBilateralWeight(float r, float3 S, float rcpPdf)
#if (SSS_BILATERAL == 0)
t = 0;
#if SSS_CLAMP_BLEED
return saturate(KernelValCircle(r, S) * rcpPdf);
#else
return KernelValCircle(r, S) * rcpPdf;
float3 val = KernelValCircle(sqrt(r * r + t * t), S);
// Rescaling of the PDF is handled by 'totalWeight'.
return val * rcpPdf;
}
#define SSS_ITER(i, n, kernel, profileID, shapeParam, centerPosUnSS, centerDepthVS, \

float d = LinearEyeDepth(z, _ZBufferParams); \
float t = millimPerUnit * d - (millimPerUnit * centerDepthVS); \
float p = kernel[profileID][i][1]; \
float3 w = ComputeBilateralWeight(shapeParam, r, t, p); \
float3 w = ComputeBilateralWeight(sqrt(r * r + t * t), shapeParam, p); \
\
totalIrradiance += w * irradiance; \
totalWeight += w; \

UpdatePositionInput(centerDepth, _InvViewProjMatrix, _ViewProjMatrix, posInput);
// Compute the disk tangential to the surface.
// Compute the disk tangential to the surface.
float3x3 basisVS = GetLocalFrame(normalVS);
float3 tangentX = basisVS[0] * rcp(millimPerUnit);
float3 tangentY = basisVS[1] * rcp(millimPerUnit);

float3 x = millimPerUnit * length(relPosVS + float3(0, 0, t));
float p = _FilterKernelsNearField[profileID][i][1];
float3 w = KernelValCircle(x, shapeParam) * p;
float3 w = ComputeBilateralWeight(x, shapeParam, p);
float3 w = KernelValCircle(r, shapeParam) * p;
float3 w = ComputeBilateralWeight(r, shapeParam, p);
#endif
totalIrradiance += w * irradiance;

正在加载...
取消
保存