浏览代码

Use per-pixel SSS radius scale

/main
Evgenii Golubev 8 年前
当前提交
20a45ba0
共有 4 个文件被更改,包括 14 次插入12 次删除
  1. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  2. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
  3. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
  4. 17
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader

1
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


m_CombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale);
// TODO: use user-defined values for '_ProfileID' and '_FilterRadius.'
m_CombineSubsurfaceScattering.SetVectorArray("_FilterKernel", sssParameters.profiles[0].filterKernel);
m_CombineSubsurfaceScattering.SetFloat("_FilterRadius", 3.0f);
MaterialPropertyBlock properties = new MaterialPropertyBlock();

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader


[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2)] _MaterialID("Material Class", Int) = 0
_SubsurfaceProfile("Subsurface Profile", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0.5
_Thickness("Thickness", Range(0.0, 1.0)) = 0
_Thickness("Thickness", Range(0.0, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0

4
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader


[Enum(Standard, 0, Subsurface Scattering, 1, Clear Coat, 2)] _MaterialID("Material Class", Int) = 0
_SubsurfaceProfile("Subsurface Profile", Int) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0
_SubsurfaceRadius("Subsurface Radius", Range(0.0, 1.0)) = 0.5
_Thickness("Thickness", Range(0.0, 1.0)) = 0
_Thickness("Thickness", Range(0.0, 1.0)) = 0.5
_ThicknessMap("Thickness Map", 2D) = "white" {}
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0

17
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader


float _DistToProjWindow; // The height of the projection window is 2 meters
float _FilterHorizontal; // Vertical = 0, horizontal = 1
float4 _FilterKernel[7]; // RGB = weights, A = radial distance
float _FilterRadius; // Uses world-space units
TEXTURE2D(_GBufferTexture2);
TEXTURE2D(_IrradianceSource);
SAMPLER2D(sampler_IrradianceSource);

{
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);
float rawDepth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r;
float centerDepth = LinearEyeDepth(rawDepth, _ZBufferParams);
float radiusScale = _FilterRadius * _DistToProjWindow / centerDepth;
float rawDepth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).r;
float centerDepth = LinearEyeDepth(rawDepth, _ZBufferParams);
float radiusScale = LOAD_TEXTURE2D(_GBufferTexture2, posInput.unPositionSS).r;
float filterRadius = radiusScale * _DistToProjWindow / centerDepth;
float2 unitDirection = _FilterHorizontal ? float2(1, 0) : float2(0, 1);
float2 scaledDirection = radiusScale * unitDirection;
float x, y;
sincos(PI / 3, y, x);
float2 unitDirection = _FilterHorizontal ? float2(x, y) : float2(-y, x);
float2 scaledDirection = filterRadius * unitDirection;
// Premultiply with the inverse of the screen size.
scaledDirection *= _ScreenSize.zw;

// Apply bilateral filtering.
float sampleDepth = LinearEyeDepth(rawDepth, _ZBufferParams);
float depthDiff = abs(sampleDepth - centerDepth);
float scaleDiff = _BilateralScale * _FilterRadius * _DistToProjWindow;
float scaleDiff = radiusScale * _DistToProjWindow * _BilateralScale;
float t = saturate(depthDiff / scaleDiff);
// TODO: use real-world distances for weighting.

正在加载...
取消
保存