Browse Source

Merge branch 'ww1dev/hdrp17/svn' into ww1dev/hdrp17/staging

# Conflicts:
#	Packages/com.unity.visualeffectgraph/Shaders/VFXRayTracingCommon.hlsl.meta
ww1dev/hdrp17/staging
Nico de Poel 9 months ago
parent
commit
ae8d04a703
  1. 6
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
  2. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs
  3. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
  4. 11
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3Upscaler.cs
  5. 8
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs
  6. 10
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h
  7. 29
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h
  8. 19
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_prepare_reactivity.h

6
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs

@ -2295,8 +2295,10 @@ namespace UnityEngine.Rendering.HighDefinition
{
// The variance between 0 and the actual halton sequence values reveals noticeable
// instability in Unity's shadow maps, so we avoid index 0.
jitterX = HaltonSequence.Get(taaFrameIndex + 1, 2) - 0.5f;
jitterY = HaltonSequence.Get(taaFrameIndex + 1, 3) - 0.5f;
const float basePhaseCount = 8.0f;
int jitterPhaseCount = (int)(basePhaseCount * Mathf.Pow(screenSize.x / actualWidth, 2.0f));
jitterX = HaltonSequence.Get((taaFrameIndex % jitterPhaseCount) + 1, 2) - 0.5f;
jitterY = HaltonSequence.Get((taaFrameIndex % jitterPhaseCount) + 1, 3) - 0.5f;
}
if (!(IsFSR2Enabled() || IsDLSSEnabled() || IsTAAUEnabled() || camera.cameraType == CameraType.SceneView))

2
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs

@ -265,7 +265,7 @@ namespace UnityEngine.Rendering.HighDefinition
ApplyExposure,
TemporalAntialiasing,
UpscalerColorMask,
FSR2,
AdvancedUpscaling,
DeepLearningSuperSampling,
DepthOfField,
DepthOfFieldKernel,

4
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs

@ -1001,7 +1001,7 @@ namespace UnityEngine.Rendering.HighDefinition
RenderGraph renderGraph, HDCamera hdCamera,
TextureHandle source, TextureHandle depthBuffer, TextureHandle motionVectors, TextureHandle biasColorMask)
{
using (var builder = renderGraph.AddRenderPass<FSR2Data>("Fidelity FX 2 Super Resolution", out var passData, ProfilingSampler.Get(HDProfileId.FSR2)))
using (var builder = renderGraph.AddRenderPass<FSR2Data>("Advanced Temporal Upscaling", out var passData, ProfilingSampler.Get(HDProfileId.AdvancedUpscaling)))
{
passData.parameters = new FSR2Pass.Parameters();
passData.parameters.hdCamera = hdCamera;
@ -1009,7 +1009,7 @@ namespace UnityEngine.Rendering.HighDefinition
var viewHandles = new UpscalerResources.ViewResourceHandles();
viewHandles.source = builder.ReadTexture(source);
viewHandles.output = builder.WriteTexture(GetPostprocessUpsampledOutputHandle(hdCamera, renderGraph, "FSR2 destination"));
viewHandles.output = builder.WriteTexture(GetPostprocessUpsampledOutputHandle(hdCamera, renderGraph, "Upscaling destination"));
viewHandles.depth = builder.ReadTexture(depthBuffer);
viewHandles.motionVectors = builder.ReadTexture(motionVectors);

11
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3Upscaler.cs

@ -1,4 +1,4 @@
// Copyright (c) 2024 Nico de Poel
// Copyright (c) 2024 Nico de Poel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -202,6 +202,10 @@ namespace FidelityFX.FSR3
public float CameraFovAngleVertical;
public float ViewSpaceToMetersFactor;
public float VelocityFactor = 1.0f;
public float ReactivenessScale = 1.0f;
public float ShadingChangeScale = 1.0f;
public float AccumulationAddedPerFrame = 1.0f / 3.0f;
public float MinDisocclusionAccumulation = -1.0f / 3.0f;
public DispatchFlags Flags;
public bool UseTextureArrays; // Enable texture array bindings, primarily used for HDRP and XR
@ -269,7 +273,12 @@ namespace FidelityFX.FSR3
public float frameIndex;
public Vector2Int inputResourceSize; // WW1MOD
public float velocityFactor;
public float reactivenessScale;
public float shadingChangeScale;
public float accumulationAddedPerFrame;
public float minDisocclusionAccumulation;
}
[Serializable, StructLayout(LayoutKind.Sequential)]

8
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs

@ -97,6 +97,10 @@ namespace FidelityFX.FSR3
UpscalerConsts.maxUpscaleSize = _contextDescription.MaxUpscaleSize;
UpscalerConsts.velocityFactor = 1.0f;
UpscalerConsts.reactivenessScale = 1.0f;
UpscalerConsts.shadingChangeScale = 1.0f;
UpscalerConsts.accumulationAddedPerFrame = 1.0f / 3.0f;
UpscalerConsts.minDisocclusionAccumulation = -1.0f / 3.0f;
_resources.Create(_contextDescription);
CreatePasses();
@ -418,6 +422,10 @@ namespace FidelityFX.FSR3
constants.frameIndex += 1.0f;
constants.velocityFactor = dispatchParams.VelocityFactor;
constants.reactivenessScale = dispatchParams.ReactivenessScale;
constants.shadingChangeScale = dispatchParams.ShadingChangeScale;
constants.accumulationAddedPerFrame = dispatchParams.AccumulationAddedPerFrame;
constants.minDisocclusionAccumulation = dispatchParams.MinDisocclusionAccumulation;
}
private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr3Upscaler.DispatchDescription dispatchParams)

