# Atmospheric Vistas, Volumetric Clouds & Deterministic Feel in Pulse

> Composing Pulse physical sky, volumetric clouds, volumetric fog, water/foliage, and pure component-backed spring feel without violating sandboxed tick determinism.

- **Canonical page:** https://gamecrew.ai/techniques/pulse/atmosphere-vistas-springs
- **Techniques hub:** https://gamecrew.ai/techniques
- **Engine:** Pulse
- **Category:** atmosphere
- **Tags:** `clouds`, `volumetric`, `sky`, `fog`, `lighting`, `springs`, `game-feel`, `deterministic`, `environment`, `vistas`
- **Verification:** Compile-verified pattern

## When to Use & Field Best Practices

Pulse runs on WebGPU in the browser with built-in physical sky, volumetric clouds, volumetric fog, water, foliage, and procedural motion — while enforcing **strict tick determinism** (`compile` rejects module-level mutable state, `Math.random`, `Date`, or `Promise` in `systems/*.ts`).

Best-in-field composition in Pulse combines two layers:
1. **Declarative Atmospheric Area Environment (`world/<area>.area.jsonc`)**:
   - Enable `physical_sky: true` and `volumetric_clouds: 0.45..0.72` alongside calibrated three-band sky colors (`sky_zenith`, `sky_horizon`, `sky_ground` darker than horizon) and low-angle golden or crisp directional light (`sun_dir: [-0.45, -0.62, -0.38]`).
   - Keep `fog_density` inversely proportional to area span ($\rho \approx 0.45 / D_{\text{span}}$, e.g. `0.0035` for a 100 m valley; `0.01` washes out a 50 m area) and pair subtle `volumetric_fog_density` (`0.004`) with `tonemap: "agx"` or `"aces"` and restrained bloom (`bloom_intensity: 0.18`, `bloom_threshold: 1.05`).
   - Frame distant horizon silhouettes (layered mountain wedges/arches outside the playable navmesh) so `volumetric_clouds` and aerial perspective create unmistakable depth cues.
2. **Pure Component-Backed Springs & Feel (`contracts/` + `systems/`)**:
   - Store spring state (`scale_y`, `vel_y`, `hitstop_s`) inside a `cosmetic` component declared via `pulse_declare` (`cosmetic` keeps visual juice out of gameplay save hashes while keeping every tick 100% deterministic!).
   - Use built-in `ProceduralMotion` (bob, breathe, lean), `ProceduralGait` (multi-legged creatures), `ProceduralChain` (tails, banners, tentacles), `vfx("burst" | "spark" | "ring" | "shockwave", ...)`, and `shake(amount)` on impacts.

## Mathematical & Algorithmic Core

- **Fog Calibration**: For arena diameter $D$ metres, set `fog_density` $= \mathrm{clamp}(0.45 / D,\; 0.0015,\; 0.008)$ so foreground and midground targets keep $> 65\%$ contrast while distant vista silhouettes soften into haze.
- **Pure Fixed-Tick Spring**: In a fixed-`hz` Pulse system (`dt = 1 / hz`), update component fields `(value, vel)` directly with symplectic Euler:
  $$v' = v + \bigl(-\omega^2(x - x_{\text{target}}) - 2\zeta\omega v\bigr)\Delta t, \qquad x' = x + v' \Delta t$$

## Engine Implementation

### 1. Area Environment Recipe with Volumetric Clouds (`world/highlands.area.jsonc` excerpt)

Apply via `pulse_edit` or area JSONC (flat environment keys only so `compile` emits zero unknown-key warnings):

```jsonc
{
  "environment": {
    "physical_sky": true,
    "volumetric_clouds": 0.58,
    "sky_zenith": "#1f4987",
    "sky_horizon": "#9ec2e6",
    "sky_ground": "#1c202b",
    "sun_dir": [-0.46, -0.58, -0.36],
    "sun_color": "#ffe9c7",
    "sun_intensity": 3.2,
    "sun_shadows": true,
    "sun_disc_size": 1.15,
    "ambient_color": "#58749e",
    "ambient_intensity": 0.55,
    "ibl_intensity": 0.75,
    "fog_density": 0.0035,
    "volumetric_fog_density": 0.004,
    "volumetric_fog_rgba": "#b8cde6",
    "tonemap": "agx",
    "exposure": 1.05,
    "bloom_intensity": 0.18,
    "bloom_threshold": 1.08,
    "contrast": 1.06,
    "saturation": 1.08,
    "contact_shadows": true,
    "taa": true
  }
}
```

### 2. Declaring & Running Deterministic Feel Springs (`contracts` + `systems/feel.ts`)

First declare the cosmetic component and tuning with `pulse_declare`:
- `"component FeelSpring { squash: num=1.0, squash_vel: num=0.0, was_grounded: bool=true } cosmetic"`
- `"tuning feel { spring_hz: 6.5, spring_damping: 0.42, jump_stretch: 3.8, land_squash: 4.4 }"`

Then step it in a pure deterministic system (`systems/feel.ts`) with **zero module-level mutable variables**:

```ts
import { query, shake, system, vfx } from "pulse";
import { FeelSpring, Player } from "../contracts/game";
import { feel } from "../contracts/tuning";

export const feelSystem = system("feel", { after: "physics" }, (dt) => {
  const omega = 6.2831853 * feel.spring_hz;
  const damp = feel.spring_damping;

  for (const e of query(Player, FeelSpring)) {
    const fs = e.feelSpring;
    if (fs.was_grounded && !e.grounded && e.vel[1] > 1.5) {
      fs.squash_vel += feel.jump_stretch;
      vfx("ring", { pos: [e.pos[0], e.pos[1], e.pos[2]], color: "#d8f0ff", count: 8 });
    } else if (!fs.was_grounded && e.grounded) {
      fs.squash_vel -= feel.land_squash;
      shake(0.18);
      vfx("burst", { pos: [e.pos[0], e.pos[1], e.pos[2]], color: "#e8dcc4", count: 10 });
    }
    fs.was_grounded = e.grounded;

    const acc = -omega * omega * (fs.squash - 1.0) - 2.0 * damp * omega * fs.squash_vel;
    fs.squash_vel += acc * dt;
    fs.squash = Math.max(0.55, Math.min(1.65, fs.squash + fs.squash_vel * dt));
  }
});
```

## Browser, Mobile & Software-Renderer Budgets

- **Flat Environment Keys Only**: Pulse validates `environment` keys at `compile`; never nest objects inside `environment` or invent non-existent fog color keys (`fog_density` and `volumetric_fog_rgba` are the exact keys).
- **Scenario Robustness (`robust >= 3/4`)**: Keep `FeelSpring` marked `cosmetic` and avoid altering `CharacterMotor3D` capsule height from visual squash so kept `spec/scenarios/` tapes remain 100% witnessed when tuning visual feel!

## Verification Checklist

1. Run `compile` and verify zero determinism errors and zero unknown-environment-key warnings.
2. Run `pulse_look` with `"views play"` and open the rendered PNG with `Read` to verify volumetric cloud coverage, horizon separation, and target readability.
3. Run `test` (`EditMode` + `PlayMode`) to confirm all scenarios stay witnessed.

## Official references

- Sébastien Hillaire (SIGGRAPH 2016 — Physically Based Sky, Atmosphere and Cloud Rendering)
- Naty Hoffman & Preetham (Outdoor Light Scattering)
- Pulse Deterministic ECS & Area Environment Architecture
