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.
67 lines
2.6 KiB
67 lines
2.6 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 UpsampleFastTiles
|
|
|
|
#pragma multi_compile _ ENABLE_ALPHA
|
|
#pragma multi_compile _ FORCE_POINT_SAMPLING
|
|
|
|
#define GROUP_RES 8u
|
|
#define GROUP_SIZE (GROUP_RES * GROUP_RES)
|
|
|
|
CBUFFER_START(cb0)
|
|
float4 _Params;
|
|
float4 _Params2;
|
|
uint _DebugTileClassification;
|
|
uint3 _Padding;
|
|
CBUFFER_END
|
|
|
|
#define NumRings _Params.x
|
|
#define MaxCoCRadius _Params.y
|
|
#define Anamorphism _Params.z
|
|
|
|
// Out-of-focus areas, computed at lower res
|
|
TEXTURE2D_X(_InputNearTexture);
|
|
|
|
// Here we write the final output
|
|
RW_TEXTURE2D_X(CTYPE, _OutputTexture);
|
|
|
|
#define ResScale 1.0f
|
|
#define OneOverResScale 1.0f
|
|
#define MaxColorMip 0.0
|
|
#define AdaptiveSamplingWeights _Params2.xy
|
|
#define BlurResolution _Params2.z
|
|
#define InvBlurResolution _Params2.w
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DoFGatherUtils.hlsl"
|
|
|
|
// TODO: indirect classification
|
|
[numthreads(GROUP_RES, GROUP_RES, 1)]
|
|
void UpsampleFastTiles(uint3 dispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
|
|
|
|
PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId.xy), _PostProcessScreenSize.zw, uint2(GROUP_RES, GROUP_RES));
|
|
|
|
int tileClass = GetTileClass(posInputs.positionSS);
|
|
|
|
if (tileClass == FAST_DEFOCUS_TILE)
|
|
{
|
|
float2 uv = (posInputs.positionSS + 0.5) * _PostProcessScreenSize.zw;
|
|
uv = ClampAndScaleUV(uv, _PostProcessScreenSize.zw * BlurResolution, 0.5f, _RTHandlePostProcessScale.xy);
|
|
CTYPE output = SAMPLE_TEXTURE2D_X_LOD(_InputNearTexture, s_linear_clamp_sampler, uv, 0.0).CTYPE_SWIZZLE;
|
|
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = (CTYPE)output;
|
|
}
|
|
|
|
// Helper function to visualize tile types in case it is needed for debugging
|
|
if (_DebugTileClassification != 0)
|
|
{
|
|
CTYPE debug = _OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)];
|
|
DebugTiles(tileClass, debug.xyz);
|
|
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = debug;
|
|
}
|
|
}
|