10
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h

@ -1,7 +1,7 @@
// This file is part of the FidelityFX SDK.
//
// Copyright (C) 2024 Advanced Micro Devices, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@ -46,13 +46,13 @@ void RectifyHistory(
FFX_PARAMETER_INOUT AccumulationPassData data
)
{
const FfxFloat32 fVecolityFactor = ffxSaturate(params.f4KVelocity / 20.0f);
const FfxFloat32 f4kVelocityFactor = ffxSaturate(params.f4KVelocity / 20.0f);
const FfxFloat32 fDistanceFactor = ffxSaturate(0.75f - params.fFarthestDepthInMeters / 20.0f);
const FfxFloat32 fAccumulationFactor = 1.0f - params.fAccumulation;
const FfxFloat32 fReactiveFactor = ffxPow(params.fReactiveMask, 1.0f / 2.0f);
const FfxFloat32 fShadingChangeFactor = params.fShadingChange;
const FfxFloat32 fBoxScaleT = ffxMax(fVecolityFactor, ffxMax(fDistanceFactor, ffxMax(fAccumulationFactor, ffxMax(fReactiveFactor, fShadingChangeFactor))));
const FfxFloat32 fBoxScaleT = ffxMax(f4kVelocityFactor, ffxMax(fDistanceFactor, ffxMax(fAccumulationFactor, ffxMax(fReactiveFactor, fShadingChangeFactor))));
const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT);
const FfxFloat32x3 fScaledBoxVec = data.clippingBox.boxVec * FfxFloat32x3(1.7f, 1.0f, 1.0f) * fBoxScale;
@ -148,7 +148,7 @@ void Accumulate(FfxInt32x2 iPxHrPos)
if (params.bIsExistingSample && !params.bIsNewSample) {
ReprojectHistoryColor(params, data);
}
UpdateLockStatus(params, data);
ComputeBaseAccumulationWeight(params, data);

29
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h

