Two storeys on the frontier, and no round rocks on the Moon

TALL BUILDINGS IN AN 1880S TOWN. surf_west's facade stacked its window
band with `storey = floor(uy / st.up)` and no cap, so it drew as many
rows of glass as the map gave it height — and city.js's landmark roll
gave it 14-24 m. The result was eight-storey window grids on a main
street. The facade now draws two storeys and nothing above them, so a
tall building is a false front or a tower of blank boarded wall, which
is what a tall frontier building is. Landmarks come down to 9-14 m and
get rarer; the verticality that world is entitled to comes off the roof
in the crowns element. Every cell over 12 m is now rock, not building.

MINI MOONS ON THE MOON. moon_ground drew each boulder as a filled disc
with a smooth sphere normal and a specular ring round its limb — which
is a picture of a small moon, scattered a few hundred times across a
lunar plain. Nothing there is round: lunar rocks are impact breccia
with no weathering to wear the corners off. Boulders are now a seven-
vertex polygon with exact chord edges, flat per-facet shading so two
faces of the same rock step hard against each other, and the specular
on whichever facet faces the sun instead of round a limb. The sub-cell
branch stops using 'o', which was the same mistake one scale down.

domshim 288/288, photosensitivity gates pass, city night byte-identical.
This commit is contained in:
MiguelCarino 2026-08-18 08:30:45 -06:00
parent a39746e97b
commit 3ca965cf31
8 changed files with 155 additions and 33 deletions

View file

@ -127,9 +127,13 @@ The same machinery, told to be somewhere else. The street lattice, the walk, the
the crowd, the cat and every optic are shared; the map generator, the texture layer, the weather the crowd, the cat and every optic are shared; the map generator, the texture layer, the weather
table and about a third of the elements are the frontier's own. table and about a third of the elements are the frontier's own.
- **The town** is timber. False fronts — a flat board wall carried a metre and a half above the - **The town** is timber and it is TWO STOREYS. False fronts — a flat board wall carried a metre
building's own roofline so it looks bigger from the street — clapboard, board-and-batten, adobe and a half above the building's own roofline so it looks bigger from the street — clapboard,
and fieldstone, in six quarters from the main street to the mission. board-and-batten, adobe and fieldstone, in six quarters from the main street to the mission.
Nothing gets a third row of windows: the facade draws two and everything above them is blank
boarded wall, so a tall building reads as a false front or a tower rather than as a block of
flats. What verticality the world has comes off the roof — a steeple, a water tank, a windmill —
and the tallest things in it are rock.
- **Open range.** A quarter of the ground is a district that is mostly not a district: empty lots, - **Open range.** A quarter of the ground is a district that is mostly not a district: empty lots,
sagebrush, saguaro, and one lot in fourteen carrying a flat-topped sandstone butte. sagebrush, saguaro, and one lot in fourteen carrying a flat-topped sandstone butte.
- **The light.** One low sun in a fixed direction, and every wall in the world is either rimmed in - **The light.** One low sun in a fixed direction, and every wall in the world is either rimmed in

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 KiB

After

Width:  |  Height:  |  Size: 740 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 KiB

After

Width:  |  Height:  |  Size: 528 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 KiB

After

Width:  |  Height:  |  Size: 690 KiB

View file

