diff --git a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli index 2716a950e..8979699e4 100644 --- a/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli +++ b/features/Wetness Effects/Shaders/WetnessEffects/WetnessEffects.hlsli @@ -6,15 +6,11 @@ struct PerPassWetnessEffects row_major float3x4 DirectionalAmbientWS; uint EnableWetnessEffects; float MaxRainWetness; - float MaxSnowWetness; - float MaxFogWetness; float MaxShoreWetness; uint ShoreRange; float PuddleRadius; float PuddleMaxAngle; float PuddleMinWetness; - float FogPowerThreshold; - float FogNearDistanceThreshold; }; StructuredBuffer perPassWetnessEffects : register(t22); diff --git a/src/Features/WetnessEffects.cpp b/src/Features/WetnessEffects.cpp index 1e3ce9502..2c845925f 100644 --- a/src/Features/WetnessEffects.cpp +++ b/src/Features/WetnessEffects.cpp @@ -5,27 +5,17 @@ const float MIN_START_PERCENTAGE = 0.05f; const float DEFAULT_TRANSITION_PERCENTAGE = 1.0f; const float TRANSITION_CURVE_MULTIPLIER = 2.0f; const float TRANSITION_DENOMINATOR = 256.0f; -float FOG_POWER_THRESHOLD = 0.5f; -float FOG_NEAR_DISTANCE_THRESHOLD = 0.0f; const float DRY_WETNESS = 0.0f; -const float DAY = 0.0f; -const float NIGHT = 1.0f; -const int TIME_BEFORE = 1800; -const int TIME_AFTER = 2700; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( WetnessEffects::Settings, EnableWetnessEffects, MaxRainWetness, - MaxSnowWetness, - MaxFogWetness, MaxShoreWetness, ShoreRange, PuddleRadius, PuddleMaxAngle, - PuddleMinWetness, - FogPowerThreshold, - FogNearDistanceThreshold) + PuddleMinWetness) void WetnessEffects::DrawSettings() { @@ -40,8 +30,6 @@ void WetnessEffects::DrawSettings() } ImGui::SliderFloat("Max Rain Wetness", &settings.MaxRainWetness, 0.0f, 1.0f); - ImGui::SliderFloat("Max Snow Wetness", &settings.MaxSnowWetness, 0.0f, 1.0f); - ImGui::SliderFloat("Max Fog Wetness", &settings.MaxFogWetness, 0.0f, 1.0f); ImGui::SliderFloat("Max Shore Wetness", &settings.MaxShoreWetness, 0.0f, 1.0f); ImGui::SliderInt("Shore Range", (int*)&settings.ShoreRange, 1, 64); @@ -50,24 +38,6 @@ void WetnessEffects::DrawSettings() ImGui::SliderFloat("Puddle Max Angle", &settings.PuddleMaxAngle, 0.0f, 1.0f); ImGui::SliderFloat("Puddle Min Wetness", &settings.PuddleMinWetness, 0.0f, 1.0f); - ImGui::SliderFloat("Max Fog Power", &settings.FogPowerThreshold, 0.0f, 1.0f); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::Text("The maxiumum Fog Power considered foggy weather. (Try raising this if foggy weather isn't causing wetness)"); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); - } - - ImGui::SliderFloat("Max Fog Distance", &settings.FogNearDistanceThreshold, 0.0f, 10000.0f); - if (ImGui::IsItemHovered()) { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::Text("The maximum Fog Distance considered foggy weather. (Try raising this if foggy weather isn't causing wetness)"); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); - } - ImGui::TreePop(); } } @@ -97,70 +67,7 @@ float WetnessEffects::CalculateWetness(RE::TESWeather* weather, RE::Sky* sky) if (weather->precipitationData && weather->data.flags.any(RE::TESWeather::WeatherDataFlag::kRainy)) { // Raining wetness = settings.MaxRainWetness; - } else if (weather->precipitationData && weather->data.flags.any(RE::TESWeather::WeatherDataFlag::kSnow)) { - // Snowing - wetness = settings.MaxSnowWetness; - } else if ((weather->fogData.dayNear <= FOG_NEAR_DISTANCE_THRESHOLD && weather->fogData.dayPower <= FOG_POWER_THRESHOLD) || - (weather->fogData.nightNear <= FOG_NEAR_DISTANCE_THRESHOLD && weather->fogData.nightPower <= FOG_POWER_THRESHOLD)) { - // Foggy - could be foggy during day, night, or both - float dayWetness = (weather->fogData.dayNear <= FOG_NEAR_DISTANCE_THRESHOLD && weather->fogData.dayPower <= FOG_POWER_THRESHOLD) ? settings.MaxFogWetness : DRY_WETNESS; - float nightWetness = (weather->fogData.nightNear <= FOG_NEAR_DISTANCE_THRESHOLD && weather->fogData.nightPower <= FOG_POWER_THRESHOLD) ? settings.MaxFogWetness : DRY_WETNESS; - // If both, skip interpolating between day and night values - if (dayWetness == nightWetness) { - wetness = dayWetness; - } else { - float DayNightTransition = DEFAULT_TRANSITION_PERCENTAGE; - // Set the Day Night Transition with Day = 0, and Night = 1 - if (auto calendar = RE::Calendar::GetSingleton()) { - if (auto currentClimate = sky->currentClimate) { - struct tm sunriseBeginTM = currentClimate->timing.sunrise.GetBeginTime(); - struct tm sunriseEndTM = currentClimate->timing.sunrise.GetEndTime(); - struct tm sunsetBeginTM = currentClimate->timing.sunset.GetBeginTime(); - struct tm sunsetEndTM = currentClimate->timing.sunset.GetEndTime(); - float gameHour = calendar->GetHour(); - // Skyrim doesn't seem to use seconds, but doing this in seconds just in case - // Skyrim transitions weather values between day and night in one hour starting 30 minutes before sunrise starts or sunset ends - int sunriseBeginTime = (sunriseBeginTM.tm_hour * 3600) + (sunriseBeginTM.tm_min * 60) + sunriseBeginTM.tm_sec; - int sunsetEndTime = (sunsetEndTM.tm_hour * 3600) + (sunsetEndTM.tm_min * 60) + sunsetEndTM.tm_sec; - int time = static_cast(gameHour * 3600); - int nightToDayBegin = sunriseBeginTime - TIME_BEFORE; - int nightToDayEnd = sunriseBeginTime + TIME_AFTER; - int dayToNightBegin = sunsetEndTime - TIME_BEFORE; - int dayToNightEnd = sunsetEndTime + TIME_AFTER; - - if (dayToNightEnd > dayToNightBegin && dayToNightBegin >= nightToDayEnd && nightToDayEnd > nightToDayBegin && nightToDayBegin >= 0) { - if ((time - nightToDayBegin) < 0 || (time - dayToNightEnd) > 0) { - // Night - DayNightTransition = NIGHT; - } else if ((time - nightToDayEnd) <= 0) { - // During sunrise, night 1 -> day 0 - DayNightTransition = 1.0f - (static_cast(time - nightToDayBegin) / static_cast(nightToDayEnd - nightToDayBegin)); - } else if ((time - dayToNightBegin) < 0) { - // During day - DayNightTransition = DAY; - } else if ((time - dayToNightEnd) <= 0) { - // During sunset, day 0 -> night 1 - DayNightTransition = static_cast(time - dayToNightBegin) / static_cast(dayToNightEnd - dayToNightBegin); - } else { - // This should never happen - logger::error("Invalid Time Calculating Fog"); - } - } - - // Adjust the transition curve to ease in/out of the transition - DayNightTransition = (exp2(TRANSITION_CURVE_MULTIPLIER * log2(DayNightTransition))); - } - } - // Handle wetness transition between day and night - wetness = std::lerp(dayWetness, nightWetness, DayNightTransition); - } - } else if (weather->data.flags.any(RE::TESWeather::WeatherDataFlag::kCloudy)) { - // Cloudy - wetness = DRY_WETNESS; - } else { - // Pleasant - wetness = DRY_WETNESS; - } + } } } return wetness; @@ -175,8 +82,6 @@ void WetnessEffects::Draw(const RE::BSShader* shader, const uint32_t) PerPass data{}; data.Wetness = DRY_WETNESS; - FOG_POWER_THRESHOLD = settings.FogPowerThreshold; - FOG_NEAR_DISTANCE_THRESHOLD = settings.FogNearDistanceThreshold; if (settings.EnableWetnessEffects) { if (auto player = RE::PlayerCharacter::GetSingleton()) { diff --git a/src/Features/WetnessEffects.h b/src/Features/WetnessEffects.h index fe07a1976..5fe21230e 100644 --- a/src/Features/WetnessEffects.h +++ b/src/Features/WetnessEffects.h @@ -22,15 +22,11 @@ struct WetnessEffects : Feature { uint EnableWetnessEffects = true; float MaxRainWetness = 1.0f; - float MaxSnowWetness = 0.8f; - float MaxFogWetness = 0.5f; float MaxShoreWetness = 0.5f; uint ShoreRange = 32; float PuddleRadius = 1.0f; float PuddleMaxAngle = 0.95f; float PuddleMinWetness = 0.75f; - float FogPowerThreshold = 0.5f; - float FogNearDistanceThreshold = 0.0f; }; struct alignas(16) PerPass