diff --git a/src/app/features/scene/terrain/terrainStars.test.ts b/src/app/features/scene/terrain/terrainStars.test.ts index 40020186..370b6843 100644 --- a/src/app/features/scene/terrain/terrainStars.test.ts +++ b/src/app/features/scene/terrain/terrainStars.test.ts @@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { SKY } from './skyData'; import { + BRIGHTEN, createTerrainStars, elevationOf, ELEVATION_TOP, @@ -12,7 +13,7 @@ import { skyColoursOf, } from './terrainStars'; import { CAMERA, view } from './terrainWorld'; -import { isNight } from '../ridge/stars'; +import { isNight, makeStars } from '../ridge/stars'; import { skyNameFor } from './terrainSky'; /** A 2D context that only counts: arcs painted and clears since the last reset. */ @@ -168,6 +169,19 @@ describe('turning with the camera', () => { }); }); +describe('brightness', () => { + it('draws every star at BRIGHTEN times its ridge-field alpha, capped at 1', () => { + createTerrainStars(glCanvas(), SKY.midnight)?.draw(0); + const want = makeStars(skyColoursOf(SKY.midnight), 390, 844).map((st) => + Math.min(1, st.alpha * BRIGHTEN) + ); + ctx2d.c.alphas.forEach((a) => expect(want.some((w) => Math.abs(w - a) < 1e-9)).toBe(true)); + // and it is brighter than the ridge field's own top alpha + const top = Math.max(...makeStars(skyColoursOf(SKY.midnight), 390, 844).map((st) => st.alpha)); + expect(Math.max(...ctx2d.c.alphas)).toBeGreaterThan(top * 1.5); + }); +}); + describe('motion', () => { it('with no clock every star is at base and a repeat draw repaints; no twinkle', () => { const s = createTerrainStars(glCanvas(), SKY.midnight)!; diff --git a/src/app/features/scene/terrain/terrainStars.ts b/src/app/features/scene/terrain/terrainStars.ts index e568418f..4fca72c9 100644 --- a/src/app/features/scene/terrain/terrainStars.ts +++ b/src/app/features/scene/terrain/terrainStars.ts @@ -72,6 +72,10 @@ export const elevationOf = (y: number): number => ELEVATION_TOP * (1 - y / SKY_S const wrap = (a: number): number => a - PERIOD * Math.round(a / PERIOD); +/** The terrain overlay draws the ridge field's stars brighter and a little larger: a phone's small, hazy sky needs it to read. */ +export const BRIGHTEN = 2.4; +export const GROW = 1.3; + export interface TerrainStars { /** Paint for the camera `turns` into its turn (0..1). `seconds` is the clock while the terrain moves; absent: every star at base. */ draw(turns: number, seconds?: number): void; @@ -126,13 +130,13 @@ export function createTerrainStars(canvas: HTMLCanvasElement, sky: SkyData): Ter lit.forEach(({ star, az, e }, i) => { const da = wrap(az - yaw); const gain = seconds === undefined ? 1 : gains.get(i) ?? 1; - ctx.globalAlpha = Math.min(1, star.alpha * gain); + ctx.globalAlpha = Math.min(1, star.alpha * gain * BRIGHTEN); ctx.fillStyle = star.fill; [da, da > 0 ? da - PERIOD : da + PERIOD].forEach((d) => { const at = project(d, e, w, h); if (!at || at.y < 0 || at.y > el.height / scale) return; ctx.beginPath(); - ctx.arc(at.x * scale, at.y * scale, star.r * scale, 0, 2 * Math.PI); + ctx.arc(at.x * scale, at.y * scale, star.r * GROW * scale, 0, 2 * Math.PI); ctx.fill(); }); });