浏览代码

Added temporal filtering for HiZ

/main
Frédéric Vauchelles 7 年前
当前提交
493c1fac
共有 1 个文件被更改,包括 27 次插入5 次删除
  1. 32
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

32
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


int debugMode = 0;
#endif
float invScreenWeightDistance = 0;
float temporalFilteringWeight = 0.2;
if (GPUImageBasedLightingType == GPUIMAGEBASEDLIGHTINGTYPE_REFRACTION)
{

ScreenSpaceRaymarchInput ssRayInput;
ZERO_INITIALIZE(ScreenSpaceRaymarchInput, ssRayInput);
ssRayInput.rayOriginWS = rayOriginWS + rayDirWS * SampleBayer4(posInput.positionSS + _FrameCount) * 0.1;
// Jitter the ray origin to trade some noise instead of banding effect
ssRayInput.rayOriginWS = rayOriginWS + rayDirWS * SampleBayer4(posInput.positionSS + uint2(_FrameCount, _FrameCount / 4)) * 0.1;
ssRayInput.rayDirWS = rayDirWS;
#if DEBUG_DISPLAY
ssRayInput.debug = debug;

UpdateLightingHierarchyWeights(hierarchyWeight, weight); // Shouldn't be needed, but safer in case we decide to change hierarchy priority
// Reproject color pyramid
float4 velocityBuffer = LOAD_TEXTURE2D_LOD(
float4 hitVelocityBuffer = LOAD_TEXTURE2D_LOD(
float2 velocityNDC;
DecodeVelocity(velocityBuffer, velocityNDC);
float2 hitVelocityNDC;
DecodeVelocity(hitVelocityBuffer, hitVelocityNDC);
(hit.positionNDC - velocityNDC) * _ColorPyramidScale.xy + _ColorPyramidSize.zw * 0.5,
(hit.positionNDC - hitVelocityNDC) * _ColorPyramidScale.xy + _ColorPyramidSize.zw * 0.5,
// With HiZ, we use a temporal filtering to reduce the noise from the ray origin jittering
if (projectionModel == PROJECTIONMODEL_HI_Z)
{
float4 currentVelocityBuffer = LOAD_TEXTURE2D_LOD(
_CameraMotionVectorsTexture,
posInput.positionSS,
0.0
);
float2 currentVelocityNDC;
DecodeVelocity(currentVelocityBuffer, currentVelocityNDC);
float3 currentLD = LOAD_TEXTURE2D_LOD(
_ColorPyramidTexture,
int2(posInput.positionSS) - int2(currentVelocityNDC * _ScreenSize.xy),
0
).rgb;
preLD = preLD * (1.0 - temporalFilteringWeight) + currentLD * temporalFilteringWeight;
}
// We use specularFGD as an approximation of the fresnel effect (that also handle smoothness)
float3 F = preLightData.specularFGD;

正在加载...
取消
保存