Fix depth of field blur artifacts on upper and left screen edges

This commit is contained in:
Wojciech Figat
2021-12-07 15:54:27 +01:00
parent 983d5dee31
commit b44b8955b3
2 changed files with 14 additions and 14 deletions

BIN
Content/Shaders/DepthOfField.flax (Stored with Git LFS)

Binary file not shown.

View File

@@ -137,11 +137,11 @@ META_CS(true, FEATURE_LEVEL_SM5)
void CS_DepthOfFieldH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID)
{
// These positions are relative to the "grid", AKA the horizontal group of pixels that this thread group is writing to
const uint gridStartX = groupID.x * DOF_GRID_SIZE;
const uint gridX = groupThreadID.x - DOF_APRON_SIZE;
const int gridStartX = groupID.x * DOF_GRID_SIZE;
const int gridX = groupThreadID.x - DOF_APRON_SIZE;
// These positions are relative to the pixel coordinates
const uint sampleX = gridStartX + gridX;
const uint sampleX = max(gridStartX + gridX, 0);
const uint sampleY = groupID.y;
uint2 textureSize;
@@ -218,12 +218,12 @@ META_CS(true, FEATURE_LEVEL_SM5)
void CS_DepthOfFieldV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID)
{
// These positions are relative to the "grid", AKA the vertical group of pixels that this thread group is writing to
const uint gridStartY = groupID.y * DOF_GRID_SIZE;
const uint gridY = groupThreadID.y - DOF_APRON_SIZE;
const int gridStartY = groupID.y * DOF_GRID_SIZE;
const int gridY = groupThreadID.y - DOF_APRON_SIZE;
// These positions are relative to the pixel coordinates
const uint sampleX = groupID.x;
const uint sampleY = gridStartY + gridY;
const uint sampleY = max(gridStartY + gridY, 0);
uint2 textureSize;
Input0.GetDimensions(textureSize.x, textureSize.y);
@@ -311,11 +311,11 @@ META_CS(true, FEATURE_LEVEL_SM5)
void CS_CoCSpreadH(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID)
{
// These positions are relative to the "grid", AKA the horizontal group of pixels that this thread group is writing to
const uint gridStartX = groupID.x * DOF_GRID_SIZE;
const uint gridX = groupThreadID.x - DOF_APRON_SIZE;
const int gridStartX = groupID.x * DOF_GRID_SIZE;
const int gridX = groupThreadID.x - DOF_APRON_SIZE;
// These positions are relative to the pixel coordinates
const uint sampleX = gridStartX + gridX;
const uint sampleX = max(gridStartX + gridX, 0);
const uint sampleY = groupID.y;
uint2 textureSize;
@@ -382,12 +382,12 @@ META_CS(true, FEATURE_LEVEL_SM5)
void CS_CoCSpreadV(uint3 groupID : SV_GroupID, uint3 groupThreadID : SV_GroupThreadID)
{
// These positions are relative to the "grid", AKA the vertical group of pixels that this thread group is writing to
const uint gridStartY = groupID.y * DOF_GRID_SIZE;
const uint gridY = groupThreadID.y - DOF_APRON_SIZE;
const int gridStartY = groupID.y * DOF_GRID_SIZE;
const int gridY = groupThreadID.y - DOF_APRON_SIZE;
// These positions are relative to the pixel coordinates
const uint sampleX = groupID.x;
const uint sampleY = gridStartY + gridY;
const uint sampleY = max(gridStartY + gridY, 0);
uint2 textureSize;
Input0.GetDimensions(textureSize.x, textureSize.y);