Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Commit 8ff436b

Browse files
authored
Merge pull request #391 from TeamWisp/feature_reflection_denoiser
Feature reflection denoiser
2 parents 5ac22d0 + 649323d commit 8ff436b

29 files changed

+2003
-90
lines changed

resources/shaders/deferred_composition_pass.hlsl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ TextureCube skybox : register(t5);
3333
TextureCube irradiance_map : register(t6);
3434
TextureCube pref_env_map : register(t7);
3535
Texture2D brdf_lut : register(t8);
36-
Texture2D buffer_reflection : register(t9); // xyz: reflection, a: shadow factor
37-
Texture2D buffer_shadow : register(t10);
36+
Texture2D buffer_reflection : register(t9); //rgb: reflection, a : 1 / pdf
37+
Texture2D buffer_shadow : register(t10); //r: shadow factor
3838
Texture2D screen_space_irradiance : register(t11);
3939
Texture2D screen_space_ao : register(t12);
4040
RWTexture2D<float4> output : register(u0);
@@ -44,17 +44,24 @@ SamplerState linear_sampler : register(s1);
4444
cbuffer CameraProperties : register(b0)
4545
{
4646
float4x4 view;
47+
4748
float4x4 projection;
49+
4850
float4x4 inv_projection;
51+
4952
float4x4 inv_view;
53+
5054
float4x4 prev_projection;
55+
5156
float4x4 prev_view;
57+
5258
uint is_hybrid;
5359
uint is_path_tracer;
5460
uint is_ao;
5561
uint has_shadows;
62+
63+
float3 padding1;
5664
uint has_reflections;
57-
float3 padding;
5865
};
5966

6067
static uint min_depth = 0xFFFFFFFF;
@@ -130,7 +137,7 @@ void main_cs(int3 dispatch_thread_id : SV_DispatchThreadID)
130137
// Do deferred shadow (fully lit for now)
131138
float3(1, 1, 1),
132139
// Shadow buffer if its hybrid rendering
133-
buffer_shadow.SampleLevel(point_sampler, uv, 0).rgb,
140+
buffer_shadow.SampleLevel(linear_sampler, uv, 0.0f).rgb,
134141
// Lerp factor (0: no hybrid, 1: hybrid)
135142
has_shadows);
136143

@@ -139,7 +146,7 @@ void main_cs(int3 dispatch_thread_id : SV_DispatchThreadID)
139146
// Sample from environment if it IS NOT hybrid rendering
140147
sampled_environment_map,
141148
// Reflection buffer if it IS hybrid rendering
142-
buffer_reflection.SampleLevel(point_sampler, uv, 0).xyz,
149+
buffer_reflection.SampleLevel(linear_sampler, uv, 0).xyz,
143150
// Lerp factor (0: no hybrid, 1: hybrid)
144151
has_reflections);
145152

resources/shaders/deferred_geometry_pass.hlsl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,24 @@ struct VS_OUTPUT
5353
cbuffer CameraProperties : register(b0)
5454
{
5555
float4x4 view;
56+
5657
float4x4 projection;
58+
5759
float4x4 inv_projection;
60+
5861
float4x4 inv_view;
62+
5963
float4x4 prev_projection;
64+
6065
float4x4 prev_view;
66+
6167
uint is_hybrid;
6268
uint is_path_tracer;
69+
uint is_ao;
70+
uint has_shadows;
71+
72+
float3 padding1;
73+
uint has_reflections;
6374
};
6475

6576
struct ObjectData
@@ -114,6 +125,7 @@ struct PS_OUTPUT
114125
#ifdef IS_HYBRID
115126
float4 velocity : SV_TARGET3;
116127
float4 depth : SV_TARGET4;
128+
float4 world_position : SV_TARGET5;
117129
#endif
118130
};
119131

@@ -183,6 +195,8 @@ PS_OUTPUT main_ps(VS_OUTPUT input) : SV_TARGET
183195
float max_change_z = max(abs(ddx(linear_z)), abs(ddy(linear_z)));
184196
float compressed_obj_normal = asfloat(dirToOct(normalize(obj_normal)));
185197
output.depth = float4(linear_z, max_change_z, prev_z, compressed_obj_normal);
198+
199+
output.world_position = input.world_pos;
186200
#endif
187201

188202
return output;

0 commit comments

Comments
 (0)