diff --git a/features/Upscaling/Shaders/Features/Upscaling.ini b/features/Upscaling/Shaders/Features/Upscaling.ini index badc614325..e6ca8e41dc 100644 --- a/features/Upscaling/Shaders/Features/Upscaling.ini +++ b/features/Upscaling/Shaders/Features/Upscaling.ini @@ -1,2 +1,2 @@ -[Info] -Version = 1-3-1 \ No newline at end of file +[Info] +Version = 1-3-1 diff --git a/features/Wetness Effects/Shaders/Features/WetnessEffects.ini b/features/Wetness Effects/Shaders/Features/WetnessEffects.ini index 6e1d334916..cacb2edcb2 100644 --- a/features/Wetness Effects/Shaders/Features/WetnessEffects.ini +++ b/features/Wetness Effects/Shaders/Features/WetnessEffects.ini @@ -1,2 +1,2 @@ [Info] -Version = 3-1-0 +Version = 3-2-0 diff --git a/src/Features/WetnessEffects.cpp b/src/Features/WetnessEffects.cpp index 4307013b63..dd077abf04 100644 --- a/src/Features/WetnessEffects.cpp +++ b/src/Features/WetnessEffects.cpp @@ -566,6 +566,13 @@ static void DrawRainTypeLabel(const char* prefix, float rate) // Weather/Precipitation Analysis Helpers // ===================== +static float linearstep(float edge0, float edge1, float x) +{ + if (edge0 >= edge1) + return x >= edge1 ? 1.0f : 0.0f; + return std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); +} + float WetnessEffects::GetRainIntensity(RE::NiPointer precipObject, RE::TESWeather* weather) { if (!precipObject || !weather || !weather->precipitationData) { @@ -599,10 +606,6 @@ WetnessEffects::WeatherWetnessResult WetnessEffects::CalculateWeatherWetness(RE: return result; } - auto linearstep = [](float edge0, float edge1, float x) { - return std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); - }; - if (isCurrentWeather) { // Current weather uses fade-in logic float fadeValue = weather->data.precipitationBeginFadeIn; @@ -733,10 +736,22 @@ WetnessEffects::PerFrame WetnessEffects::GetCommonBufferData() const lastRaining = GetRainIntensity(precip->lastPrecip, sky->lastWeather); } - // Use weighted average based on weather transition percentage instead of additive - // This prevents unrealistic rain intensity spikes during transitions - float currentWeight = sky->currentWeatherPct; - float lastWeight = 1.0f - sky->currentWeatherPct; + // Apply the same fade-in/fade-out thresholds the game uses in + // Sky::IsRaining() to prevent CS effects appearing before the + // game's own rain particles become visible, with a smooth ramp + // from the threshold to full intensity. + float currentWeight = 0.0f; + if (sky->currentWeather && sky->currentWeather->data.flags.any(RE::TESWeather::WeatherDataFlag::kRainy)) { + float fadeInThreshold = sky->currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f); + currentWeight = linearstep(fadeInThreshold, 1.0f, sky->currentWeatherPct); + } + + float lastWeight = 0.0f; + if (sky->lastWeather && sky->lastWeather->data.flags.any(RE::TESWeather::WeatherDataFlag::kRainy)) { + float fadeOutThreshold = sky->lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f); + lastWeight = 1.0f - linearstep(0.0f, fadeOutThreshold, sky->currentWeatherPct); + } + data.Raining = (currentRaining * currentWeight) + (lastRaining * lastWeight); }