浏览代码

Remove 2x QR instruction from the SSS pass

/main
Evgenii Golubev 7 年前
当前提交
d6e30390
共有 4 个文件被更改,包括 24 次插入8 次删除
  1. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  3. 19
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.compute
  4. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


public Vector4[] frustumPlaneEquations;
public Camera camera;
public uint taaFrameIndex;
public Vector2 taaFrameRotation;
public Vector4 viewParam;
public PostProcessRenderContext postprocessRenderContext;

const uint taaFrameCount = 8;
taaFrameIndex = taaEnabled ? (uint)Time.renderedFrameCount % taaFrameCount : 0;
taaFrameRotation = new Vector2(Mathf.Sin(taaFrameIndex * (0.5f * Mathf.PI)),
Mathf.Cos(taaFrameIndex * (0.5f * Mathf.PI)));
viewMatrix = gpuView;
projMatrix = gpuProj;

cmd.SetGlobalMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix);
cmd.SetGlobalVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations);
cmd.SetGlobalInt(HDShaderIDs._TaaFrameIndex, (int)taaFrameIndex);
cmd.SetGlobalVector(HDShaderIDs._TaaFrameRotation, taaFrameRotation);
}
// TODO: We should set all the value below globally and not let it under the control of Unity,

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/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 _TaaFrameIndex = Shader.PropertyToID("_TaaFrameIndex");
public static readonly int _TaaFrameRotation = Shader.PropertyToID("_TaaFrameRotation");
public static readonly int _DepthTexture = Shader.PropertyToID("_DepthTexture");
public static readonly int _CameraColorTexture = Shader.PropertyToID("_CameraColorTexture");

19
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.compute


#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.
#define SSS_CLAMP_ARTIFACT 0 // Reduces bleeding. Use with SSS_USE_TANGENT_PLANE.
#define SSS_DEBUG_LOD 0

float3 tangentX, float3 tangentY, float4x4 projMatrix,
inout float3 totalIrradiance, inout float3 totalWeight)
{
float r = _FilterKernels[profileID][i][iR];
float r = _FilterKernels[profileID][i][iR];
float phi = SampleDiskFibonacci(i, n).y;
float phi = SampleDiskFibonacci(i, n).y;
phi += VanDerCorputBase2(_TaaFrameIndex % 4) * TWO_PI;
#endif
float sinPsi = _TaaFrameRotation.x;
float cosPsi = _TaaFrameRotation.y;
// The angle 'psi' is loop-invariant. All the trigonometry is done at compile time.
// cos(a + b) = cos(a) * cos(b) - sin(a) * sin(b)
// sin(a + b) = sin(a) * cos(b) + cos(a) * sin(b)
float cosSum = cos(phi) * cosPsi - sin(phi) * sinPsi;
float sinSum = sin(phi) * cosPsi + cos(phi) * sinPsi;
float2 vec = r * float2(cosSum, sinSum);
#else
#endif
// Compute the screen-space position and the squared distance (in mm) in the image plane.
int2 position; float xy2;

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl


int unity_StereoEyeIndex;
#endif
float3 unity_ShadowColor;
uint _TaaFrameIndex; // [0, 7]
float4 unity_ShadowColor;
float2 _TaaFrameRotation; // {x = sin(_TaaFrameIndex * PI/2), y = cos(_TaaFrameIndex * PI/2), z = unused}
uint _TaaFrameIndex; // [0, 7]
uint _Align128;
// Volumetric lighting. Should be a struct in 'UnityPerFrame'.
// Unfortunately, structures inside constant buffers are not supported by Unity.
float3 _GlobalFog_Scattering;

正在加载...
取消
保存