浏览代码

Reduce SSS artifacts

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
92b0ced1
共有 2 个文件被更改,包括 24 次插入3 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  2. 25
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


// In theory, we should modify the thickness by the inverse of the radius scale of the profile.
// thickness /= radiusScale;
float3 expOneThird = exp((-thickness * (1.0 / 3.0)) * S);
float3 expOneThird = exp(((-1.0 / 3.0) * thickness) * S);
return 0.5 * (expOneThird + expOneThird * expOneThird * expOneThird) * surfaceAlbedo;
}

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


// N.b.: the returned value is multiplied by 4. It is irrelevant due to weight renormalization.
float3 KernelValCircle(float r, float3 S)
{
float3 expOneThird = exp((-r * (1.0 / 3.0)) * S);
float3 expOneThird = exp(((-1.0 / 3.0) * r) * S);
return /* 0.25 * */ S * (expOneThird + expOneThird * expOneThird * expOneThird);
}

// Perform integration over the screen-aligned plane in the view space.
// TODO: it would be more accurate to use the tangent plane in the world space.
int invalidSampleCount = 0;
[unroll]
for (uint i = 1; i < SSS_N_SAMPLES_NEAR_FIELD; i++)
{

sampleIrradiance = LOAD_TEXTURE2D(_IrradianceSource, samplePosition).rgb;
[flatten]
if (rawDepth == 0)
{
// Our sample comes from a region without any geometry.
invalidSampleCount++;
continue;
}
[flatten]
if (any(sampleIrradiance) == false)
{
// The irradiance is 0. This could happen for 2 reasons.

// We do not terminate the loop since we want to gather the contribution
// of the remaining samples (e.g. in case of hair covering skin).
invalidSampleCount++;
continue;
}

totalWeight += sampleWeight;
}
[branch]
if (invalidSampleCount > SSS_N_SAMPLES_NEAR_FIELD / 2)
{
// Do not blur.
samplePosition = posInput.unPositionSS;
sampleIrradiance = LOAD_TEXTURE2D(_IrradianceSource, samplePosition).rgb;
return float4(bsdfData.diffuseColor * sampleIrradiance, 1);
}
return float4(0, 0, 0, 0); // TODO
return float4(0, 0, 0, 1); // TODO
}
}
ENDHLSL

正在加载...
取消
保存