depth of field update

This commit is contained in:
Turanszki Janos
2020-04-21 20:21:13 +01:00
parent 518bb6ad77
commit c838506b07
6 changed files with 16 additions and 10 deletions
+4
View File
@@ -1,6 +1,10 @@
#ifndef WI_DEPTHOFFIELD_HF
#define WI_DEPTHOFFIELD_HF
inline float get_coc(in float linear_depth)
{
return min(dof_maxcoc, dof_scale * pow(abs(1 - dof_focus / (linear_depth * g_xCamera_ZFarP)), 2.0f));
}
#define DOF_DEPTH_SCALE_FOREGROUND (g_xCamera_ZFarP * 1.5)
float2 DepthCmp2(float depth, float closestTileDepth)
@@ -42,9 +42,8 @@ void main(uint3 DTid : SV_DispatchThreadID)
{
tile_statistics.InterlockedAdd(TILE_STATISTICS_OFFSET_EARLYEXIT, 1, prevCount);
tiles_earlyexit[prevCount] = tile;
return;
}
else if (abs(max_coc - min_coc) < 0.1f)
else if (abs(max_coc - min_coc) < 1)
{
tile_statistics.InterlockedAdd(TILE_STATISTICS_OFFSET_CHEAP, 1, prevCount);
tiles_cheap[prevCount] = tile;
@@ -54,5 +53,5 @@ void main(uint3 DTid : SV_DispatchThreadID)
tile_statistics.InterlockedAdd(TILE_STATISTICS_OFFSET_EXPENSIVE, 1, prevCount);
tiles_expensive[prevCount] = tile;
}
output[DTid.xy] = float2(min_depth, min(dof_maxcoc, max_coc));
output[DTid.xy] = float2(min_depth, max_coc);
}
+1 -2
View File
@@ -32,7 +32,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
const float mindepth = neighborhood_mindepth_maxcoc[2 * pixel / DEPTHOFFIELD_TILESIZE].x;
const float center_depth = texture_lineardepth.Load(uint3(pixel, 1));
const float coc = min(dof_maxcoc, dof_scale * abs(1 - dof_focus / (center_depth * g_xCamera_ZFarP)));
const float coc = get_coc(center_depth);
const float alpha = SampleAlpha(coc);
const float2 depthcmp = DepthCmp2(center_depth, mindepth);
@@ -53,7 +53,6 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
[unroll]
for (uint i = ringSampleCount[0]; i < ringSampleCount[1]; ++i)
{
const float offsetCoc = disc[i].z;
const float2 uv2 = uv + ringScale * disc[i].xy;
const float depth = texture_lineardepth.SampleLevel(sampler_point_clamp, uv2, 1);
const float3 color = max(0, input.SampleLevel(sampler_linear_clamp, uv2, 0).rgb);
@@ -1,5 +1,6 @@
#include "globals.hlsli"
#include "ShaderInterop_Postprocess.h"
#include "depthOfFieldHF.hlsli"
RWTEXTURE2D(tile_mindepth_maxcoc, float2, 0);
RWTEXTURE2D(tile_mincoc, float, 1);
@@ -22,7 +23,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
if (pixel.x >= 0 && pixel.y >= 0 && pixel.x < dim.x && pixel.y < dim.y)
{
const float depth = texture_lineardepth[pixel];
const float coc = dof_scale * abs(1 - dof_focus / (depth * g_xCamera_ZFarP));
const float coc = get_coc(depth);
min_depth = min(min_depth, depth);
max_coc = max(max_coc, coc);
min_coc = min(min_coc, coc);
+6 -3
View File
@@ -22,19 +22,22 @@ void main(uint3 DTid : SV_DispatchThreadID)
const float3 halfres = texture_postfilter.SampleLevel(sampler_linear_clamp, uv, 0);
const float alpha = texture_alpha.SampleLevel(sampler_linear_clamp, uv, 0);
const float coc = min(dof_maxcoc, dof_scale * abs(1 - dof_focus / (center_depth * g_xCamera_ZFarP)));
const float coc = get_coc(center_depth);
float depthDelta = saturate(1.0 - g_xCamera_ZFarP * 0.2 * (center_depth - mindepth));
float depthDelta = saturate(1.0 - g_xCamera_ZFarP * (center_depth - mindepth));
const float backgroundFactor = coc;
const float foregroundFactor = lerp(maxcoc, coc, pow(depthDelta, 1.0f / 2.2f));
const float foregroundFactor = lerp(maxcoc, coc, depthDelta);
const float combinedFactor = saturate(lerp(backgroundFactor, foregroundFactor, alpha));
float4 color = float4(lerp(fullres.rgb, halfres, combinedFactor), fullres.a);
//color = backgroundFactor;
//color = foregroundFactor;
//color = maxcoc;
//color = combinedFactor;
//color = alpha;
//color = depthDelta;
//color.rgb = halfres;
//if (coc < 0.01) color = float4(1, 0, 0, 1);
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 39;
// minor bug fixes, alterations, refactors, updates
const int revision = 75;
const int revision = 76;
long GetVersion()