diff --git a/WickedEngine/ShaderInterop_Postprocess.h b/WickedEngine/ShaderInterop_Postprocess.h index b2935e329..1165290fb 100644 --- a/WickedEngine/ShaderInterop_Postprocess.h +++ b/WickedEngine/ShaderInterop_Postprocess.h @@ -17,6 +17,9 @@ CBUFFER(PostProcessCB, CBSLOT_RENDERER_POSTPROCESS) #define lineardepth_inputresolution xPPParams0.xy #define lineardepth_inputresolution_rcp xPPParams0.zw +#define ssr_input_maxmip xPPParams0.x +#define ssr_input_resolution_max xPPParams0.y + #define ssao_range xPPParams0.x #define ssao_samplecount xPPParams0.y #define ssao_power xPPParams0.z diff --git a/WickedEngine/ssr_resolveCS.hlsl b/WickedEngine/ssr_resolveCS.hlsl index b544b5945..2249a5a84 100644 --- a/WickedEngine/ssr_resolveCS.hlsl +++ b/WickedEngine/ssr_resolveCS.hlsl @@ -74,7 +74,6 @@ void main(uint3 DTid : SV_DispatchThreadID) float specularConeTangent = lerp(0.0, roughness * (1.0 - BRDFBias), NdotV * sqrt(roughness)); specularConeTangent *= lerp(saturate(NdotV * 2), 1.0f, sqrt(roughness)); - const float maxMipLevel = 11.0f - 1.0f; const uint2 Random = Rand3DPCG16(int3((DTid.xy + 0.5f), g_xFrame_FrameCount)).xy; float4 result = 0.0f; @@ -87,7 +86,7 @@ void main(uint3 DTid : SV_DispatchThreadID) float2 offsetRotation = (HammersleyRandom(i, NumResolve, Random) * 2.0 - 1.0) * roughnessSequenceSize; float2x2 offsetRotationMatrix = float2x2(offsetRotation.x, offsetRotation.y, -offsetRotation.y, offsetRotation.x); - float2 offsetUV = offset[i] * (1.0f / xPPResolution); + float2 offsetUV = offset[i] * xPPResolution_rcp; offsetUV = uv + mul(offsetRotationMatrix, offsetUV) * CalculateTailDirection(N); float4 raytraceSource = texture_raytrace.SampleLevel(sampler_point_clamp, offsetUV, 0); @@ -100,7 +99,7 @@ void main(uint3 DTid : SV_DispatchThreadID) float iterationStep = maskSource.y; float intersectionCircleRadius = specularConeTangent * length(hitPixel - uv); - float sourceMip = clamp(log2(intersectionCircleRadius * max(xPPResolution.x, xPPResolution.y)), 0.0, maxMipLevel) * resolveMip; + float sourceMip = clamp(log2(intersectionCircleRadius * ssr_input_resolution_max), 0.0, ssr_input_maxmip) * resolveMip; float4 sampleColor; sampleColor.rgb = texture_main.SampleLevel(sampler_linear_clamp, hitPixel, sourceMip).xyz; diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 81c1b90ec..463a2f2ae 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -8825,6 +8825,7 @@ void Postprocess_SSR( device->UnbindResources(TEXSLOT_RENDERPATH_SSR, 1, cmd); + const TextureDesc& input_desc = input.GetDesc(); const TextureDesc& desc = output.GetDesc(); static TextureDesc initialized_desc; @@ -8865,6 +8866,8 @@ void Postprocess_SSR( cb.xPPResolution.y = desc.Height / 2; cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x; cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y; + cb.ssr_input_maxmip = float(input_desc.MipLevels - 1); + cb.ssr_input_resolution_max = (float)std::max(input_desc.Width, input_desc.Height); device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd); device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 80cdb6c60..95a285c95 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 38; // minor bug fixes, alterations, refactors, updates - const int revision = 18; + const int revision = 19; long GetVersion()