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

Commit

Permalink
Merge pull request #391 from TeamWisp/feature_reflection_denoiser
Browse files Browse the repository at this point in the history
Feature reflection denoiser
  • Loading branch information
VZout authored Jun 20, 2019
2 parents 5ac22d0 + 649323d commit 8ff436b
Show file tree
Hide file tree
Showing 29 changed files with 2,003 additions and 90 deletions.
17 changes: 12 additions & 5 deletions resources/shaders/deferred_composition_pass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ TextureCube skybox : register(t5);
TextureCube irradiance_map : register(t6);
TextureCube pref_env_map : register(t7);
Texture2D brdf_lut : register(t8);
Texture2D buffer_reflection : register(t9); // xyz: reflection, a: shadow factor
Texture2D buffer_shadow : register(t10);
Texture2D buffer_reflection : register(t9); //rgb: reflection, a : 1 / pdf
Texture2D buffer_shadow : register(t10); //r: shadow factor
Texture2D screen_space_irradiance : register(t11);
Texture2D screen_space_ao : register(t12);
RWTexture2D<float4> output : register(u0);
Expand All @@ -44,17 +44,24 @@ SamplerState linear_sampler : register(s1);
cbuffer CameraProperties : register(b0)
{
float4x4 view;

float4x4 projection;

float4x4 inv_projection;

float4x4 inv_view;

float4x4 prev_projection;

float4x4 prev_view;

uint is_hybrid;
uint is_path_tracer;
uint is_ao;
uint has_shadows;

float3 padding1;
uint has_reflections;
float3 padding;
};

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

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

Expand Down
14 changes: 14 additions & 0 deletions resources/shaders/deferred_geometry_pass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,24 @@ struct VS_OUTPUT
cbuffer CameraProperties : register(b0)
{
float4x4 view;

float4x4 projection;

float4x4 inv_projection;

float4x4 inv_view;

float4x4 prev_projection;

float4x4 prev_view;

uint is_hybrid;
uint is_path_tracer;
uint is_ao;
uint has_shadows;

float3 padding1;
uint has_reflections;
};

struct ObjectData
Expand Down Expand Up @@ -114,6 +125,7 @@ struct PS_OUTPUT
#ifdef IS_HYBRID
float4 velocity : SV_TARGET3;
float4 depth : SV_TARGET4;
float4 world_position : SV_TARGET5;
#endif
};

Expand Down Expand Up @@ -183,6 +195,8 @@ PS_OUTPUT main_ps(VS_OUTPUT input) : SV_TARGET
float max_change_z = max(abs(ddx(linear_z)), abs(ddy(linear_z)));
float compressed_obj_normal = asfloat(dirToOct(normalize(obj_normal)));
output.depth = float4(linear_z, max_change_z, prev_z, compressed_obj_normal);

output.world_position = input.world_pos;
#endif

return output;
Expand Down
Loading

0 comments on commit 8ff436b

Please sign in to comment.