Skip to content

Commit ba687bd

Browse files
Fix snow volumes' distant fading (#1181)
* Fix snow volumes' distant fading Fade distances should be scaled by the View Distance slider for more consistency across settings. * Use find_pattern
1 parent db74a74 commit ba687bd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/seasonal/snow.ixx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ public:
116116
pattern = find_pattern("88 41 61 F3 0F 10 0D", "48 60 8A 15 ? ? ? ? 88 50 61");
117117
pRainEmitter = *pattern.get_first<gtaRainEmitter*>(15);
118118
pStormEmitter = reinterpret_cast<gtaRainEmitter*>((uintptr_t)pRainEmitter + 0xD0);
119+
120+
pattern = find_pattern("F3 0F 11 05 ? ? ? ? 66 0F 6E 05 ? ? ? ? 0F 5B C0 F3 0F 59 05 ? ? ? ? F3 0F 59 05 ? ? ? ? F3 0F 58 05 ? ? ? ? F3 0F 11 04 24", "F3 0F 11 05 ? ? ? ? F3 0F 2A 05 ? ? ? ? F3 0F 59 05 ? ? ? ? F3 0F 58 05 ? ? ? ? D3 E6");
121+
if (!pattern.empty())
122+
{
123+
dwViewDistance = *pattern.get_first<float*>(4);
124+
}
119125
}
120126

121127
auto Enable() -> void override
@@ -176,6 +182,8 @@ private:
176182

177183
static inline float* pWetness = nullptr;
178184

185+
static inline float* dwViewDistance = nullptr;
186+
179187
static auto __fastcall OnDeviceLost() -> void
180188
{
181189
mDiffuseRT = nullptr;
@@ -501,8 +509,8 @@ private:
501509

502510
float Distance = std::sqrt(DeltaX * DeltaX + DeltaY * DeltaY + DeltaZ * DeltaZ);
503511

504-
float FadeStart = 75.0f;
505-
float FadeEnd = 150.0f;
512+
float FadeStart = 30.0f * *dwViewDistance;
513+
float FadeEnd = 105.0f * *dwViewDistance;
506514

507515
float DistanceFade = 1.0f - Smoothstep(FadeStart, FadeEnd, Distance);
508516

0 commit comments

Comments
 (0)