Skip to content

Hopefully fix fog light flicker precision#4906

Merged
qaisjp merged 4 commits intomultitheftauto:masterfrom
Zephkek:fix/4901-fog-light-flicker-precision
May 10, 2026
Merged

Hopefully fix fog light flicker precision#4906
qaisjp merged 4 commits intomultitheftauto:masterfrom
Zephkek:fix/4901-fog-light-flicker-precision

Conversation

@Zephkek
Copy link
Copy Markdown
Contributor

@Zephkek Zephkek commented May 8, 2026

Summary

Adjust weather interpolation resync precision in CWeatherSA::ResyncInterpolationWithGameClock.
This keeps InterpolationValue aligned with the engine comparison path and removes fog transition light flicker.

Motivation

Fog to sunny flicker was fixed, but lights still flickered when blending into fog.
This change prevents precision mismatches that can trigger the wrap branch and spike light related weather values.

Test plan

Test in-game on v26595 with fast clock and repeated setWeatherBlended into fog.
Verify car lights, traffic lights, and other 2dfx lights no longer flash each second during the blend.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Zephkek added 3 commits May 6, 2026 19:17
…ultitheftauto#4803)

ResyncInterpolationWithGameClock snapped CWeather::InterpolationValue
to minute/60, dropping the seconds component. CTimeCycle::CalcColoursForPoint
then blended m_CurrentColours per game-minute instead of per frame, so
m_fSpriteBrightness (vehicle coronas) and m_wShadowStrength (vehicle
shadows) ticked visibly when the game clock runs fast.

Match the value CWeather::Update derives at 0x72B897
(seconds/3600 + minutes/60) so the wrap-suppression still holds and
m_CurrentColours interpolates smoothly each frame.
…into fix/4803-vehicle-corona-shadow-flicker
Compute interpolation in double and step one float ULP down when needed to preserve the engine v0 >= InterpolationValue invariant and prevent precision-induced 2dfx light flicker.
@Zephkek Zephkek changed the title Fix/4901 fog light flicker precision Hopefully fix fog light flicker precision May 8, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts CWeatherSA::ResyncInterpolationWithGameClock to compute InterpolationValue using a double-precision path intended to match the game engine’s own interpolation calculation more closely, reducing precision-triggered wrap behavior that can manifest as light flicker during fog blending.

Changes:

  • Reworks the interpolation calculation to mirror the engine’s (seconds * k + minutes) * k double math path.
  • Adds a float-rounding correction intended to ensure the stored float does not exceed the computed double value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Client/game_sa/CWeatherSA.cpp
Copy link
Copy Markdown
Member

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

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

Ty!

@qaisjp qaisjp merged commit c12ffaf into multitheftauto:master May 10, 2026
14 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