Skip to content

fork release 3: AerialPerspectiveNode shadowNode and lightingMaskNode

Choose a tag to compare

@johnfewell johnfewell released this 25 Oct 15:50

Release 2 plus two optional inputs on the WebGPU AerialPerspectiveNode: shadowNode and lightingMaskNode. These are patched builds of @takram/three-atmosphere 0.19.1 and @takram/three-geospatial 0.9.1. This is an unofficial fork release. Upstream is takram-design-engineering/three-geospatial.

Release 3 is built on fork-release-2, which stays published.

The new inputs

// Transmittance (0-1) of an occluder such as clouds toward the sun, applied
// only to the direct solar illuminance when lighting is enabled.
shadowNode: Node<'float'> | null = null

// Per-pixel amount (0-1) of lighting applied when lighting is enabled. Where
// it is 0 the input color is kept as self-lit, still with transmittance and
// inscattering applied.
lightingMaskNode: Node<'float'> | null = null
  • shadowNode computes illuminance = direct * shadow + indirect. Moonlight is not shadowed.
  • lightingMaskNode computes mix(color * transmittance, postLit, clamp(mask, 0, 1)) before inscattering is added. It is applied only when lighting is true. When lighting is off, the self-lit and post-lit values are the same, so the mask has nothing to do.
  • With both inputs null, the node builds the same graph as 0.19.1. The emitted WGSL is byte-identical; see below.

Pass a mask node that is free of derivatives, for example a texture read at an explicit level. The node evaluates the mask inside its surface branch, which is non-uniform control flow.

Source

  • Base: fork/release-2 = b1a4d6282db3ad5079c807f4039ae1db96c06765 (the upstream commit that published 0.19.1 / 0.9.1) + 22d75078 and e7f0418e (the r185 struct fix from PR takram-design-engineering#118) + dc8d1915 (release 2 version metadata)
  • cd8d304c773de47d22d3d9ca6700827cc8f3d52e Add shadowNode and lightingMaskNode inputs to AerialPerspectiveNode (one file, +18/-1)
  • 4c14bee692ce3df9ef92dddaa13fb3331acb9a26 fork release 3: version metadata

Assets

File Version Size SHA-256
takram-three-geospatial-0.9.1+fork.3.tgz 0.9.1+fork.3 200853 B 8c1b548b23386719974b2868d9332e6ada8e39eabed631c946759b7f8d2a153e
takram-three-atmosphere-0.19.1+fork.3.tgz 0.19.1+fork.3 24446776 B afc9def33a66d13928b8cf77e8bc34933821b31fd8eb3af736b61d8f651005fc

Compared with release 2, the geospatial tarball differs only in its version. The atmosphere tarball differs only in AerialPerspectiveNode.ts, AerialPerspectiveNode.d.ts, build/webgpu.{js,cjs} with their source maps, and the version.

Built with node 22.23.3 and pnpm 9.15.9 from the base commit's lockfile. Prettier, eslint, typecheck, both builds, and the tests (atmosphere 3/3, core 5/5) all exit 0.

Evidence (CPU only)

  • Default graph unchanged. The node was compiled to WGSL without a GPU, with every new input null, on release 2 and on release 3. In all four configurations (lit, unlit, lit + moon, unlit + moon) the vertex and fragment WGSL are byte-identical. Example (lit), fragment sha256 a7d9a5b96758e264c2da27554717f2686561d55fc681ae40a314946d4c1aaac6 and vertex 4385253346fecd610a93a974fd4d5ac1bf05bd0913220c89a357e9a81a6ed7db on both releases.
  • Same output as the subclass it replaces. The port being forked for, three-clouds-webgpu, currently uses a subclass that overrides setup(). Both nodes were rendered on WebGPU via SwiftShader (CPU) with identical seeded inputs; readbacks are pinned to one STBN phase (frameId % 64), where the node itself is bit-reproducible:
    • Against the subclass as it was before an instrumentation refactor (the summed form direct * shadow + indirect), the output is bit-identical in every configuration that version supports.
    • Against the current subclass, the unlit configurations are bit-identical. The lit configurations differ by at most 3.1e-6 relative (1.2e-7 absolute). That residual is float32 rounding from the subclass's re-association D·T·s + I·T.
    • Sensitivity control: multiplying the shadow by 0.999 changes values by up to 9.6e-4 relative.
  • Consumer. Stock three 0.185.1 (no patch), node 24, pnpm 11.8, overrides pointing at these tarballs: install with no warnings, pnpm peers check exits 0 (including the ^0.19.1 / ^0.9.1 ranges), vite build exits 0, imports succeed (29 / 69 exports), FnLayout with a struct type works, both inputs are present on a new node, and the built bundle runs. Negative control: the npm 0.19.1 / 0.9.1 packages fail at import with the .layout.name TypeError.

Use

Override both names (pnpm 11, in pnpm-workspace.yaml). Keep geospatial as a local tarball, because pnpm's blockExoticSubdeps (on by default) rejects a URL for a dependency of a dependency:

overrides:
  '@takram/three-atmosphere': 'https://github.com/johnfewell/three-geospatial/releases/download/fork-release-3/takram-three-atmosphere-0.19.1%2Bfork.3.tgz'
  '@takram/three-geospatial': 'file:./vendor/takram-three-geospatial-0.9.1+fork.3.tgz'

Use only one copy of atmosphere per app: instanceof AtmosphereContext breaks if two copies are installed.