Repository navigation
Fix rain wetness depending on frame rate, add level.set_rain_wetness - #765
Conversation
|
|
||
| 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Good point, changed to 166. That's only 0.4% faster than before at 60 fps, so it doesn't change how it plays.
| 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; |
There was a problem hiding this comment.
Same here, it's going to be "1 / WETNESS_CHANGE_RATE" instead of 0.0001f (or whatever that new constant)
|
LGTM |
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.
Rain wetness (
wetness_factor) was changed by a fixed amount every frame inCEnvDescriptorMixer::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.fTimeDeltausing a newWETNESS_CHANGE_TIMEconstant of 166 seconds, which matches the old per-frame rate at 60 fps to within 0.4%.ssfx_wetness_multiplierkeeps 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 tolevel.rain_wetness(), clamped to 0 to 1, and listed it inlua_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 atr__framelimit 30and 0.084 atr__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).