Skip to content

Fix rain wetness depending on frame rate, add level.set_rain_wetness - #765

Merged
themrdemonized merged 5 commits into
themrdemonized:prfrom
Um-Yeah-No:rain-wetness-fix
Oct 26, 2026
Merged

themrdemonized merged 5 commits into
themrdemonized:prfrom
Um-Yeah-No:rain-wetness-fix

Conversation

@Um-Yeah-No

@Um-Yeah-No Um-Yeah-No commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Rain wetness (wetness_factor) was changed by a fixed amount every frame in CEnvDescriptorMixer::lerp, so it built up and dried faster the higher the frame rate. At 144 fps it was 2.4 times faster than at 60, and at 30 fps it was half as fast.

The step is now scaled by Device.fTimeDelta using a new WETNESS_CHANGE_TIME constant of 166 seconds, which matches the old per-frame rate at 60 fps to within 0.4%. ssfx_wetness_multiplier keeps the same meaning and range, so the buildup and drying settings in SSS now give the same speed at any frame rate.

I also added level.set_rain_wetness(float) next to level.rain_wetness(), clamped to 0 to 1, and listed it in lua_help_ex.script. Wetness isn't stored in saves, so a load or a new game starts with whatever the previous session left, or 0 after a fresh start. The setter lets a script save and restore it, or reset it for a new game.

Tested on both main and the MT branch with rain at 0.7 and ssfx_wetness_multiplier 10,0.5. On the current release (2026.10.11), wetness rose by 0.042 every 2 seconds at r__framelimit 30 and 0.084 at r__framelimit 60. Uncapped, it rose by 0.30 on main and 0.39 on MT (about 220 and 280 fps), going from dry to fully wet in 5 to 7 seconds. With this change it rose by 0.084 in every case.

To test the setter, a script saved level.rain_wetness() with the game and restored it on load. After restarting the game, wetness started at 0 and was restored to the saved value (0.483 and 1.000).

Comment thread src/xrEngine/Environment_misc.cpp Outdated

if (rain_density > 0.f)
env->wetness_factor += ( rain_density * ssfx_wetness_multiplier.x) / 10000.f;
env->wetness_factor += ( rain_density * ssfx_wetness_multiplier.x) / 10000.f * wetness_step;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can instead change the factor here (so instead of 10000, let's say 150) and declare it as a constant somewhere in this file or in the header

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done. I used 10000 / 60 rather than 150 so 60 fps stays exactly the same and existing SSS settings keep their feel (150 would be about 11% faster). I called it WETNESS_CHANGE_TIME since it's the seconds for a full change at multiplier 1. Both lines use it now.

@damoldavskiy damoldavskiy Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe write it just "166" then? 10000 is only historical value here, if the physical meaning of this var is seconds to go from one state to another, makes sense to write is as is imo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed to 166. That's only 0.4% faster than before at 60 fps, so it doesn't change how it plays.

Comment thread src/xrEngine/Environment_misc.cpp Outdated
env->wetness_factor += ( rain_density * ssfx_wetness_multiplier.x) / 10000.f * wetness_step;
else
env->wetness_factor -= 0.0001f * ssfx_wetness_multiplier.y;
env->wetness_factor -= 0.0001f * ssfx_wetness_multiplier.y * wetness_step;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, it's going to be "1 / WETNESS_CHANGE_RATE" instead of 0.0001f (or whatever that new constant)

@damoldavskiy

Copy link
Copy Markdown
Contributor

LGTM

qy0214 added a commit to qy0214/xray-monolith-MT-CN that referenced this pull request Oct 24, 2026
Upstream PR themrdemonized#765 (themrdemonized/xray-monolith): drying used a fixed
per-frame step, so at high frame rates the ground dried ~2.4x faster
than authored - directly relevant to our DLSS high-FPS scenarios. The
step now scales with Device.fTimeDelta, and level.set_rain_wetness is
exposed for scripts.
@themrdemonized
themrdemonized changed the base branch from all-in-one-vs2022-wpo to pr October 26, 2026 03:17
@themrdemonized
themrdemonized merged commit 1ae4e87 into themrdemonized:pr Oct 26, 2026
17 of 18 checks passed
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.

3 participants