Rework morning-flight dawn palette and unify cloud color model
- Replace per-deck shade/lit/edge/glow tracks with shared CLOUD_* curves plus a time lead so the high deck sees the sun sooner - Retune sky, fog, mountain, glow, and city underlight timing and colors for a darker pre-dawn that blooms into pink/orange then blue morning - Simplify cloud lighting math by dropping per-deck glow factors in favor of a fixed sunward blend
This commit is contained in:
parent
e6da313b61
commit
cd6a945dca
|
|
@ -2,12 +2,12 @@ import { ditherStep, hex, mix, type RGB } from '../../engine/color';
|
|||
import { progress } from '../../engine/Timeline';
|
||||
import { noise2 } from '../../engine/rng';
|
||||
import type { Surface } from '../../engine/Surface';
|
||||
import { frameAt, HIGH_EDGE, HIGH_LIT, HIGH_SHADE, LOW_EDGE, LOW_LIT, LOW_SHADE, type Frame } from './timeline';
|
||||
import { CLOUD_EDGE, CLOUD_LIT, CLOUD_SHADE, frameAt, type Frame } from './timeline';
|
||||
import { clarity, CX, F, HORIZON, smoothstep, urbanAt, W } from './world';
|
||||
|
||||
/**
|
||||
* Two broken cloud decks overhead, seen from below: a high, thin one that catches the first pink of
|
||||
* dawn, and a patchier low one. Each is a sheet of noise in world coordinates, so it streams
|
||||
* Two broken cloud decks overhead, seen from below: a high, thin one that catches the dawn colors
|
||||
* first, and a patchier low one that follows. Each is a sheet of noise in world coordinates, so it streams
|
||||
* overhead from the horizon as the plane flies on, and it is filtered by how much ground each pixel
|
||||
* spans so the far rows don't shimmer.
|
||||
*/
|
||||
|
|
@ -20,10 +20,8 @@ interface Deck {
|
|||
/** Wind drift across the path, m/s. */
|
||||
wind: number;
|
||||
seed: number;
|
||||
shade: (t: number) => RGB;
|
||||
lit: (t: number) => RGB;
|
||||
edge: (t: number) => RGB;
|
||||
glow: (f: Frame) => number;
|
||||
/** Seconds ahead of the low deck in the dawn's color changes: higher clouds see the sun sooner. */
|
||||
lead: number;
|
||||
}
|
||||
|
||||
const HIGH: Deck = {
|
||||
|
|
@ -32,10 +30,7 @@ const HIGH: Deck = {
|
|||
th: 0.55,
|
||||
wind: 5,
|
||||
seed: 80,
|
||||
shade: HIGH_SHADE,
|
||||
lit: HIGH_LIT,
|
||||
edge: HIGH_EDGE,
|
||||
glow: (f) => f.highGlow,
|
||||
lead: 18,
|
||||
};
|
||||
|
||||
const LOW: Deck = {
|
||||
|
|
@ -44,13 +39,10 @@ const LOW: Deck = {
|
|||
th: 0.6,
|
||||
wind: 3,
|
||||
seed: 90,
|
||||
shade: LOW_SHADE,
|
||||
lit: LOW_LIT,
|
||||
edge: LOW_EDGE,
|
||||
glow: (f) => f.lowGlow,
|
||||
lead: 0,
|
||||
};
|
||||
|
||||
const CITY_UNDERLIGHT = hex('#a8643e');
|
||||
const CITY_UNDERLIGHT = hex('#7a4a5a');
|
||||
|
||||
function density(d: Deck, X: number, Z: number, fp: number, th: number): number {
|
||||
const s = d.size;
|
||||
|
|
@ -73,11 +65,12 @@ const LAYER_A = new Float32Array(W * HORIZON);
|
|||
function computeDeck(f: Frame, d: Deck): void {
|
||||
const cam = f.cam;
|
||||
const h = d.alt - cam.y;
|
||||
const shade = d.shade(f.t);
|
||||
const litC = d.lit(f.t);
|
||||
const edgeC = d.edge(f.t);
|
||||
const glow = d.glow(f);
|
||||
const city = d === LOW ? f.lights * (1 - progress(f.t, 150, 225)) : 0;
|
||||
const shade = CLOUD_SHADE(f.t + d.lead);
|
||||
const litC = CLOUD_LIT(f.t + d.lead);
|
||||
const edgeC = CLOUD_EDGE(f.t + d.lead);
|
||||
const core: RGB = [shade[0] * 0.82, shade[1] * 0.82, shade[2] * 0.85];
|
||||
// Town light on the low deck at night, gone once the dawn colors take over.
|
||||
const city = d === LOW ? f.lights * (1 - progress(f.t, 50, 110)) : 0;
|
||||
const drift = f.t * d.wind;
|
||||
for (let y = 0; y < HORIZON; y++) {
|
||||
const r = HORIZON - (y + 0.5);
|
||||
|
|
@ -94,18 +87,18 @@ function computeDeck(f: Frame, d: Deck): void {
|
|||
if (e <= -0.02) continue;
|
||||
const a = ditherStep(Math.min(1, (e + 0.02) / 0.07) * far, x, y, 5);
|
||||
if (a <= 0) continue;
|
||||
// Dawn light from the east reaches under the clouds, warmest near the sun and the horizon.
|
||||
const sunward = Math.exp(-(((x - f.sunX) / 120) ** 2)) * (0.45 + 0.55 * low);
|
||||
const g = glow * (0.4 + 0.6 * sunward);
|
||||
// Light from the east reaches under the clouds, strongest near the sun and the horizon.
|
||||
const sunward = Math.exp(-(((x - f.sunX) / 130) ** 2)) * (0.4 + 0.6 * low);
|
||||
const g = 0.25 + 0.75 * sunward;
|
||||
let c = mix(shade, litC, g);
|
||||
c = mix(c, edgeC, (1 - Math.min(1, Math.max(0, e) / 0.08)) * (0.3 + 0.5 * glow));
|
||||
c = mix(c, edgeC, (1 - Math.min(1, Math.max(0, e) / 0.08)) * 0.6);
|
||||
const thick = Math.min(1, Math.max(0, e) / 0.24);
|
||||
c = mix(c, shade, thick * 0.45 * (1 - g));
|
||||
c = mix(c, core, thick * 0.4 * (1 - g * 0.5));
|
||||
if (city > 0) {
|
||||
const u = urbanAt(X - drift, Z);
|
||||
if (u > 0) c = mix(c, CITY_UNDERLIGHT, u * city * 0.45);
|
||||
if (u > 0) c = mix(c, CITY_UNDERLIGHT, u * city * 0.35);
|
||||
}
|
||||
c = mix(c, f.horizonColor, haze * 0.7);
|
||||
c = mix(c, f.horizonColor, haze * 0.55);
|
||||
// Lay this deck over what the decks above have left in the layer.
|
||||
const j = y * W + x;
|
||||
const below = LAYER_A[j];
|
||||
|
|
|
|||
|
|
@ -6,34 +6,45 @@ import { CHASE, CRUISE_ALT, GEAR_H, type Cam } from './world';
|
|||
|
||||
export { DURATION, TIMES };
|
||||
|
||||
/** Light phases: deep pre-dawn navy → blue hour → first pink → rose and orange → sunrise. */
|
||||
/** Light phases for the ground: deep pre-dawn navy → blue hour → first pink → rose and orange → sunrise. */
|
||||
const P = [0, 90, 180, 250, 300] as const;
|
||||
const phase = (...c: string[]) => colorTrack(P.map((t, i) => [t, hex(c[i])] as const));
|
||||
const keyed = (times: readonly number[], colors: readonly string[]) => colorTrack(times.map((t, i) => [t, hex(colors[i])] as const));
|
||||
const phase = (...c: string[]) => keyed(P, c);
|
||||
|
||||
/**
|
||||
* The sky's own phases: deep dark blue until a minute in, then orange and pink flood up from the
|
||||
* horizon under a purple sky, then the blue returns from above and the horizon pales to warm white.
|
||||
*/
|
||||
const SKY_T = [0, 60, 120, 165, 215, 260, 300] as const;
|
||||
const sky = (...c: string[]) => keyed(SKY_T, c);
|
||||
|
||||
/** Sky gradient stops from zenith to horizon. */
|
||||
const SKY = [
|
||||
phase('#03071a', '#060e2a', '#12245a', '#2a4a8a', '#3a68ae'),
|
||||
phase('#060c26', '#0c1a40', '#1e3672', '#4268a4', '#5e8ec6'),
|
||||
phase('#0b1434', '#152654', '#3c4e8c', '#7c88b8', '#9cb2d8'),
|
||||
phase('#121c42', '#243262', '#7a6c9e', '#d89aa6', '#f2bfae'),
|
||||
phase('#1c2550', '#3a3c6c', '#c88a96', '#ffb27e', '#ffd290'),
|
||||
sky('#02051a', '#03071e', '#080e30', '#122260', '#1c4a9a', '#2c66bc', '#3474c8'),
|
||||
sky('#040a24', '#060d2a', '#141a48', '#2a2e78', '#3062b4', '#4a86d0', '#5a98dc'),
|
||||
sky('#08112e', '#0c1638', '#3a2664', '#7a3e8a', '#7a78c0', '#86aee0', '#94c2ec'),
|
||||
sky('#0e1838', '#162048', '#a8406e', '#f2607a', '#f08aa0', '#e8b8c4', '#cce2f2'),
|
||||
sky('#152044', '#222a56', '#f0704a', '#ff9440', '#ffb05a', '#ffd090', '#fff0d8'),
|
||||
];
|
||||
|
||||
/** Light falling on everything in the scene, as a per-channel multiplier. */
|
||||
const AMBIENT = phase('#262c4c', '#30385e', '#58588a', '#a28ca8', '#f0d8c6');
|
||||
/** Haze that swallows the far ground. */
|
||||
const FOG = phase('#141c40', '#26305a', '#7c6c94', '#d0a0a8', '#f0c8b0');
|
||||
const FOG = sky('#0a1030', '#121a3a', '#3a2a5a', '#7a4a6a', '#c08a90', '#e0b8b0', '#f0d8c8');
|
||||
|
||||
/** Cloud colors for the high and low decks: shaded underside, underlit by the dawn, bright thin edges. */
|
||||
export const HIGH_SHADE = phase('#0a1230', '#16204a', '#4a4a7c', '#a06c8c', '#c0909e');
|
||||
export const HIGH_LIT = phase('#121a3e', '#262c5c', '#b07890', '#ff9c84', '#ffc8a0');
|
||||
export const HIGH_EDGE = phase('#1a2450', '#343e72', '#d8a0b4', '#ffc4aa', '#fff0e0');
|
||||
export const LOW_SHADE = phase('#080e26', '#121a3a', '#383a64', '#6c5678', '#9a8292');
|
||||
export const LOW_LIT = phase('#0e153a', '#20284e', '#76628a', '#ec8a7a', '#ffb488');
|
||||
export const LOW_EDGE = phase('#182044', '#2c3460', '#a08aa8', '#ffb09a', '#ffe0c8');
|
||||
/**
|
||||
* Cloud colors: undersides away from the sun, undersides toward it, and thin bright edges. While the
|
||||
* horizon glows the clouds stay dark blue and purple, with pink rims; as the sky turns blue they
|
||||
* catch the sun in orange and pink, then whiten into morning cloud.
|
||||
*/
|
||||
const CLOUD_T = [0, 60, 120, 165, 200, 235, 270, 300] as const;
|
||||
const cloud = (...c: string[]) => keyed(CLOUD_T, c);
|
||||
export const CLOUD_SHADE = cloud('#03061a', '#050a22', '#141436', '#1e1842', '#5a2e5e', '#b0506a', '#d8a0a8', '#d4d8e4');
|
||||
export const CLOUD_LIT = cloud('#060a24', '#0a1030', '#20183e', '#3a2250', '#c8506a', '#ff7a4a', '#ffc090', '#ffffff');
|
||||
export const CLOUD_EDGE = cloud('#0c1434', '#121a40', '#4a2a5a', '#a04a6a', '#ff8a80', '#ffb07a', '#ffe0c0', '#ffffff');
|
||||
|
||||
export const MOUNTAIN_FAR = phase('#0c1230', '#161e44', '#3e3e6c', '#7a5c84', '#8c76a0');
|
||||
export const MOUNTAIN_NEAR = phase('#070b20', '#0e1432', '#2a2a52', '#4c3c62', '#5c4c72');
|
||||
export const MOUNTAIN_FAR = sky('#080d26', '#0c1430', '#2a1e4a', '#4a2e5e', '#6a5482', '#8070a0', '#8c86ae');
|
||||
export const MOUNTAIN_NEAR = sky('#05081c', '#080e26', '#1c1636', '#30203e', '#4a3a62', '#5a4c72', '#62587a');
|
||||
|
||||
/** The sun rises behind the mountains just right of the runway, cresting the ridge around touchdown. */
|
||||
export const SUN_R = 6;
|
||||
|
|
@ -53,9 +64,9 @@ const sunColor = colorTrack([
|
|||
]);
|
||||
/** Warm glow on the horizon around the sun. */
|
||||
const glow = track([
|
||||
[50, 0],
|
||||
[150, 0.3],
|
||||
[220, 0.7],
|
||||
[60, 0],
|
||||
[130, 0.5],
|
||||
[200, 0.8],
|
||||
[TIMES.touchdown, 1],
|
||||
]);
|
||||
const stars = track([
|
||||
|
|
@ -70,17 +81,6 @@ const lights = track([
|
|||
[250, 0.6],
|
||||
[DURATION, 0.35],
|
||||
]);
|
||||
/** How strongly the dawn underlights each cloud deck; the high one catches it first. */
|
||||
const highGlow = track([
|
||||
[110, 0],
|
||||
[200, 0.6],
|
||||
[260, 1],
|
||||
]);
|
||||
const lowGlow = track([
|
||||
[160, 0],
|
||||
[240, 0.6],
|
||||
[285, 1],
|
||||
]);
|
||||
/** Pale ground mist gathering in the fields at sunrise. */
|
||||
const mist = track([
|
||||
[180, 0],
|
||||
|
|
@ -155,8 +155,6 @@ export interface Frame {
|
|||
glow: number;
|
||||
stars: number;
|
||||
lights: number;
|
||||
highGlow: number;
|
||||
lowGlow: number;
|
||||
mist: number;
|
||||
/** Landing light, 0–1. */
|
||||
landing: number;
|
||||
|
|
@ -205,8 +203,6 @@ export function frameAt(t: number): Frame {
|
|||
glow: glow(t),
|
||||
stars: stars(t),
|
||||
lights: lights(t),
|
||||
highGlow: highGlow(t),
|
||||
lowGlow: lowGlow(t),
|
||||
mist: mist(t),
|
||||
landing: progress(t, 200, 206) * (1 - progress(t, 293, 295)),
|
||||
strobes: t < 279 ? 1 : 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue