From b0cc4bdf58bb89f0a17385001aa5c46ea140ea3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Wed, 11 Feb 2026 17:26:35 +0100 Subject: [PATCH] path tracing volumetric cloud fix --- WickedEngine/shaders/raytraceCS.hlsl | 5 ++-- WickedEngine/shaders/skyHF.hlsli | 4 +-- WickedEngine/wiGraphicsDevice_Vulkan.h | 14 ++++------- WickedEngine/wiRenderPath3D_PathTracing.cpp | 27 +++++++++++---------- WickedEngine/wiVersion.cpp | 2 +- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/WickedEngine/shaders/raytraceCS.hlsl b/WickedEngine/shaders/raytraceCS.hlsl index 244db18b9..567342a14 100644 --- a/WickedEngine/shaders/raytraceCS.hlsl +++ b/WickedEngine/shaders/raytraceCS.hlsl @@ -141,15 +141,16 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex) if (exit_sky) { float3 envColor; + bool clouds_enabled = bounce > 0; [branch] if (IsStaticSky()) { // We have envmap information in a texture: - envColor = GetStaticSkyColor(ray.Direction); + envColor = GetStaticSkyColor(ray.Direction, clouds_enabled); } else { - envColor = GetDynamicSkyColor(ray.Direction); + envColor = GetDynamicSkyColor(ray.Direction, true, false, false, false, false, false, clouds_enabled); } result += max(0, energy * envColor); break; diff --git a/WickedEngine/shaders/skyHF.hlsli b/WickedEngine/shaders/skyHF.hlsli index 02cfbc800..2a882b63b 100644 --- a/WickedEngine/shaders/skyHF.hlsli +++ b/WickedEngine/shaders/skyHF.hlsli @@ -155,9 +155,9 @@ float3 GetDynamicSkyColor(in float2 pixel, in float3 V, bool sun_enabled = true, return sky; } -float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool dark_enabled = false, bool stationary = false) +float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool dark_enabled = false, bool stationary = false, bool highQuality = false, bool perPixelNoise = false, bool receiveShadow = false, bool clouds_enabled = true) { - return GetDynamicSkyColor(float2(0.0f, 0.0f), V, sun_enabled, dark_enabled, stationary, false, false, false, true); + return GetDynamicSkyColor(float2(0.0f, 0.0f), V, sun_enabled, dark_enabled, stationary, highQuality, perPixelNoise, receiveShadow, clouds_enabled); } float3 GetStaticSkyColor(in float3 V, bool clouds_enabled = true) diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h index 4ca6e9a6a..f8142c5a3 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.h +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -851,25 +851,21 @@ namespace wi::graphics int allocate() { - locker.lock(); + std::scoped_lock lck(locker); if (!freelist.empty()) { int index = freelist.back(); freelist.pop_back(); - locker.unlock(); return index; } - locker.unlock(); return -1; } void free(int index) { - if (index >= 0) - { - locker.lock(); - freelist.push_back(index); - locker.unlock(); - } + if (index < 0) + return; + std::scoped_lock lck(locker); + freelist.push_back(index); } }; BindlessDescriptorHeap bindlessSampledImages; diff --git a/WickedEngine/wiRenderPath3D_PathTracing.cpp b/WickedEngine/wiRenderPath3D_PathTracing.cpp index 00ec84375..b2e084f90 100644 --- a/WickedEngine/wiRenderPath3D_PathTracing.cpp +++ b/WickedEngine/wiRenderPath3D_PathTracing.cpp @@ -433,6 +433,20 @@ namespace wi wi::renderer::DrawShadowmaps(visibility_main, cmd); } + if (scene->weather.IsVolumetricClouds()) + { + wi::renderer::Postprocess_VolumetricClouds( + volumetriccloudResources, + cmd, + *camera, + camera_previous, + camera_reflection, + false, + scene->weather.volumetricCloudsWeatherMapFirst.IsValid() ? &scene->weather.volumetricCloudsWeatherMapFirst.GetTexture() : nullptr, + scene->weather.volumetricCloudsWeatherMapSecond.IsValid() ? &scene->weather.volumetricCloudsWeatherMapSecond.GetTexture() : nullptr + ); + } + }); if (scene->terrains.GetCount() > 0) @@ -489,19 +503,6 @@ namespace wi cmd ); } - if (scene->weather.IsVolumetricClouds()) - { - wi::renderer::Postprocess_VolumetricClouds( - volumetriccloudResources, - cmd, - *camera, - camera_previous, - camera_reflection, - false, - scene->weather.volumetricCloudsWeatherMapFirst.IsValid() ? &scene->weather.volumetricCloudsWeatherMapFirst.GetTexture() : nullptr, - scene->weather.volumetricCloudsWeatherMapSecond.IsValid() ? &scene->weather.volumetricCloudsWeatherMapSecond.GetTexture() : nullptr - ); - } RenderVolumetrics(cmd); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 6d459b109..3aa122b08 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 72; // minor bug fixes, alterations, refactors, updates - const int revision = 33; + const int revision = 34; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);