Class Atmosphere

java.lang.Object
eu.svjatoslav.aukio.e3d.renderer.raster.lighting.Atmosphere

public final class Atmosphere extends Object
Optional distance haze ("atmospheric perspective"): geometry fades toward the sky color as camera-space depth grows, factor f = 1 - exp(-depth / scale). Disabled by default; enable per scene (setEnabled(boolean), the Fallout 4 environment does) or globally with -De3d.atmosphere=true / e3d.atmosphere: true in the config file (bugreport-20261006-000922).

Cost model: the factor is evaluated once per polygon per frame and folded into the same per-polygon light multiplier the span loops already apply — texel * (light*(1-f)) + sky*f — so the per-pixel price on textured triangles is one ADD per channel and no additional multiplication. Solid polygons precompute one shaded color per polygon, so their per-pixel cost is exactly zero. Lightmapped triangles sit inside the stage-3 bubble a few hundred units from the camera, where the factor rounds to zero for any practical scale; that path is deliberately left untouched.

The haze target color is the configured e3d.atmosphereColor when set, otherwise the scene's sky color (LightingManager.getSkyColor()), so the horizon blends into the backdrop seamlessly. With neither, haze is inert.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyHaze(Color shaded, float f, Color target)
    Blends a per-polygon shaded color toward the haze target in place: c = c*(1-f) + target*f.
    static boolean
    Returns whether distance haze is active.
    static float
    factor(double cameraDepth)
    The haze factor for a camera-space depth: 0 at the camera, approaching 1 at infinity.
    static void
    Drops all runtime overrides; configuration applies again.
    static double
    Returns the haze scale in world units.
    static void
    setColor(Color color)
    Sets the haze target color at runtime.
    static void
    setEnabled(boolean enabled)
    Enables or disables the haze at runtime (environment modules).
    static void
    setScale(double scale)
    Sets the haze scale at runtime: the camera depth at which the haze factor reaches ~63% (1 - 1/e).
    static Color
    Resolves the haze target color: runtime override, then the configured e3d.atmosphereColor, then the scene's sky color.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setEnabled

      public static void setEnabled(boolean enabled)
      Enables or disables the haze at runtime (environment modules). Wins over e3d.atmosphere; see resetOverrides().
      Parameters:
      enabled - true to haze distant geometry toward the sky color
    • setScale

      public static void setScale(double scale)
      Sets the haze scale at runtime: the camera depth at which the haze factor reaches ~63% (1 - 1/e). Wins over e3d.atmosphereScale.
      Parameters:
      scale - world units
    • setColor

      public static void setColor(Color color)
      Sets the haze target color at runtime. Wins over e3d.atmosphereColor and the scene sky color.
      Parameters:
      color - haze color, or null to fall back to configuration
    • resetOverrides

      public static void resetOverrides()
      Drops all runtime overrides; configuration applies again.
    • enabled

      public static boolean enabled()
      Returns whether distance haze is active.
    • scale

      public static double scale()
      Returns the haze scale in world units.
    • factor

      public static float factor(double cameraDepth)
      The haze factor for a camera-space depth: 0 at the camera, approaching 1 at infinity. Returns 0 when the haze is disabled or the depth is behind the near plane.
      Parameters:
      cameraDepth - camera-space Z of the polygon
      Returns:
      haze blend factor in [0, 1)
    • targetColor

      public static Color targetColor(LightingManager lighting)
      Resolves the haze target color: runtime override, then the configured e3d.atmosphereColor, then the scene's sky color.
      Parameters:
      lighting - the scene lighting manager, or null
      Returns:
      the color to fade toward, or null when none is known (haze stays inert)
    • applyHaze

      public static void applyHaze(Color shaded, float f, Color target)
      Blends a per-polygon shaded color toward the haze target in place: c = c*(1-f) + target*f. Called once per polygon per frame — the span loops keep painting the constant result, so solid polygons pay zero per-pixel cost for the haze.
      Parameters:
      shaded - the polygon's lit color, mutated
      f - haze factor from factor(double)
      target - haze target color from targetColor(LightingManager)