@ -824,7 +824,7 @@ var CC = (function () {
DIST_WEST = [ DIST_WEST = [
{ name: 'main', hue: P.warm, mix: P.amber, mixP: 0.72, accent: P.amber, styles: [0, 2, 0, 2], { name: 'main', hue: P.warm, mix: P.amber, mixP: 0.72, accent: P.amber, styles: [0, 2, 0, 2],
hMin: 6.2, hMax: 10, lit: 0.20, signP: 0.66, landmark: 0.022, w: 0.21, hMin: 6.2, hMax: 10, lit: 0.20, signP: 0.66, landmark: 0.012, w: 0.21,
vacant: 0.07, butte: 0 }, vacant: 0.07, butte: 0 },
{ name: 'dust', hue: P.slate, mix: P.white, mixP: 0.74, accent: P.white, styles: [0, 1, 5], { name: 'dust', hue: P.slate, mix: P.white, mixP: 0.74, accent: P.white, styles: [0, 1, 5],
hMin: 5.0, hMax: 8.5, lit: 0.11, signP: 0.18, landmark: 0.004, w: 0.19, hMin: 5.0, hMax: 8.5, lit: 0.11, signP: 0.18, landmark: 0.004, w: 0.19,
@ -837,7 +837,7 @@ var CC = (function () {
vacant: 0.30, butte: 0.004 }, vacant: 0.30, butte: 0.004 },
{ name: 'mission', hue: P.white, mix: P.amber, mixP: 0.60, accent: P.spring, styles: [3, 4, 2], { name: 'mission', hue: P.white, mix: P.amber, mixP: 0.60, accent: P.spring, styles: [3, 4, 2],
hMin: 5.4, hMax: 9.5, lit: 0.14, signP: 0.07, landmark: 0.050, w: 0.07, hMin: 5.4, hMax: 9.5, lit: 0.14, signP: 0.07, landmark: 0.022, w: 0.07,
vacant: 0.22, butte: 0 }, vacant: 0.22, butte: 0 },
{ name: 'range', hue: P.slate, mix: P.ember, mixP: 0.62, accent: P.ember, styles: [4, 1, 4], { name: 'range', hue: P.slate, mix: P.ember, mixP: 0.62, accent: P.ember, styles: [4, 1, 4],
hMin: 4.4, hMax: 7.5, lit: 0.06, signP: 0.02, landmark: 0.000, w: 0.26, hMin: 4.4, hMax: 7.5, lit: 0.06, signP: 0.02, landmark: 0.000, w: 0.26,
@ -904,7 +904,8 @@ var CC = (function () {
alleyMin: 9, alleyP: 0.52, alleyDeepMin: 10, alleyDeepP: 0.40, alleyMin: 9, alleyP: 0.52, alleyDeepMin: 10, alleyDeepP: 0.40,
plazaP: 0.20, plazaBigP: 0.34, plazaR: 6, plazaRVar: 9, plazaP: 0.20, plazaBigP: 0.34, plazaR: 6, plazaRVar: 9,
vacant: 0.14, setbackP: 0.68, podMin: 0, podVar: 0, falseFront: 1, vacant: 0.14, setbackP: 0.68, podMin: 0, podVar: 0, falseFront: 1,
lmMin: 14, lmVar: 10, crownTall: 13, DG: 34, sky: 1,
lmMin: 9, lmVar: 5, crownTall: 13, DG: 34, sky: 1,
butteMin: 9, butteVar: 23, rockStyle: 6, butteMin: 9, butteVar: 23, rockStyle: 6,
styleCh: STYLE_CH_WEST, signCh: SIGN_CH_WEST, styleBase: 0, styleCh: STYLE_CH_WEST, signCh: SIGN_CH_WEST, styleBase: 0,
setbackMode: 'falsefront', signShape: 'board', signPalette: 'painted' setbackMode: 'falsefront', signShape: 'board', signPalette: 'painted'
@ -3023,7 +3024,8 @@ var CC = (function () {
var uy = v - (st.gnd + 0.52); var uy = v - (st.gnd + 0.52);
var storey = Math.floor(uy / st.up); var storey = Math.floor(uy / st.up);
var sv = uy - storey * st.up; var sv = uy - storey * st.up;
if (storey >= 0 && sv > 0.55 && sv < 0.55 + st.winH) {
if (storey >= 0 && storey < 2 && sv > 0.55 && sv < 0.55 + st.winH) {
var cw = st.winW / st.bay, c0 = 0.5 - cw * 0.5, c1 = 0.5 + cw * 0.5; var cw = st.winW / st.bay, c0 = 0.5 - cw * 0.5, c1 = 0.5 + cw * 0.5;
if (fu > c0 && fu < c1) { if (fu > c0 && fu < c1) {
var wh = hash2(bay * 7 + storey, sd, 0x8D2); var wh = hash2(bay * 7 + storey, sd, 0x8D2);
@ -6400,6 +6402,13 @@ var CC = (function () {
} }
} }
var NFACET = 7, TAU_F = 6.283185307;
var FU = new Float64Array(NFACET), FV = new Float64Array(NFACET), FB = new Float64Array(NFACET);
function facetR(k, sd) {
return 0.58 + hash2(((k % NFACET) + NFACET) % NFACET, 3, sd ^ 0x5C13) * 0.42;
}
function drawRock(f, px, pz, r, sX, sZ, sd) { function drawRock(f, px, pz, r, sX, sZ, sd) {
if (!project(px, r, pz)) return; if (!project(px, r, pz)) return;
var cx = PJ.x, cy = PJ.y, d = PJ.d, w = PJ.w; var cx = PJ.x, cy = PJ.y, d = PJ.d, w = PJ.w;
@ -6420,7 +6429,9 @@ var CC = (function () {
if (lk < 0.25) return; if (lk < 0.25) return;
var hs = hash2(Math.floor(px * 4), Math.floor(pz * 4), sd ^ 0x71); var hs = hash2(Math.floor(px * 4), Math.floor(pz * 4), sd ^ 0x71);
var l1 = litOf(0.55 + hs * 0.45, d, hs); var l1 = litOf(0.55 + hs * 0.45, d, hs);
emit(f, Math.floor(cx), Math.floor(cy), hs < 0.4 ? G_o : G_DOT, l1.col, l1.lum * lk, d);
emit(f, Math.floor(cx), Math.floor(cy), hs < 0.35 ? G_PCT : (hs < 0.7 ? G_8 : G_DOT),
l1.col, l1.lum * lk, d);
return; return;
} }
@ -6432,15 +6443,43 @@ var CC = (function () {
if (x0 + dx1 > V.cols - 1) dx1 = V.cols - 1 - x0; if (x0 + dx1 > V.cols - 1) dx1 = V.cols - 1 - x0;
if (y0 + dy0 < 0) dy0 = -y0; if (y0 + dy0 < 0) dy0 = -y0;
if (y0 + dy1 > V.rows - 1) dy1 = V.rows - 1 - y0; if (y0 + dy1 > V.rows - 1) dy1 = V.rows - 1 - y0;
var fu = FU, fv = FV, fb = FB, fk;
for (fk = 0; fk < NFACET; fk++) {
var mid = (fk + 0.5) * TAU_F / NFACET;
var lean = 0.34 + hash2(fk, 7, sd ^ 0x6D2) * 0.52;
var cxn = Math.cos(mid) * lean, cyn = Math.sin(mid) * lean;
var cbn = Math.sqrt(1 - lean * lean * 0.92);
var nn = Math.sqrt(cxn * cxn + cyn * cyn + cbn * cbn);
fu[fk] = cxn / nn; fv[fk] = cyn / nn; fb[fk] = cbn / nn;
}
var bestF = 0, bestD = -2;
for (fk = 0; fk < NFACET; fk++) {
var bd = fu[fk] * sr - fv[fk] * su + fb[fk] * sf;
if (bd > bestD) { bestD = bd; bestF = fk; }
}
for (dy = dy0; dy <= dy1; dy++) { for (dy = dy0; dy <= dy1; dy++) {
for (dx = dx0; dx <= dx1; dx++) { for (dx = dx0; dx <= dx1; dx++) {
var u = (x0 + dx - cx) / rw, v = (y0 + dy - cy) / rh; var u = (x0 + dx - cx) / rw, v = (y0 + dy - cy) / rh;
var r2 = u * u + v * v; var r2 = u * u + v * v;
if (r2 > 1.0) continue; if (r2 > 1.0) continue;
var bulge = Math.sqrt(1 - r2);
var ang = Math.atan2(v, u); if (ang < 0) ang += TAU_F;
var tt = ang * NFACET / TAU_F;
var kk0 = Math.floor(tt), ff = tt - kk0;
var a0 = kk0 * TAU_F / NFACET, dA = TAU_F / NFACET;
var r0 = facetR(kk0, sd), r1 = facetR(kk0 + 1, sd);
var den = r0 * Math.sin(ff * dA) + r1 * Math.sin(dA - ff * dA);
var lim = den > 1e-6 ? (r0 * r1 * Math.sin(dA)) / den : 1;
if (r2 > lim * lim) continue;
var fi = kk0 % NFACET;
var bulge = (1 - r2) * 0.55;
var dd = d - bulge * r; var dd = d - bulge * r;
var dot = u * sr - v * su + bulge * sf; var dot = fu[fi] * sr - fv[fi] * su + fb[fi] * sf;
var litK = clamp(0.5 + 3.0 * dot, 0, 1); var litK = clamp(0.5 + 3.0 * dot, 0, 1);
var hv = hash2(Math.floor((u + 1.2) * 9), Math.floor((v + 1.2) * 9), sd ^ 0x72); var hv = hash2(Math.floor((u + 1.2) * 9), Math.floor((v + 1.2) * 9), sd ^ 0x72);
@ -6453,7 +6492,7 @@ var CC = (function () {
} }
var soft = softOf(edge); var soft = softOf(edge);
if (r2 > 0.80 && hv < 0.30) { if (fi === bestF && bestD > 0.15 && hv < 0.26) {
var ls = specOf(0.55 + hv, d); var ls = specOf(0.55 + hv, d);
emit(f, x0 + dx, y0 + dy, G_EQ, ls.col, ls.lum * soft, dd); emit(f, x0 + dx, y0 + dy, G_EQ, ls.col, ls.lum * soft, dd);
continue; continue;

View file

@ -172,7 +172,7 @@
*/ */
DIST_WEST = [ DIST_WEST = [
{ name: 'main', hue: P.warm, mix: P.amber, mixP: 0.72, accent: P.amber, styles: [0, 2, 0, 2], { name: 'main', hue: P.warm, mix: P.amber, mixP: 0.72, accent: P.amber, styles: [0, 2, 0, 2],
hMin: 6.2, hMax: 10, lit: 0.20, signP: 0.66, landmark: 0.022, w: 0.21, hMin: 6.2, hMax: 10, lit: 0.20, signP: 0.66, landmark: 0.012, w: 0.21,
vacant: 0.07, butte: 0 }, vacant: 0.07, butte: 0 },
{ name: 'dust', hue: P.slate, mix: P.white, mixP: 0.74, accent: P.white, styles: [0, 1, 5], { name: 'dust', hue: P.slate, mix: P.white, mixP: 0.74, accent: P.white, styles: [0, 1, 5],
hMin: 5.0, hMax: 8.5, lit: 0.11, signP: 0.18, landmark: 0.004, w: 0.19, hMin: 5.0, hMax: 8.5, lit: 0.11, signP: 0.18, landmark: 0.004, w: 0.19,
@ -187,7 +187,7 @@
* spring is the cottonwood, and it carries the church — landmark 0.05 is by far the highest * spring is the cottonwood, and it carries the church — landmark 0.05 is by far the highest
* in either world, because a mission IS its bell tower. */ * in either world, because a mission IS its bell tower. */
{ name: 'mission', hue: P.white, mix: P.amber, mixP: 0.60, accent: P.spring, styles: [3, 4, 2], { name: 'mission', hue: P.white, mix: P.amber, mixP: 0.60, accent: P.spring, styles: [3, 4, 2],
hMin: 5.4, hMax: 9.5, lit: 0.14, signP: 0.07, landmark: 0.050, w: 0.07, hMin: 5.4, hMax: 9.5, lit: 0.14, signP: 0.07, landmark: 0.022, w: 0.07,
vacant: 0.22, butte: 0 }, vacant: 0.22, butte: 0 },
{ name: 'range', hue: P.slate, mix: P.ember, mixP: 0.62, accent: P.ember, styles: [4, 1, 4], { name: 'range', hue: P.slate, mix: P.ember, mixP: 0.62, accent: P.ember, styles: [4, 1, 4],
hMin: 4.4, hMax: 7.5, lit: 0.06, signP: 0.02, landmark: 0.000, w: 0.26, hMin: 4.4, hMax: 7.5, lit: 0.06, signP: 0.02, landmark: 0.000, w: 0.26,
@ -291,7 +291,11 @@
alleyMin: 9, alleyP: 0.52, alleyDeepMin: 10, alleyDeepP: 0.40, alleyMin: 9, alleyP: 0.52, alleyDeepMin: 10, alleyDeepP: 0.40,
plazaP: 0.20, plazaBigP: 0.34, plazaR: 6, plazaRVar: 9, plazaP: 0.20, plazaBigP: 0.34, plazaR: 6, plazaRVar: 9,
vacant: 0.14, setbackP: 0.68, podMin: 0, podVar: 0, falseFront: 1, vacant: 0.14, setbackP: 0.68, podMin: 0, podVar: 0, falseFront: 1,
lmMin: 14, lmVar: 10, crownTall: 13, DG: 34, sky: 1, /* 9-14 m, down from 14-24. A "landmark" out here is a church, a hotel or a livery barn — three
* storeys at the outside — and the tower on top of it belongs to the crowns element rather than
* to the lot's own height. At 14-24 the map was emitting eight-storey buildings and surf_west's
* facade was dutifully drawing eight storeys of windows on them. */
lmMin: 9, lmVar: 5, crownTall: 13, DG: 34, sky: 1,
butteMin: 9, butteVar: 23, rockStyle: 6, butteMin: 9, butteVar: 23, rockStyle: 6,
styleCh: STYLE_CH_WEST, signCh: SIGN_CH_WEST, styleBase: 0, styleCh: STYLE_CH_WEST, signCh: SIGN_CH_WEST, styleBase: 0,
setbackMode: 'falsefront', signShape: 'board', signPalette: 'painted' setbackMode: 'falsefront', signShape: 'board', signPalette: 'painted'

View file

@ -1087,20 +1087,40 @@
} }
/* ---- the rock ------------------------------------------------------------------------------------ /* ---- the rock ------------------------------------------------------------------------------------
* A SPHERE WITH A REAL TERMINATOR ON IT, which is worth the eight lines it costs. Every other * AN ANGULAR FRAGMENT, AND EMPHATICALLY NOT A SPHERE. The first cut of this drew each boulder as a
* object in the frontier is a flat face with one normal and is lit or not; a boulder presents * filled disc — `r2 = u*u + v*v; if (r2 > 1) continue;` — with a smooth sphere normal
* every normal at once, and the line where the surface turns away from the sun is the only thing * (u*right - v*up + sqrt(1-r2)*(-viewdir)) and a specular ring round its limb. The arithmetic was
* that says it is round. The normal at a screen offset (u, v) inside the disc is * right and the object was wrong: what it produced was a small round grey body with a terminator
* across it and a bright rim, which is a picture of a MOON. Scattering a few hundred of them
* across a lunar plain read exactly as it sounds.
* *
* n = u*right - v*up + sqrt(1 - u^2 - v^2) * (-viewdir) * Nothing on the Moon is round. Lunar surface rocks are impact breccia and fractured basalt:
* they are chipped, they are faceted, and they have corners. There is also no weathering to round
* them off — no water, no wind, no frost — so a fragment that broke ten million years ago still
* has the shape it broke in. A sphere is the one silhouette that cannot occur.
* *
* — the first two terms are the tangent plane, the third is how far the surface bulges toward the * So the outline is a POLYGON: seven vertices at hashed radii, with straight chords between them,
* eye — and n.sun is the whole lighting model. * and the boundary radius along any ray is the exact chord intersection rather than a constant.
* The shading is FLAT PER FACET — one normal for each sector, held constant across it — which is
* what puts a hard-edged tonal step between two faces of the same rock and is the single thing
* that says "angular" at character resolution. The specular is on the facet that happens to face
* the sun rather than round a limb, because a facet catches the light and a limb is a thing
* spheres have.
* *
* WITH THE SUN BEHIND THE WALK, MOST ROCKS ARE FULLY LIT AND THE TERMINATOR IS OFF THE LIMB. That * WITH THE SUN BEHIND THE WALK, MOST ROCKS ARE FULLY LIT AND ONLY ONE OR TWO FACETS TURN AWAY.
* is not a bug and it is not a waste: it is exactly what down-sun Apollo photography looks like, * That is not a bug and not a waste: it is what down-sun Apollo photography looks like, it is why
* it is why the crews were told to shoot down-sun, and it is why the shadows above have to carry * the crews were told to shoot down-sun, and it is why the shadows above carry the relief. Turn
* the relief. Turn round and the same rocks are black cut-outs. */ * round and the same rocks are black cut-outs with a chipped edge. */
var NFACET = 7, TAU_F = 6.283185307;
/* Facet scratch, allocated once for the life of the page: drawRock runs for every rock in the
* frame and this file is allocation-free in draw() by contract. */
var FU = new Float64Array(NFACET), FV = new Float64Array(NFACET), FB = new Float64Array(NFACET);
/* The vertex radius of facet k, 0.58-1.00 of the rock's nominal size. The spread is what stops
* seven equal radii from being a heptagon, which at this cell size is a circle again. */
function facetR(k, sd) {
return 0.58 + hash2(((k % NFACET) + NFACET) % NFACET, 3, sd ^ 0x5C13) * 0.42;
}
function drawRock(f, px, pz, r, sX, sZ, sd) { function drawRock(f, px, pz, r, sX, sZ, sd) {
if (!project(px, r, pz)) return; if (!project(px, r, pz)) return;
var cx = PJ.x, cy = PJ.y, d = PJ.d, w = PJ.w; var cx = PJ.x, cy = PJ.y, d = PJ.d, w = PJ.w;
@ -1125,7 +1145,11 @@
if (lk < 0.25) return; if (lk < 0.25) return;
var hs = hash2(Math.floor(px * 4), Math.floor(pz * 4), sd ^ 0x71); var hs = hash2(Math.floor(px * 4), Math.floor(pz * 4), sd ^ 0x71);
var l1 = litOf(0.55 + hs * 0.45, d, hs); var l1 = litOf(0.55 + hs * 0.45, d, hs);
emit(f, Math.floor(cx), Math.floor(cy), hs < 0.4 ? G_o : G_DOT, l1.col, l1.lum * lk, d); /* NOT G_o. At one cell the glyph IS the silhouette, and 'o' is a ring — the same mistake as
* the disc one scale up. A chip of rock under a cell across is a blob of ink, which is what
* '%' and '8' are and what '.' is when it is smaller still. */
emit(f, Math.floor(cx), Math.floor(cy), hs < 0.35 ? G_PCT : (hs < 0.7 ? G_8 : G_DOT),
l1.col, l1.lum * lk, d);
return; return;
} }
@ -1142,16 +1166,53 @@
if (x0 + dx1 > V.cols - 1) dx1 = V.cols - 1 - x0; if (x0 + dx1 > V.cols - 1) dx1 = V.cols - 1 - x0;
if (y0 + dy0 < 0) dy0 = -y0; if (y0 + dy0 < 0) dy0 = -y0;
if (y0 + dy1 > V.rows - 1) dy1 = V.rows - 1 - y0; if (y0 + dy1 > V.rows - 1) dy1 = V.rows - 1 - y0;
/* The seven facet normals, resolved once per rock rather than once per cell. Each is the
* outward direction of its own chord, tilted toward the eye by a hashed amount so no two faces
* of the same rock catch the light equally — which is the whole read. `nb` is how far the facet
* leans toward the viewer; a low value is a face seen almost edge-on and it is what makes one
* side of a rock go dark while the rest stays lit. */
var fu = FU, fv = FV, fb = FB, fk;
for (fk = 0; fk < NFACET; fk++) {
var mid = (fk + 0.5) * TAU_F / NFACET;
var lean = 0.34 + hash2(fk, 7, sd ^ 0x6D2) * 0.52;
var cxn = Math.cos(mid) * lean, cyn = Math.sin(mid) * lean;
var cbn = Math.sqrt(1 - lean * lean * 0.92);
var nn = Math.sqrt(cxn * cxn + cyn * cyn + cbn * cbn);
fu[fk] = cxn / nn; fv[fk] = cyn / nn; fb[fk] = cbn / nn;
}
/* Which facet is most nearly square-on to the sun; that one gets the specular, in place of the
* limb ring a sphere would have had. */
var bestF = 0, bestD = -2;
for (fk = 0; fk < NFACET; fk++) {
var bd = fu[fk] * sr - fv[fk] * su + fb[fk] * sf;
if (bd > bestD) { bestD = bd; bestF = fk; }
}
for (dy = dy0; dy <= dy1; dy++) { for (dy = dy0; dy <= dy1; dy++) {
for (dx = dx0; dx <= dx1; dx++) { for (dx = dx0; dx <= dx1; dx++) {
var u = (x0 + dx - cx) / rw, v = (y0 + dy - cy) / rh; var u = (x0 + dx - cx) / rw, v = (y0 + dy - cy) / rh;
var r2 = u * u + v * v; var r2 = u * u + v * v;
if (r2 > 1.0) continue; if (r2 > 1.0) continue; // cheap reject before the polygon test
var bulge = Math.sqrt(1 - r2); /* ---- THE POLYGON, and it is an exact chord intersection rather than a stepped radius.
/* Per-cell depth: the near face of the sphere, so the rock's own silhouette does not * Quantising the boundary to one radius per sector gives a shape made of arcs, which is a
* overwrite the ground in front of its base. */ * circle with dents in it; the straight chord between two vertices is what gives a rock a
* flat edge and a corner. For a ray at angle t between vertices at a0 and a1 with radii r0
* and r1, the chord is hit at r0*r1*sin(d) / (r0*sin(t-a0) + r1*sin(a1-t)). */
var ang = Math.atan2(v, u); if (ang < 0) ang += TAU_F;
var tt = ang * NFACET / TAU_F;
var kk0 = Math.floor(tt), ff = tt - kk0;
var a0 = kk0 * TAU_F / NFACET, dA = TAU_F / NFACET;
var r0 = facetR(kk0, sd), r1 = facetR(kk0 + 1, sd);
var den = r0 * Math.sin(ff * dA) + r1 * Math.sin(dA - ff * dA);
var lim = den > 1e-6 ? (r0 * r1 * Math.sin(dA)) / den : 1;
if (r2 > lim * lim) continue;
var fi = kk0 % NFACET;
/* Per-cell depth: a mild bulge, for ordering only — enough that the rock's own silhouette
* does not overwrite the ground in front of its base, without reintroducing a sphere. */
var bulge = (1 - r2) * 0.55;
var dd = d - bulge * r; var dd = d - bulge * r;
var dot = u * sr - v * su + bulge * sf; var dot = fu[fi] * sr - fv[fi] * su + fb[fi] * sf;
var litK = clamp(0.5 + 3.0 * dot, 0, 1); var litK = clamp(0.5 + 3.0 * dot, 0, 1);
/* Keyed on the rock's own surface parameterisation, not on the screen cell: the field has to /* Keyed on the rock's own surface parameterisation, not on the screen cell: the field has to
* be welded to the rock or it crawls as the camera walks past. It is not perfect — u and v * be welded to the rock or it crawls as the camera walks past. It is not perfect — u and v
@ -1172,7 +1233,11 @@
* fracture plane and is a genuine specular. About 6% of the painted cells of an object that * fracture plane and is a genuine specular. About 6% of the painted cells of an object that
* is itself a small part of the frame, which is where a slice of the print's hot budget is * is itself a small part of the frame, which is where a slice of the print's hot budget is
* meant to come from. */ * meant to come from. */
if (r2 > 0.80 && hv < 0.30) { /* THE SPECULAR IS ON A FACET, NOT ROUND A LIMB. `r2 > 0.80` put a bright annulus at the
* edge of every rock, which is the single most sphere-like mark available and was half of
* why these read as little moons. A fracture plane that happens to face the sun glints;
* that is one face of the rock, and it is a patch rather than a ring. */
if (fi === bestF && bestD > 0.15 && hv < 0.26) {
var ls = specOf(0.55 + hv, d); var ls = specOf(0.55 + hv, d);
emit(f, x0 + dx, y0 + dy, G_EQ, ls.col, ls.lum * soft, dd); emit(f, x0 + dx, y0 + dy, G_EQ, ls.col, ls.lum * soft, dd);
continue; continue;

View file

@ -387,7 +387,17 @@
var uy = v - (st.gnd + 0.52); var uy = v - (st.gnd + 0.52);
var storey = Math.floor(uy / st.up); var storey = Math.floor(uy / st.up);
var sv = uy - storey * st.up; var sv = uy - storey * st.up;
if (storey >= 0 && sv > 0.55 && sv < 0.55 + st.winH) { /* ---- TWO STOREYS OF WINDOWS AND NOT ONE MORE -------------------------------------------------
* This loop had no cap, so it repeated its window band all the way up whatever height city.js
* handed it — and city.js's `landmark` roll hands it 14-24 m. The result was an eight-storey
* grid of lit windows on a frontier main street: an apartment block, in 1880, and the single
* most wrong thing in that world.
*
* A frontier building is two storeys. What makes the tall ones tall is a FALSE FRONT or a
* TOWER, and both of those are blank boarded wall — which is what falling through to board()
* below gives, for free. The verticality that world is entitled to comes from the crowns
* element on the roof (a steeple, a water tank, a windmill), not from more rows of glass. */
if (storey >= 0 && storey < 2 && sv > 0.55 && sv < 0.55 + st.winH) {
var cw = st.winW / st.bay, c0 = 0.5 - cw * 0.5, c1 = 0.5 + cw * 0.5; var cw = st.winW / st.bay, c0 = 0.5 - cw * 0.5, c1 = 0.5 + cw * 0.5;
if (fu > c0 && fu < c1) { if (fu > c0 && fu < c1) {
var wh = hash2(bay * 7 + storey, sd, 0x8D2); var wh = hash2(bay * 7 + storey, sd, 0x8D2);