fogFactor method

double fogFactor(
  1. double distance
)

Calculates fog factor for a given distance from camera. Returns 0 (no fog) to 1 (fully fogged).

Implementation

double fogFactor(double distance) {
  if (!enabled) return 0;

  // Exponential fog
  final factor = 1 - (1 / (1 + density * distance * distance));
  return factor.clamp(0, 1);
}