diff --git a/WickedEngine/shaders/ShaderInterop_Postprocess.h b/WickedEngine/shaders/ShaderInterop_Postprocess.h index 61dd70378..03387e5ae 100644 --- a/WickedEngine/shaders/ShaderInterop_Postprocess.h +++ b/WickedEngine/shaders/ShaderInterop_Postprocess.h @@ -42,6 +42,7 @@ struct Bloom #define ssr_input_maxmip postprocess.params0.x #define ssr_input_resolution_max postprocess.params0.y +#define ssr_frame postprocess.params0.w #define ssao_range postprocess.params0.x #define ssao_samplecount postprocess.params0.y @@ -51,6 +52,7 @@ struct Bloom #define rtao_power ssao_power #define rtreflection_range ssao_range +#define rtreflection_frame ssr_frame static const uint POSTPROCESS_HBAO_THREADCOUNT = 320; #define hbao_direction postprocess.params0.xy @@ -58,7 +60,7 @@ static const uint POSTPROCESS_HBAO_THREADCOUNT = 320; #define hbao_uv_to_view_A postprocess.params1.xy #define hbao_uv_to_view_B postprocess.params1.zw -#define sss_step postprocess.params0 +#define volumetricclouds_frame postprocess.params0.z static const uint POSTPROCESS_MSAO_BLOCKSIZE = 16; struct MSAO diff --git a/WickedEngine/shaders/ssr_temporalCS.hlsl b/WickedEngine/shaders/ssr_temporalCS.hlsl index 65be0c38b..38fd0e5f8 100644 --- a/WickedEngine/shaders/ssr_temporalCS.hlsl +++ b/WickedEngine/shaders/ssr_temporalCS.hlsl @@ -96,6 +96,12 @@ inline void ResolverAABB(Texture2D currentColor, SamplerState currentSam [numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)] void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex) { + if ((uint)ssr_frame == 0) + { + output[DTid.xy] = resolve_current[DTid.xy]; + return; + } + const float2 uv = (DTid.xy + 0.5f) * postprocess.resolution_rcp; const float depth = texture_depth.SampleLevel(sampler_linear_clamp, uv, 0); if (depth == 0) diff --git a/WickedEngine/shaders/volumetricCloud_reprojectCS.hlsl b/WickedEngine/shaders/volumetricCloud_reprojectCS.hlsl index 65e76489b..b2977a198 100644 --- a/WickedEngine/shaders/volumetricCloud_reprojectCS.hlsl +++ b/WickedEngine/shaders/volumetricCloud_reprojectCS.hlsl @@ -73,7 +73,7 @@ void main(uint3 DTid : SV_DispatchThreadID) #endif - bool validHistory = is_saturated(prevUV); + bool validHistory = is_saturated(prevUV) && volumetricclouds_frame > 0; int subPixelIndex = GetFrame().frame_count % 4; int localIndex = (DTid.x & 1) + (DTid.y & 1) * 2; diff --git a/WickedEngine/shaders/volumetricCloud_temporalCS.hlsl b/WickedEngine/shaders/volumetricCloud_temporalCS.hlsl index 7747c2859..ae120b83a 100644 --- a/WickedEngine/shaders/volumetricCloud_temporalCS.hlsl +++ b/WickedEngine/shaders/volumetricCloud_temporalCS.hlsl @@ -192,7 +192,7 @@ void main(uint3 DTid : SV_DispatchThreadID) float4 result = lerp(previous, current, temporalResponse); - result = is_saturated(prevUV) ? result : current; + result = (is_saturated(prevUV) && volumetricclouds_frame > 0) ? result : current; output[DTid.xy] = result; diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 92ba81d27..ef07e5117 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -9182,6 +9182,8 @@ void Postprocess_RTAO( } void CreateRTReflectionResources(RTReflectionResources& res, XMUINT2 resolution) { + res.frame = 0; + TextureDesc desc; desc.width = resolution.x / 2; desc.height = resolution.y / 2; @@ -9227,6 +9229,7 @@ void Postprocess_RTReflection( postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; rtreflection_range = range; + rtreflection_frame = (float)res.frame; device->PushConstants(&postprocess, sizeof(postprocess), cmd); size_t shaderIdentifierSize = device->GetShaderIdentifierSize(); @@ -9283,7 +9286,7 @@ void Postprocess_RTReflection( device->PushConstants(&postprocess, sizeof(postprocess), cmd); - int temporal_output = device->GetFrameCount() % 2; + int temporal_output = res.frame % 2; int temporal_history = 1 - temporal_output; // Temporal pass: @@ -9362,11 +9365,15 @@ void Postprocess_RTReflection( device->EventEnd(cmd); } + res.frame++; + wiProfiler::EndRange(prof_range); device->EventEnd(cmd); } void CreateSSRResources(SSRResources& res, XMUINT2 resolution) { + res.frame = 0; + TextureDesc desc; desc.type = TextureDesc::Type::TEXTURE_2D; desc.width = resolution.x / 2; @@ -9405,6 +9412,7 @@ void Postprocess_SSR( postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; ssr_input_maxmip = float(input_desc.mip_levels - 1); ssr_input_resolution_max = (float)std::max(input_desc.width, input_desc.height); + ssr_frame = (float)res.frame; device->PushConstants(&postprocess, sizeof(postprocess), cmd); // Raytrace pass: @@ -9483,7 +9491,7 @@ void Postprocess_SSR( device->EventEnd(cmd); } - int temporal_output = device->GetFrameCount() % 2; + int temporal_output = res.frame % 2; int temporal_history = 1 - temporal_output; // Temporal pass: @@ -9562,6 +9570,8 @@ void Postprocess_SSR( device->EventEnd(cmd); } + res.frame++; + wiProfiler::EndRange(range); device->EventEnd(cmd); } @@ -10779,6 +10789,8 @@ void Postprocess_MotionBlur( } void CreateVolumetricCloudResources(VolumetricCloudResources& res, XMUINT2 resolution) { + res.frame = 0; + XMUINT2 renderResolution = XMUINT2(resolution.x / 4, resolution.y / 4); XMUINT2 reprojectionResolution = XMUINT2(resolution.x / 2, resolution.y / 2); XMUINT2 maskResolution = XMUINT2(resolution.x / 4, resolution.y / 4); // Needs to be half of final cloud output @@ -10890,9 +10902,10 @@ void Postprocess_VolumetricClouds( postprocess.resolution.y = reprojection_desc.height; postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; + volumetricclouds_frame = (float)res.frame; device->PushConstants(&postprocess, sizeof(postprocess), cmd); - int temporal_output = device->GetFrameCount() % 2; + int temporal_output = res.frame % 2; int temporal_history = 1 - temporal_output; // Reprojection pass: @@ -10980,6 +10993,8 @@ void Postprocess_VolumetricClouds( device->EventEnd(cmd); } + res.frame++; + wiProfiler::EndRange(range); device->EventEnd(cmd); } diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 7a3669cd9..da677f301 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -432,6 +432,7 @@ namespace wiRenderer ); struct RTReflectionResources { + mutable int frame = 0; wiGraphics::Texture temporal[2]; wiGraphics::Texture rayLengths; }; @@ -445,6 +446,7 @@ namespace wiRenderer ); struct SSRResources { + mutable int frame = 0; wiGraphics::Texture texture_raytrace; wiGraphics::Texture rayLengths; wiGraphics::Texture texture_temporal[2]; @@ -552,6 +554,7 @@ namespace wiRenderer ); struct VolumetricCloudResources { + mutable int frame = 0; wiGraphics::Texture texture_cloudRender; wiGraphics::Texture texture_cloudDepth; wiGraphics::Texture texture_reproject[2]; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 4882a6823..4f9876005 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 59; // minor bug fixes, alterations, refactors, updates - const int revision = 6; + const int revision = 7; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);