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.
 
 
 
 

39 lines
1.7 KiB

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel FXAA
#pragma multi_compile _ ENABLE_ALPHA
#pragma multi_compile _ HDR_INPUT
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/PostProcessDefines.hlsl"
RW_TEXTURE2D_X(CTYPE, _OutputTexture);
TEXTURE2D_X(_InputTexture);
float4 _HDROutputParams;
#define _PaperWhite _HDROutputParams.z
#define _OneOverPaperWhite _HDROutputParams.w
[numthreads(8,8,1)]
void FXAA(uint3 dispatchThreadId : SV_DispatchThreadID)
{
UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
uint2 positionSS = dispatchThreadId.xy;
float2 positionNDC = positionSS * _PostProcessScreenSize.zw + (0.5 * _PostProcessScreenSize.zw);
CTYPE outColor = Load(_InputTexture, positionSS, 0, 0).CTYPE_SWIZZLE;
CTYPE beforeFXAA = outColor;
RunFXAA(_InputTexture, s_linear_clamp_sampler, outColor, positionSS, positionNDC, _PaperWhite, _OneOverPaperWhite);
#if defined(ENABLE_ALPHA)
// When alpha processing is enabled, FXAA should not affect pixels with zero alpha
outColor.xyz = outColor.a > 0 ? outColor.xyz : beforeFXAA.xyz;
#endif
_OutputTexture[COORD_TEXTURE2D_X(positionSS)] = outColor;
}