Skip to main content

Fog & Atmosphere System

Dynamic fog that intensifies based on proximity and gaze direction toward fog activator volumes.

Fog Activators

FogActivator is a Flamework component attached to tagged parts in the world.

Activation Formula

alpha = distanceFactor × gazeFactor
  • Distance Factor: Linear falloff within 80-stud radius (1.0 at center, 0.0 at edge)
  • Gaze Factor: 60-degree cone check using dot product (cos threshold)
  • Both factors are clamped to [0, 1]

Update Loop

Every frame, all activators compute their alpha. The maximum alpha across all activators is written to the fogOverrideAlpha atom.

Rendering

LightingController reads fogOverrideAlpha and modulates the Atmosphere density:

const targetDensity = baseDensity + fogOverrideAlpha() * MAX_FOG_DENSITY;
currentDensity = lerp(currentDensity, targetDensity, FOG_LERP_SPEED);
  • MAX_FOG_DENSITY: 1.0
  • FOG_LERP_SPEED: 0.08 (smooth transition)
  • baseDensity: Captured from the Atmosphere instance at startup

Key Files

FilePurpose
fog-activator.tsComponent computing per-activator alpha
fog-state.tsfogOverrideAlpha atom
lighting-controller.tsConsumes fog alpha, applies to Atmosphere