diff --git a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl index 642336042b..68da4ced86 100644 --- a/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl +++ b/features/Dynamic Cubemaps/Shaders/DynamicCubemaps/InferCubemapCS.hlsl @@ -90,7 +90,8 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray OutputTextu } #if defined(REFLECTIONS) - color.rgb = lerp(color.rgb, Color::IrradianceToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0.0).rgb), saturate(mipLevel / 7.0)); + float fallbackWeight = saturate(mipLevel / 7.0) * SharedData::cubemapCreatorSettings.ReflectionFallbackAmount; + color.rgb = lerp(color.rgb, Color::IrradianceToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0.0).rgb), fallbackWeight); #else color.rgb = lerp(color.rgb, color.rgb * DefaultCubemap.SampleLevel(LinearSampler, uv, 0.0).xyz, saturate(mipLevel / 7.0)); #endif diff --git a/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini b/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini index 82f2c91940..0edac074f9 100644 --- a/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini +++ b/features/Dynamic Cubemaps/Shaders/Features/DynamicCubemaps.ini @@ -1,5 +1,5 @@ [Info] -Version = 2-3-1 +Version = 2-3-2 [Nexus] autoupload = false diff --git a/package/Shaders/Common/SharedData.hlsli b/package/Shaders/Common/SharedData.hlsli index cae68835fe..b9d913a899 100644 --- a/package/Shaders/Common/SharedData.hlsli +++ b/package/Shaders/Common/SharedData.hlsli @@ -60,9 +60,13 @@ namespace SharedData struct CubemapCreatorSettings { uint Enabled; - float3 pad0; + uint EnabledSSR; + float2 pad0; float4 CubemapColor; + + float ReflectionFallbackAmount; + float3 pad1; }; struct TerraOccSettings diff --git a/src/Features/DynamicCubemaps.cpp b/src/Features/DynamicCubemaps.cpp index 560c902452..83fa572f39 100644 --- a/src/Features/DynamicCubemaps.cpp +++ b/src/Features/DynamicCubemaps.cpp @@ -12,7 +12,8 @@ constexpr auto MIPLEVELS = 8; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( DynamicCubemaps::Settings, EnabledSSR, - EnabledCreator); + EnabledCreator, + ReflectionFallbackAmount); std::vector> DynamicCubemaps::GetShaderDefineOptions() { @@ -26,6 +27,14 @@ std::vector> DynamicCubemaps::GetS void DynamicCubemaps::DrawSettings() { + if (ImGui::TreeNodeEx("Native Cubemap Fallback", ImGuiTreeNodeFlags_DefaultOpen)) { + ImGui::SliderFloat("Fallback Amount", &settings.ReflectionFallbackAmount, kReflectionFallbackMin, kReflectionFallbackMax, "%.2f", ImGuiSliderFlags_AlwaysClamp); + if (auto _tt = Util::HoverTooltipWrapper()) { + ImGui::Text("Controls how much the game's reflection cubemap fills missing dynamic reflection directions."); + } + ImGui::TreePop(); + } + if (ImGui::TreeNodeEx("Screen Space Reflections", ImGuiTreeNodeFlags_DefaultOpen)) { recompileFlag |= ImGui::Checkbox("Enable Screen Space Reflections", reinterpret_cast(&settings.EnabledSSR)); if (auto _tt = Util::HoverTooltipWrapper()) { @@ -131,6 +140,7 @@ void DynamicCubemaps::DrawSettings() void DynamicCubemaps::LoadSettings(json& o_json) { settings = o_json; + settings.ReflectionFallbackAmount = std::clamp(settings.ReflectionFallbackAmount, kReflectionFallbackMin, kReflectionFallbackMax); if (REL::Module::IsVR()) { Util::LoadGameSettings(iniVRCubeMapSettings); } diff --git a/src/Features/DynamicCubemaps.h b/src/Features/DynamicCubemaps.h index 7b23744d41..413993fcbd 100644 --- a/src/Features/DynamicCubemaps.h +++ b/src/Features/DynamicCubemaps.h @@ -12,6 +12,10 @@ class MenuOpenCloseEventHandler : public RE::BSTEventSink