sky: sun.js, sun position and light colour (elevation, direct, diffuse, wetness) #20

Closed
void wants to merge 0 commits from void/sky-sun into main
Member

Adds src/sky/sun.js: one dependency-free ES module that gives the sun's elevation and the light colours for a place and moment.

light({ time, lat, lon, cloud_cover = 0, precipitation = 0 })
  -> { elevation, direct: [r,g,b], diffuse: [r,g,b], wetness }   // linear RGB
  • direct is sun colour at normal incidence (clear zenith ~1); the consumer applies Lambert. diffuse is sky ambient on an upward surface. wetness is 0..1 from precipitation (mm/h).
  • Sun position is the low-precision NOAA/Meeus series. Colour comes from per-channel air-mass attenuation (Kasten & Young air mass). Every constant tuned by eye is marked EYEBALLED in the source; those are meant to be changed by looking, not by measuring.
  • src/sky/sun.node-test.js: fixed-moment checks (equinox noon, Berlin midsummer noon against the textbook elevation, December midnight, equinox sunrise, cloud and rain behaviour, finiteness across a day). Plain node --test, run from a copy in $TMPDIR next to sun.js: 6/6 pass. The file name keeps vitest from collecting it.
  • Not wired into anything yet. The build-time token script and Nibu's shader are meant to import this same file; build-time tokens use clear weather, the live UI uses the weather feed.

Who shaped this

Quotes are from Void's recorded notes of the conversations, not verbatim transcripts.

Meta set the direction: the palette should come from physics, and the themes have names.

"Ratatoskr themes are named Midnight Sky (dark mode) and Noonday Sky (light mode)."
"Ratatoskr palette must be derived from a simplified physically based shading calculation: bark/leaf/soil albedos under Yggdrasil lit by the sky (Midnight Sky / Noonday Sky)."

That is why the sun and sky are a function with an irradiance output at all, and why direct/diffuse are split the way a Lambert + ambient token script wants them.

Nibu shaped the module and its inputs. She agreed the interface (cloud_cover, precipitation, wetness, linear RGB) and her sky shader will import this file:

"sun.js interface agreed with Nibu: light({time,lat,lon,cloud_cover=0,precipitation=0}) -> {elevation, direct:[r,g,b], diffuse:[r,g,b], wetness 0..1}, linear RGB. Cloud shrinks direct, raises diffuse, grey-cool; rain harder; wetness darkens bark/soil albedo."

The weather inputs are her fields. Her raindrop pass is her own work; nothing from Heartfelt (CC BY-NC-SA) is ported here, and this PR contains no raindrop code.

Do not merge until the people above have looked. No preview of this PR needs a login.

Credit receipts

Quotes only where verbatim; everything else is from Void's notes of the conversations, not transcripts.

  • Meta (2026-11-06): the palette is derived from physically based shading of Yggdrasil albedos lit by the sky; themes named Midnight Sky and Noonday Sky (quoted above). Consumed in #22.
  • Nibu: agreed the light() interface and owns the weather inputs (cloud_cover, precipitation, wetness); her sky shader is to import this file. Quoted above from notes.
  • Libby: contributed the silhouette (as named in the task that assigned these receipts; Void's notes here do not say which piece of work it is, so no detail is claimed). From notes.

🤖 Generated with Claude Code

Adds `src/sky/sun.js`: one dependency-free ES module that gives the sun's elevation and the light colours for a place and moment. ```js light({ time, lat, lon, cloud_cover = 0, precipitation = 0 }) -> { elevation, direct: [r,g,b], diffuse: [r,g,b], wetness } // linear RGB ``` - `direct` is sun colour at normal incidence (clear zenith ~1); the consumer applies Lambert. `diffuse` is sky ambient on an upward surface. `wetness` is 0..1 from `precipitation` (mm/h). - Sun position is the low-precision NOAA/Meeus series. Colour comes from per-channel air-mass attenuation (Kasten & Young air mass). Every constant tuned by eye is marked `EYEBALLED` in the source; those are meant to be changed by looking, not by measuring. - `src/sky/sun.node-test.js`: fixed-moment checks (equinox noon, Berlin midsummer noon against the textbook elevation, December midnight, equinox sunrise, cloud and rain behaviour, finiteness across a day). Plain `node --test`, run from a copy in `$TMPDIR` next to `sun.js`: 6/6 pass. The file name keeps vitest from collecting it. - Not wired into anything yet. The build-time token script and Nibu's shader are meant to import this same file; build-time tokens use clear weather, the live UI uses the weather feed. ## Who shaped this Quotes are from Void's recorded notes of the conversations, not verbatim transcripts. **Meta** set the direction: the palette should come from physics, and the themes have names. > "Ratatoskr themes are named Midnight Sky (dark mode) and Noonday Sky (light mode)." > "Ratatoskr palette must be derived from a simplified physically based shading calculation: bark/leaf/soil albedos under Yggdrasil lit by the sky (Midnight Sky / Noonday Sky)." That is why the sun and sky are a function with an irradiance output at all, and why `direct`/`diffuse` are split the way a Lambert + ambient token script wants them. **Nibu** shaped the module and its inputs. She agreed the interface (`cloud_cover`, `precipitation`, `wetness`, linear RGB) and her sky shader will import this file: > "sun.js interface agreed with Nibu: light({time,lat,lon,cloud_cover=0,precipitation=0}) -> {elevation, direct:[r,g,b], diffuse:[r,g,b], wetness 0..1}, linear RGB. Cloud shrinks direct, raises diffuse, grey-cool; rain harder; wetness darkens bark/soil albedo." The weather inputs are her fields. Her raindrop pass is her own work; nothing from Heartfelt (CC BY-NC-SA) is ported here, and this PR contains no raindrop code. Do not merge until the people above have looked. No preview of this PR needs a login. ## Credit receipts Quotes only where verbatim; everything else is from Void's notes of the conversations, not transcripts. - **Meta** (2026-11-06): the palette is derived from physically based shading of Yggdrasil albedos lit by the sky; themes named Midnight Sky and Noonday Sky (quoted above). Consumed in #22. - **Nibu**: agreed the `light()` interface and owns the weather inputs (`cloud_cover`, `precipitation`, `wetness`); her sky shader is to import this file. Quoted above from notes. - **Libby**: contributed the silhouette (as named in the task that assigned these receipts; Void's notes here do not say which piece of work it is, so no detail is claimed). From notes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sky: sun.js, sun position and light colour for a place and moment
Some checks failed
CLA Assistant / CLAssistant (pull_request_target) Has been cancelled
Check PR title / lint (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled
7c89bd0289
Dependency-free ES module: light({time,lat,lon,cloud_cover,precipitation})
-> {elevation, direct, diffuse, wetness}, linear RGB. Constants that were
tuned by eye are labelled EYEBALLED. Fixed-moment tests in
sun.node-test.js (plain node, not collected by vitest).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Member

Closing: landed in dev's history (head is an ancestor of dev 64edacac, brought in through the preview-all merges). src/sky/sun.js is on dev, since evolved (#43-#48, #54-#56). Nothing left to merge.

Closing: landed in dev's history (head is an ancestor of dev 64edacac, brought in through the preview-all merges). src/sky/sun.js is on dev, since evolved (#43-#48, #54-#56). Nothing left to merge.
void closed this pull request 2026-11-10 17:19:02 +00:00
Some checks failed
CLA Assistant / CLAssistant (pull_request_target) Has been cancelled
Check PR title / lint (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Ratatoskr!20
No description provided.