Skip to content

fix(wetness-effects): raindrop timing#2069

Merged
alandtse merged 8 commits into
community-shaders:devfrom
InTheBottle:fix(wetness-effects)-raindrop-timing
Apr 8, 2026
Merged

fix(wetness-effects): raindrop timing#2069
alandtse merged 8 commits into
community-shaders:devfrom
InTheBottle:fix(wetness-effects)-raindrop-timing

Conversation

@InTheBottle
Copy link
Copy Markdown
Contributor

@InTheBottle InTheBottle commented Apr 7, 2026

raindrops fade in\out with actual particles

Summary by CodeRabbit

  • Updates
    • Wetness Effects shader bumped to 3-2-0; improved rain blending and fade transitions for smoother, more accurate precipitation visuals.
  • Chores
    • Normalized line endings and added trailing newline in an upscaling shader metadata file.

InTheBottle and others added 2 commits April 6, 2026 20:31
raindrops fade\out with actual particles
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

No actionable suggestions for changed features.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR normalizes line endings in an upscaling shader INI, bumps the WetnessEffects shader feature version, and changes WetnessEffects rain blending to use weather-specific, threshold-aware fade-in/fade-out weights when composing final raining intensity.

Changes

Cohort / File(s) Summary
Configuration & Formatting
features/Upscaling/Shaders/Features/Upscaling.ini
Normalized CRLF → LF and added trailing newline; no key/value changes.
Version Update
features/Wetness Effects/Shaders/Features/WetnessEffects.ini
Incremented [Info].Version from 3-1-0 to 3-2-0.
Rain Blending Logic
src/Features/WetnessEffects.cpp
Introduced a file-scope linearstep helper and changed GetCommonBufferData() to compute current/last rain weights conditionally using precipitationBeginFadeIn / precipitationEndFadeOut (thresholded ramps) before composing data.Raining.

Sequence Diagram(s)

sequenceDiagram
    participant Sky
    participant CurrentWeather
    participant LastWeather
    participant Wetness
    participant Shader

    Sky ->> Wetness: provide currentWeatherPct, pointers to current/last weather
    Wetness ->> CurrentWeather: read isRainy?, precipitationBeginFadeIn
    Wetness ->> LastWeather: read isRainy?, precipitationEndFadeOut
    Wetness ->> Wetness: compute linearstep = clamp((pct - edge0)/(edge1 - edge0))
    Wetness ->> Wetness: currentWeight = isRainy? linearstep(pBegin, pEnd, pct) : 0
    Wetness ->> Wetness: lastWeight = isRainy? linearstep(pBegin, pEnd, pct) : 0
    Wetness ->> Wetness: data.Raining = currentRaining*currentWeight + lastRaining*lastWeight
    Wetness ->> Shader: upload CommonBuffer (includes data.Raining)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • doodlum

Poem

🐰 I tweak the ramps where raindrops play,
Newlines hop in neat array,
Weights whisper in fade-in light,
Pixels shimmer, damp and bright,
A rabbit pats the code—okay!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix(wetness-effects): raindrop timing' accurately reflects the main objective: aligning raindrop visual timing with particle behavior. The changes to WetnessEffects.cpp implement threshold-aware raindrop fading logic tied to precipitation begin/end points, directly addressing the stated goal.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Features/WetnessEffects.cpp (1)

738-740: Consider extracting the linearstep helper to reduce duplication.

The same linearstep lambda is defined both here and in CalculateWeatherWetness (lines 600-602). Extracting to a file-level helper or utility namespace would reduce duplication.

♻️ Optional: Extract to file-level helper

Add near the top of the file (after includes):

namespace
{
    inline float linearstep(float edge0, float edge1, float x)
    {
        return std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
    }
}

