Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/Upscaling/Shaders/Features/Upscaling.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Info]
Version = 1-3-1
[Info]
Version = 1-3-1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Info]
Version = 3-1-0
Version = 3-2-0
31 changes: 23 additions & 8 deletions src/Features/WetnessEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RE::BSGeometry> precipObject, RE::TESWeather* weather)
{
if (!precipObject || !weather || !weather->precipitationData) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Loading