You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
#pragma kernel KMain
|
|
|
|
#pragma multi_compile _ ENABLE_ALPHA
|
|
#pragma multi_compile _ HDR_INPUT
|
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
|
|
TEXTURE2D_X(_InputTexture);
|
|
RW_TEXTURE2D_X(float4, _OutputTexture);
|
|
|
|
float4 _EASUOutputSize;
|
|
float4 _HDROutputParams;
|
|
|
|
#define _PaperWhite _HDROutputParams.z
|
|
#define _OneOverPaperWhite _HDROutputParams.w
|
|
|
|
float2 ClampFSR(float2 p);
|
|
#define FSR_INPUT_TEXTURE _InputTexture
|
|
#define FSR_INPUT_SAMPLER s_linear_clamp_sampler
|
|
#define FSR_EASU_ONE_OVER_PAPER_WHITE _OneOverPaperWhite
|
|
#define FSR_CLAMP_COORD ClampFSR
|
|
#include "Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/Shaders/FSRCommon.hlsl"
|
|
|
|
float2 ClampFSR(float2 p)
|
|
{
|
|
//Gathers require entire texel clamping
|
|
float2 maxCoord = _RTHandleScale.xy - asfloat(FSR_EASU_CONSTANTS_1.xy);
|
|
return min(p, maxCoord);
|
|
}
|
|
|
|
[numthreads(64, 1, 1)]
|
|
void KMain(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 dispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
|
|
|
|
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
|
|
uint2 gxy = ARmp8x8(LocalThreadId.x) + uint2(WorkGroupId.x << 3u, WorkGroupId.y << 3u);
|
|
|
|
#ifdef ENABLE_ALPHA
|
|
float2 uv = ((float2)gxy.xy + 0.5) * _EASUOutputSize.zw;
|
|
float alpha = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, s_linear_clamp_sampler, ClampFSR(uv), 0.0).a;
|
|
#else
|
|
float alpha = 1.0;
|
|
#endif
|
|
|
|
float3 c = ApplyEASU(gxy);
|
|
|
|
#ifdef HDR_INPUT
|
|
c = FastTonemapInvert(c) * _PaperWhite;
|
|
#endif
|
|
|
|
// Input always stored in gamma 2.0
|
|
c = Gamma20ToLinear(c);
|
|
|
|
_OutputTexture[COORD_TEXTURE2D_X(gxy)] = float4(c, alpha);
|
|
}
|