Renderer contract: the renderer's look is its own; clouds are observed cover placed by scene time

globe.sky switches parts of the sky on and off; how the sky, atmosphere,
haze, lighting, tone mapping and exposure look is the renderer's own, and
no check compares colours. globe.weather's clouds is the fraction of the
sky covered; clouds are placed by scene time and the wind and shade the
ground under them where the sun lights it. New conformance check
globe.weather.sceneTime.
This commit is contained in:
Sameh Khamis committed 2026-11-13 16:08:41 -08:00
1 parent 7a61bf04a0
commit 1b226e14f2
5 files changed
+93 -9

No files matched your search

+52
View File
@@ -4781,6 +4781,58 @@ export function portChecks() {
},
{ capability: 'weather' },
),
check(
'globe.weather.sceneTime',
'clouds are where scene time puts them: moving it moves them, going back brings them back',
async (h, r) => {
if (h.pixels === false) return { skip: 'reads pixels' };
r.camera.setView({
destination: { ...AUSTIN, height: 600 },
orientation: { heading: 0, pitch: 0.05, roll: 0 },
});
const frame = async () => {
await drawn(h, r, 4);
await settled(r);
r.frame.renderNow();
return r.readPixels({ scale: 0.1 }).data;
};
const apart = (a, b) => {
let sum = 0;
for (let i = 0; i < a.length; i += 4)
for (let c = 0; c < 3; c++) sum += Math.abs(a[i + c] - b[i + c]);
return sum / ((a.length / 4) * 3);
};
const t0 = r.frame.time();
const later = t0 + 30 * 60_000;
// What moving scene time changes without clouds (the sun), so the
// clouds' own movement is measured on top of it.
const clearAt0 = await frame();
r.frame.setTime(later);
const clearLater = await frame();
r.frame.setTime(t0);
r.globe.weather.set({
clouds: 0.5,
wind: { speedMps: 20, fromDeg: 270 },
});
const cloudsAt0 = await frame();
r.frame.setTime(later);
const cloudsLater = await frame();
r.frame.setTime(t0);
const cloudsAgain = await frame();
r.globe.weather.set({ clouds: 0, wind: { speedMps: 0, fromDeg: 0 } });
const sun = apart(clearAt0, clearLater);
const moved = apart(cloudsAt0, cloudsLater);
ok(
moved > sun + 2,
`30 minutes of wind move the clouds (${moved.toFixed(1)} against ${sun.toFixed(1)} clear)`,
);
ok(
apart(cloudsAt0, cloudsAgain) < 3,
`the same scene time draws the same clouds (${apart(cloudsAt0, cloudsAgain).toFixed(1)})`,
);
},
{ capability: 'weather' },
),
// --- Effects, credits, quality ---------------------------------------
check(
+17 -2
View File
@@ -199,7 +199,11 @@ export interface BaseStatus {
}
/**
* The sky. A renderer whose sun, moon or fog are not separate from its
* The sky. These switch parts of it on and off; they do not say how it
* looks. How the sky, the atmosphere over the ground, distance haze, the
* lighting and the tone mapping and exposure of the frame look is each
* renderer's own, and no check compares colours with
* each other. Where the renderer's sun, moon or fog are not separate from its
* atmosphere follows `atmosphere` for them and reports them as it draws them.
*/
export interface SkySettings {
@@ -224,9 +228,20 @@ export interface SkySettings {
* fades what makes no sense at the camera's height (rain from orbit) by
* itself. None of it is picked or answers height queries. The application sets the
* conditions observed at the view, which the user can override.
*
* The renderer draws these in its own way, as well as it can; the
* strengths say what is observed, not how it is drawn. Clouds and
* precipitation are where scene time (`frame.time()`) puts them, drifting
* with `wind`: the same scene time draws the same sky, and moving scene time
* moves them. Where the sun lights the globe (`SkySettings.lighting`),
* clouds shade the ground and models under them.
*/
export interface WeatherSettings {
/** Cloud cover. */
/**
* The fraction of the sky the clouds cover, as observed: 0 clear, about
* 0.5 scattered to broken, 1 overcast. Under scattered cloud the ground
* shows between the clouds, from below and from above.
*/
clouds: number;
/** Fog: 1 is about 500 m visibility or less. */
fog: number;
+2 -1
View File
@@ -20,7 +20,7 @@ test('the stub passes the conformance suite', async () => {
.filter((r) => r.status === 'skip')
.map((r) => r.id);
// It draws only models into pixels, so the sweep's, a lit shape's, a line outline's and
// the blends' (over a drawn shape), video tiles' and the weather's pixels go unread; its camera takes no user gestures: the drag and wheel scripts are for a
// the blends' (over a drawn shape), video tiles' and the weather's pixels (drawn, and by scene time) go unread; its camera takes no user gestures: the drag and wheel scripts are for a
// camera that does (a controller over it, say).
assert.deepEqual(skipped, [
'effects.screenModulation.pixels',
@@ -30,6 +30,7 @@ test('the stub passes the conformance suite', async () => {
'draw.models.blend',
'globe.imagery.video',
'globe.weather.drawn',
'globe.weather.sceneTime',
...CAMERA_SCRIPTS.filter(usesInput).map((s) => `camera.trace.${s.name}`),
]);
});