Then remove the inline lambda definitions in both functions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/WetnessEffects.cpp` around lines 738 - 740, Duplicate linearstep
lambda exists in WetnessEffects.cpp (inside the local block near the function
using it and also in CalculateWeatherWetness); extract a single helper by adding
an internal-linkage function named linearstep (e.g., inline float
linearstep(float edge0, float edge1, float x) in an anonymous namespace near the
top of the file) and replace/remove the local lambda definitions in both the
function that currently defines it and in CalculateWeatherWetness so both call
the shared linearstep helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Features/WetnessEffects.cpp`:
- Around line 738-752: The linearstep lambda can divide by zero when edge0 ==
edge1; update uses where linearstep is called (computing currentWeight and
lastWeight) to guard against that: before calling linearstep for fadeInThreshold
(used to set currentWeight) and fadeOutThreshold (used to set lastWeight) check
for equality (or near-equality) of edge0 and edge1 and handle those cases
explicitly (e.g., set linear step result to 0.0f or 1.0f as appropriate) so you
never call linearstep(1.0f,1.0f,...) or linearstep(0.0f,0.0f,...); reference the
linearstep lambda, fadeInThreshold, fadeOutThreshold, currentWeight, lastWeight,
and sky->currentWeatherPct when making the change (mirror the guard already used
in CalculateWeatherWetness).

---

Nitpick comments:
In `@src/Features/WetnessEffects.cpp`:
- Around line 738-740: Duplicate linearstep lambda exists in WetnessEffects.cpp
(inside the local block near the function using it and also in
CalculateWeatherWetness); extract a single helper by adding an internal-linkage
function named linearstep (e.g., inline float linearstep(float edge0, float
edge1, float x) in an anonymous namespace near the top of the file) and
replace/remove the local lambda definitions in both the function that currently
defines it and in CalculateWeatherWetness so both call the shared linearstep
helper.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee79a08a-d931-42f5-80df-a7a8d5bcf23b

📥 Commits

Reviewing files that changed from the base of the PR and between b4abab7 and 46f19b3.

📒 Files selected for processing (3)
  • features/Upscaling/Shaders/Features/Upscaling.ini
  • features/Wetness Effects/Shaders/Features/WetnessEffects.ini
  • src/Features/WetnessEffects.cpp

Comment thread src/Features/WetnessEffects.cpp Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/Features/WetnessEffects.cpp (1)

738-757: ⚠️ Potential issue | 🟠 Major

precipitationBeginFadeIn == 255 should step on at full transition, not stay at zero.

The divide-by-zero is gone, but this fallback hard-codes currentWeight to 0.0f for the maximum fade-in value. That makes a rainy weather never contribute to data.Raining, even after it becomes fully active with currentWeatherPct == 1.0f.

🔧 Proposed fix
 					auto linearstep = [](float edge0, float edge1, float x) {
-						return std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
+						if (edge0 >= edge1)
+							return x >= edge1 ? 1.0f : 0.0f;
+						return std::clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f);
 					};
@@
 					if (sky->currentWeather && sky->currentWeather->data.flags.any(RE::TESWeather::WeatherDataFlag::kRainy)) {
 						float fadeInThreshold = sky->currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f);
-						if (fadeInThreshold >= 1.0f)
-							currentWeight = 0.0f;  // fade-in at end of transition, never rains
-						else
-							currentWeight = linearstep(fadeInThreshold, 1.0f, sky->currentWeatherPct);
+						currentWeight = linearstep(fadeInThreshold, 1.0f, sky->currentWeatherPct);
 					}
@@
 					if (sky->lastWeather && sky->lastWeather->data.flags.any(RE::TESWeather::WeatherDataFlag::kRainy)) {
 						float fadeOutThreshold = sky->lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f);
