浏览代码

Add temporal integration support to the Disney SSS

/feature-ReflectionProbeFit
Evgenii Golubev 7 年前
当前提交
5da18693
共有 4 个文件被更改,包括 21 次插入2 次删除
  1. 12
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs
  2. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDStringConstants.cs
  3. 7
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl

12
ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs


public Plane[] frustumPlanes;
public Vector4[] frustumPlaneEquations;
public Camera camera;
public uint taaFrameIndex;
public PostProcessRenderContext postprocessRenderContext;
public Matrix4x4 viewProjMatrix

}
isFirstFrame = false;
const uint taaFrameCount = 8;
taaFrameIndex = taaEnabled ? (uint)Time.renderedFrameCount % taaFrameCount : 0;
}
else
{
// Warning: in the Game View, outside of the Play Mode, the counter gets stuck on a random frame.
// In this case, reset the frame index to 0.
taaFrameIndex = 0;
}
viewMatrix = gpuView;

cmd.SetGlobalVector(HDShaderIDs._ScreenSize, screenSize);
cmd.SetGlobalMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix);
cmd.SetGlobalVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations);
cmd.SetGlobalInt(HDShaderIDs._TaaFrameIndex, (int)taaFrameIndex);
}
// Does not modify global settings. Used for shadows, low res. rendering, etc.

material.SetVector(HDShaderIDs._ScreenSize, screenSize);
material.SetMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix);
material.SetVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations);
material.SetInt(HDShaderIDs._TaaFrameIndex, (int)taaFrameIndex);
}
// TODO: We should set all the value below globally and not let it under the control of Unity,

1
ScriptableRenderPipeline/HDRenderPipeline/HDStringConstants.cs


public static readonly int _ScreenSize = Shader.PropertyToID("_ScreenSize");
public static readonly int _PrevViewProjMatrix = Shader.PropertyToID("_PrevViewProjMatrix");
public static readonly int _FrustumPlanes = Shader.PropertyToID("_FrustumPlanes");
public static readonly int _TaaFrameIndex = Shader.PropertyToID("_TaaFrameIndex");
public static readonly int _DepthTexture = Shader.PropertyToID("_DepthTexture");
public static readonly int _CameraColorTexture = Shader.PropertyToID("_CameraColorTexture");

7
ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute


// Tweak parameters.
#define SSS_BILATERAL_FILTER 1
#define SSS_USE_LDS_CACHE 1
#define SSS_TAA_INTEGRATION 1 // Smoother results at the cost of a tiny amount of flickering in under-sampled areas
#define SSS_ENABLE_NEAR_FIELD 0 // Greatly increases the number of samples. Comes at a high cost.
#define SSS_SAMPLE_TEST_HTILE 0 // Potential optimization. YMMV.
#define SSS_USE_TANGENT_PLANE 0 // Improves the accuracy of the approximation(0 -> 1st order). High cost. Does not work with back-facing normals.

#include "ShaderLibrary/Common.hlsl"
#include "ShaderLibrary/Packing.hlsl"
#include "ShaderLibrary/Sampling/Fibonacci.hlsl"
#include "ShaderLibrary/Sampling/Sampling.hlsl"
#include "ShaderLibrary/SpaceFillingCurves.hlsl"
#include "../../ShaderVariables.hlsl"
#include "../../Lighting/LightDefinition.cs.hlsl"

float r = _FilterKernels[profileID][i][iR];
// The relative sample position is known at the compile time.
float phi = SampleDiskFibonacci(i, n).y;
#if (SSS_TAA_INTEGRATION != 0)
// Note that we repeat the pattern twice during the TAA cycle to reduce flickering.
phi += VanDerCorputBase2(_TaaFrameIndex % 4) * TWO_PI;
#endif
float2 vec = r * float2(cos(phi), sin(phi));
// Compute the screen-space position and the squared distance (in mm) in the image plane.

3
ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl


int unity_StereoEyeIndex;
#endif
float4 unity_ShadowColor;
float3 unity_ShadowColor;
uint _TaaFrameIndex; // [0, 7]
CBUFFER_END
// ----------------------------------------------------------------------------

正在加载...
取消
保存