@ -1,7 +1,7 @@
// This file is part of the FidelityFX SDK.
// This file is part of the FidelityFX SDK.
//
// Copyright (C) 2024 Advanced Micro Devices, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@ -77,7 +77,12 @@ cbuffer cbFSR3Upscaler : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_FSR3UP
FfxFloat32 fFrameIndex;
FfxInt32x2 iInputResourceSize; // WW1MOD
FfxFloat32 fVelocityFactor;
FfxFloat32 fReactivenessScale;
FfxFloat32 fShadingChangeScale;
FfxFloat32 fAccumulationAddedPerFrame;
FfxFloat32 fMinDisocclusionAccumulation;
};
#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR3Upscaler) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR3Upscaler size.
@ -185,6 +190,16 @@ FfxFloat32 VelocityFactor()
return fVelocityFactor;
}
FfxFloat32 AccumulationAddedPerFrame()
{
return fAccumulationAddedPerFrame;
}
FfxFloat32 MinDisocclusionAccumulation()
{
return fMinDisocclusionAccumulation;
}
#endif // #if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER)
#define FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(p) FFX_FSR3UPSCALER_ROOTSIG_STR(p)
@ -392,7 +407,7 @@ UNITY_FSR_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3U
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos)
{
return r_reactive_mask[UNITY_FSR_POS(iPxPos)];
return r_reactive_mask[UNITY_FSR_POS(iPxPos)] * fReactivenessScale;
}
FfxInt32x2 GetReactiveMaskResourceDimensions()
@ -406,7 +421,7 @@ FfxInt32x2 GetReactiveMaskResourceDimensions()
FfxFloat32 SampleReactiveMask(FfxFloat32x2 fUV)
{
return r_reactive_mask.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x;
return r_reactive_mask.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x * fReactivenessScale;
}
#endif
@ -501,7 +516,7 @@ FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV)
}
#endif
#if defined(FSR3UPSCALER_BIND_SRV_RCAS_INPUT)
#if defined(FSR3UPSCALER_BIND_SRV_RCAS_INPUT)
Texture2D<FfxFloat32x4> r_rcas_input : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RCAS_INPUT);
FfxFloat32x4 LoadRCAS_Input(FfxInt32x2 iPxPos)
@ -562,12 +577,12 @@ Texture2D<FfxFloat32> r_shading_change : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCAL
FfxFloat32 LoadShadingChange(FfxUInt32x2 iPxPos)
{
return r_shading_change[iPxPos];
return r_shading_change[iPxPos] * fShadingChangeScale;
}
FfxFloat32 SampleShadingChange(FfxFloat32x2 fUV)
{
return r_shading_change.SampleLevel(s_LinearClamp, fUV, 0);
return r_shading_change.SampleLevel(s_LinearClamp, fUV, 0) * fShadingChangeScale;
}
#endif

19
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_prepare_reactivity.h

@ -210,15 +210,28 @@ FfxFloat32 UpdateAccumulation(FfxInt32x2 iPxPos, FfxFloat32x2 fUv, FfxFloat32x2
const FfxFloat32x2 fReprojectedUv_HW = ClampUv(fReprojectedUv, PreviousFrameRenderSize(), MaxRenderSize());
fAccumulation = ffxSaturate(SampleAccumulation(fReprojectedUv_HW));
}
const FfxFloat32 fAccumulationAddedPerFrame= AccumulationAddedPerFrame(); //default is 0.333
// Assume at frame N+0 fShadingChange is 1.0, and all subsequent frames fShadingChange is 0.0 and fDisocclusion is 0.0. Then,
// frame N+0 fAccumulation will be 0.000
// frame N+2 fAccumulation will be 0.000 + 0.333 * 1 == 0.333
// frame N+3 fAccumulation will be 0.000 + 0.333 * 2 == 0.666
// frame N+4 fAccumulation will be 0.000 + 0.333 * 3 == 0.999
fAccumulation = ffxLerp(fAccumulation, 0.0f, fShadingChange);
fAccumulation = ffxLerp(fAccumulation, ffxMin(fAccumulation, 0.25f), fDisocclusion);
const FfxFloat32 fMinDisocclusionAccumulation = MinDisocclusionAccumulation(); //default is -0.333
// Assume at frame N+0 fDisocclusion is 1.0, and all subsequent frames fShadingChange is 0.0 and fDisocclusion is 0.0. Then,
// frame N+0 fAccumulation will be -0.333f (but normalized to store in unorm)
// frame N+1 fAccumulation will be -0.333f + 0.333 * 1 == 0.000
// frame N+2 fAccumulation will be -0.333f + 0.333 * 2 == 0.333
// frame N+3 fAccumulation will be -0.333f + 0.333 * 3 == 0.666
// frame N+4 fAccumulation will be -0.333f + 0.333 * 4 == 0.999
fAccumulation = ffxLerp(fAccumulation, ffxMin(fMinDisocclusionAccumulation, fAccumulation), fDisocclusion);
fAccumulation *= FfxFloat32(round(fAccumulation * 100.0f) > 1.0f);
// Update for next frame, normalize to store in unorm
const FfxFloat32 fAccumulatedFramesMax = 3.0f;
const FfxFloat32 fAccumulatedFramesToStore = ffxSaturate(fAccumulation + (1.0f / fAccumulatedFramesMax));
const FfxFloat32 fAccumulatedFramesToStore = ffxSaturate(fAccumulation + fAccumulationAddedPerFrame);
StoreAccumulation(iPxPos, fAccumulatedFramesToStore);
return fAccumulation;

Loading…
Cancel
Save