-						if (fadeOutThreshold <= 0.0f)
-							lastWeight = 0.0f;  // immediate cutoff, no fade-out period
-						else
-							lastWeight = 1.0f - linearstep(0.0f, fadeOutThreshold, sky->currentWeatherPct);
+						lastWeight = 1.0f - linearstep(0.0f, fadeOutThreshold, sky->currentWeatherPct);
 					}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/WetnessEffects.cpp` around lines 738 - 757, The code treats
precipitationBeginFadeIn == 255 (fadeInThreshold >= 1.0f) as always setting
currentWeight to 0.0f, which prevents a rainy weather from contributing when
fully active; update the branch in the currentWeight calculation to set
currentWeight = 1.0f when sky->currentWeatherPct is fully transitioned (>= 1.0f)
and 0.0f otherwise (e.g., replace the hard-coded currentWeight = 0.0f with a
ternary using sky->currentWeatherPct), keeping the existing linearstep(path) for
the normal case; locate this change around variables/function names:
precipitationBeginFadeIn, fadeInThreshold, currentWeight, linearstep, and
sky->currentWeatherPct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/Features/WetnessEffects.cpp`:
- Around line 738-757: The code treats precipitationBeginFadeIn == 255
(fadeInThreshold >= 1.0f) as always setting currentWeight to 0.0f, which
prevents a rainy weather from contributing when fully active; update the branch
in the currentWeight calculation to set currentWeight = 1.0f when
sky->currentWeatherPct is fully transitioned (>= 1.0f) and 0.0f otherwise (e.g.,
replace the hard-coded currentWeight = 0.0f with a ternary using
sky->currentWeatherPct), keeping the existing linearstep(path) for the normal
case; locate this change around variables/function names:
precipitationBeginFadeIn, fadeInThreshold, currentWeight, linearstep, and
sky->currentWeatherPct.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4ddc4b0a-4af7-4f6e-bb45-f4d3ee8d979c

📥 Commits

Reviewing files that changed from the base of the PR and between 46f19b3 and 14f2ca3.

📒 Files selected for processing (1)
  • src/Features/WetnessEffects.cpp

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

✅ A pre-release build is available for this PR:
Download

Comment thread src/Features/WetnessEffects.cpp
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Features/WetnessEffects.cpp`:
- Around line 740-744: The guarded linearstep lambda defined near line 740
should be reused by WetnessEffects::CalculateWeatherWetness to avoid the
zero-width threshold bug: replace the unguarded linearstep calls in
WetnessEffects::CalculateWeatherWetness (which currently call
linearstep(precipitationEndFadeOut, precipitationEndFadeOut, ...)) with the
guarded helper (or move the lambda to a file-local function) so that the
edge0>=edge1 case returns the correct 0/1 behavior; update references to use the
single file-local linearstep and ensure data.Raining and precipitationEndFadeOut
logic now calls that guarded version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: afd96d58-c619-41dd-8c0c-b3b74e0504dc

📥 Commits

Reviewing files that changed from the base of the PR and between 419efe3 and ced89b8.

📒 Files selected for processing (1)
  • src/Features/WetnessEffects.cpp

Comment thread src/Features/WetnessEffects.cpp Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/Features/WetnessEffects.cpp (1)

739-753: PR metadata nit: add an issue keyword if one exists.

Title already follows Conventional Commits. If this fix is tracked, consider adding Fixes #<id> in the PR description for traceability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/WetnessEffects.cpp` around lines 739 - 753, This PR needs an
issue reference for traceability—update the PR description (or the commit
message that introduced changes in src/Features/WetnessEffects.cpp) to include
the issue keyword like "Fixes #<id>" so the change affecting symbols such as
currentWeight/lastWeight and the linearstep logic in WetnessEffects.cpp is
linked to the tracker; add the correct issue number and ensure the PR title or
description contains "Fixes #<id>".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Features/WetnessEffects.cpp`:
- Around line 739-753: This PR needs an issue reference for traceability—update
the PR description (or the commit message that introduced changes in
src/Features/WetnessEffects.cpp) to include the issue keyword like "Fixes #<id>"
so the change affecting symbols such as currentWeight/lastWeight and the
linearstep logic in WetnessEffects.cpp is linked to the tracker; add the correct
issue number and ensure the PR title or description contains "Fixes #<id>".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6786672e-d687-4ec9-80ad-92d079fc1c93

📥 Commits

Reviewing files that changed from the base of the PR and between ced89b8 and 502c83e.

📒 Files selected for processing (1)
  • src/Features/WetnessEffects.cpp

@alandtse alandtse merged commit ae325ac into community-shaders:dev Apr 8, 2026
17 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit ae325ac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants