浏览代码

Merge pull request #693 from EvgeniiG/master

Add temporal integration support to the Disney SSS
/feature-ReflectionProbeFit
GitHub 7 年前
当前提交
b8b228d9
共有 6 个文件被更改,包括 31 次插入2 次删除
  1. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl
  2. 8
      ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl
  3. 12
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDStringConstants.cs
  5. 7
      ScriptableRenderPipeline/HDRenderPipeline/Material/SubsurfaceScattering/SubsurfaceScattering.compute
  6. 3
      ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl

2
ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl


#define BitFieldExtract __v_bfe_u32
#define INTRINSIC_BITFIELD_EXTRACT_SIGN_EXTEND
#define BitFieldExtractSignExtend __v_bfe_i32
#define INTRINSIC_BITFIELD_INSERT
#define BitFieldInsert __v_bfi_b32
#define INTRINSIC_WAVEREADFIRSTLANE
#define WaveReadFirstLane ReadFirstLane
#define INTRINSIC_MAD24

8
ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl


}
#endif // INTRINSIC_BITFIELD_EXTRACT_SIGN_EXTEND
#ifdef INTRINSIC_BITFIELD_INSERT
// Inserts the bits indicated by 'mask' from 'src' into 'dst'.
uint BitFieldInsert(uint mask, uint src, uint dst)
{
return (src & mask) | (dst & ~mask);
}
#endif // INTRINSIC_BITFIELD_INSERT
bool IsBitSet(uint data, uint offset)
{
return BitFieldExtract(data, offset, 1u) != 0;

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
// ----------------------------------------------------------------------------

正在加载...
取消
保存