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.
 
 
 
 
 

73 lines
2.7 KiB

#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/PostProcessing/Shaders/PostProcessDefines.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingSampling.hlsl"
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
#pragma kernel KMain
#pragma multi_compile _ ENABLE_ALPHA
#pragma multi_compile _ HIGH_QUALITY
#pragma multi_compile _ FORCE_POINT_SAMPLING
CBUFFER_START(cb0)
float4 _Params;
float4 _Params2;
float4 _Params3;
CBUFFER_END
#define NumRings _Params.x
#define MaxCoCRadius _Params.y
#define Anamorphism _Params.z
#define MaxCoCMipLevel _Params2.x
#define MaxColorMip _Params2.y
#define OneOverResScale _Params2.z
#define ResScale _Params2.w
#define AdaptiveSamplingWeights _Params3.xy
// Outpute texture
RW_TEXTURE2D_X(CTYPE, _OutputTexture);
#define GROUP_RES 8u
#define GROUP_SIZE (GROUP_RES * GROUP_RES)
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGatherUtils.hlsl"
[numthreads(GROUP_RES, GROUP_RES, 1)]
void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
{
UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _PostProcessScreenSize.zw, uint2(GROUP_RES, GROUP_RES));
SampleData centerSample;
centerSample.color = GetColorSample(posInputs.positionSS, 0);
centerSample.CoC = GetCoCRadius(posInputs.positionSS);
#ifndef HIGH_QUALITY
int tileClass = GetTileClass(posInputs.positionSS);
if (ResScale != 1.0 && tileClass != FAST_DEFOCUS_TILE)
{
// Early exit: these tiles will be computed at full res in the combine pass
// This might create small artifacts during upscale of the half-res tiles (bilinear fetch at the border picks unblurred values and this might be visible), so it's disabled in high quality mode
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = (CTYPE)centerSample.color;
return;
}
#endif
DoFTile tileData;
LoadTileData(posInputs.positionSS, centerSample, NumRings, tileData);
float4 outColor;
float outAlpha;
DoFGatherRings(posInputs, tileData, centerSample, outColor, outAlpha);
#ifdef ENABLE_ALPHA
ComposeAlpha(outColor, centerSample.color.xyz, outAlpha);
#endif
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = (CTYPE) outColor;
}