Repository navigation
feat(clouds): takram's clouds draw in our scene through their WebGPU port, behind ?clouds=takram - #212
Open
jonjaques wants to merge 4 commits into
Open
feat(clouds): takram's clouds draw in our scene through their WebGPU port, behind ?clouds=takram#212jonjaques wants to merge 4 commits into
jonjaques wants to merge 4 commits into
Conversation
…port, behind ?clouds=takram A spike. `three-clouds-webgpu` 0.1.0-alpha.6, the unofficial WebGPU port of @takram/three-clouds, runs unmodified on our three 0.185.1 and draws on the G1 cornerstone in the slot the native composite uses. One build shows either renderer: `?clouds=1` is ours, `?clouds=takram` is theirs, under the same `engine.clouds` levers. `engine.takram` holds the port's presets and tunables. The adapter is four modules and holds no cloud shader: - `takramFrame.ts` puts our eye into the port's Earth frame. The port draws over a WGS84 ellipsoid in ECEF and takes the scene through one matrix; a point of the body's datum is stood on Earth's equator and the eye keeps its true height, heading and sun. Float64, no Three, with a property test. - `takramDepth.ts` copies the scene's depth to one sample. The port samples depth by uv and the default picture is 4× MSAA, which can only be loaded by texel. R32F, because a reversed depth in a half float steps by 12% of itself at 100 km. - `takramClouds.ts` builds the port's pass and takram's atmosphere, and draws the port's resolved layer as the first opaque of the scene pass over the clouds (ADR-0063), with the native composite's blend. Its luminance is scaled to scene units by arithmetic: an albedo-one surface under the port's sun is its illuminance over π, which is one unit (ADR-0065). - `takramTunables.ts` is every preset and tunable as a table, and the page's settings, which outlive a chain. Three things the port needed that its recipe does not say: - Its composite samples at the mesh's uv and is written for three's `QuadMesh`, whose v is 0 at the top. A plane's is 1 there and drew the clouds on the ground. - Its pass updates once per three frame, a counter only three's own loop advances. Here it is once per render call, as the scene pass is, or a rig submitting frames back to back times one march and forty quads. - pnpm refuses the geospatial fork build as a tarball URL (ERR_PNPM_EXOTIC_SUBDEP), because it is the atmosphere's dependency and not ours. It is vendored as a file, one of the policy's trusted sources and the port's own install; the policy stays on. Its MIT text is beside it. The sensor's chain and the engine now hold `CloudChainSystem`, the cloud system less the native march's field and resources, so either renderer's factory fits. Not done, and each a fork point for the report: the air between eye and cloud is takram's Earth's, the weather is the port's tiled map, no cloud shadows our ground, a cloud writes no motion vector, and nothing reads the cloud in front of a transparent object. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… so the page loads no chunk more `pnpm check` failed at `bundle`: `index.html` loaded 59 chunks where `GAME_PAGE_CHUNKS` says 58. Built with and without the takram import, the closure differs by one chunk, `profile` (`procedural/hash.ts` and `profile.ts`, 950 bytes). The takram chunk imported `cloudsServed` from `@inertialref/rendering`. That put the weather's modules in a second lazy chunk's reach while the hash beside them stayed the page's alone, so the bundler split the hash out and every visit fetched it. `App` already holds `cloudsServed` through the engine and now hands it to `loadTakramClouds`. The report carries no lever hash for the same reason: `cloudLeversHash` reaches the same module. The port's own modules were never the problem. They sit behind the flag in a 398 kB chunk, minified, which holds the port, takram's atmosphere and geospatial packages, and `postprocessing`, a WebGL library the atmosphere's root entry imports and the port reads two helpers through. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…?clouds=takram:low builds a preset Three of the port's five presets did not survive how the page applied them, and the first cost table was taken in the broken state. `low`, `medium` and `lowEnd` turn `accurateSunSkyLight` off. On three 0.185 that graph does not compile on a first frame: TSL reports `Member "bottomRadius" not found in struct "AtmosphereParameters"`, then `topRadius`, `minCosLight` and the scattering table's sizes, and Dawn refuses `renderPipeline_CloudsPass` for an invalid fragment module. It fails the same way built at boot and rebuilt on the first frame after the clouds were off. Rebuilt on the frame after one the port drew, it compiles. `high` and `ultra` build either way. Nothing fails loudly. The march's pipeline is refused, the composite draws the last good layer or none, and the frame gets cheaper: `low` read 9.7 ms a frame with errors in the console and 12.4 ms without, and neither was the preset. So the settings are now written by `flush`, which the system calls after a frame the port drew, and by nothing else; a context is always built at the port's own `high`. Both routes to `low` then draw one picture, 1.0% RMSE apart, at 9.7 ms, with a clean console. The write also restores `temporalUpscale` and `lightShaftsHalfResolution` first. Only `lowEnd` names them, so after a full-resolution march the next preset kept it. `?clouds=takram:low` builds the port at a preset, so a cost row can be a fresh page rather than a switch. The frame state reports how often the port's pass ran against the frames drawn: one to one, under the page's loop and under back-to-back frames. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…n the build log The three commits before this each say what one change did. None holds the table the spike exists to produce, and the evidence behind it is in the worktree's ignored `.data/takram/`, which goes when the worktree does. The entry carries what a later run would otherwise measure again: the cost of each of the port's presets on G1 at 1920 × 1080 and 2880 × 1800 beside the native renderer's, the far-plane fit that makes `high` cost 19.82 ms where 9.10 ms draws a better-shadowed cloud, and the five things that cost the time: the composite's uv, the presets that do not compile on a first frame and get cheaper for it, the stale shadow program after back-to-back frames, the chunk split, and pnpm's refusal of a tarball URL. It records no decision between the renderers. That is the owner's, and no ADR is written for a spike. Co-Authored-By: Claude Fable 5.2 <[email protected]>
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://spike-takram-clouds-inertialrefd.jaquers.workers.dev (commit 6274b60)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A spike, and it answers one question: takram's volumetric clouds draw in our scene through the unofficial WebGPU port as it ships.
three-clouds-webgpu0.1.0-alpha.6 runs unmodified on our three 0.185.1, behind?clouds=takram, beside?clouds=1and under the sameengine.cloudslevers. alpha.8 on three 0.187 was not tried, because alpha.6 drew.The base is
the-weather, notmain: the branch was cut from it, becausemainhas no cloud renderer and no cornerstones.The port is not forked. The adapter is four modules under
apps/game/src/render/and holds no cloud shader:takramFrame.tsputs our eye in the port's world. The port draws over a WGS84 ellipsoid in ECEF and takes the scene through one matrix; a point of the body's datum stands on Earth's equator, and the eye keeps its true height, heading and sun. Float64, no Three.takramDepth.tscopies the scene's depth to one sample. The port samples depth by uv, and the default picture is 4× MSAA, which can only be loaded by texel.takramClouds.tsbuilds the port's pass and takram's atmosphere, and draws the port's resolved layer as the first opaque of the scene pass over the clouds (ADR-0063), with the native composite's blend. The planet, the ground and the sea are ours.takramTunables.tsis the port's 174 tunables and five presets as a table, written throughengine.takram.Four things the port needed that its recipe does not say:
QuadMesh, whose v is 0 at the top. A plane's is 1 there, and the first frame drew the sky's clouds on the ground.low,mediumandlowEnddo not compile on a first frame. They turnaccurateSunSkyLightoff, and on r185 that graph fails withMember "bottomRadius" not found in struct "AtmosphereParameters". Rebuilt on the frame after one the port drew, it compiles. Nothing fails in the picture: the march's pipeline is refused and the frame costs less. A setting is written only after a frame the port drew. The cause is not found.high.shadow.maxFar200,000 draws a better-shadowed cloud for 9.10 ms in place of 19.82. The adapter leaves the preset as shipped.ERR_PNPM_EXOTIC_SUBDEP). It is vendored as a file, one of the policy's trusted sources, with its MIT text beside it. The policy stays on.The sensor's chain and the engine hold
CloudChainSystem, the cloud system less the native march's field and resources, so either renderer's factory fits.CONTEXT.mdhas the entry.Cost
The whole frame with the clouds on less the same page with them off. G1 (
weather-g1-fair, on P222_3_2_k IV), Mac mini (M6), production build28903d80, one fresh page a row,ir.gpu(135)three times and the least kept, three pairs and their median, thermal pressure 0 before and after every row. The frame without clouds is 5.2 ms at 1920 × 1080 and 11.9 ms at 2880 × 1800.lowEndlowmediumhighultrahigh, no layer casting a shadowhigh,shadow.maxFar200 kmhigh,lightShaftsoffhigh,temporalUpscaleoffThe native row agrees with the weather's own
groundrow, 7.82 ms.ultrareads 60.1 ms right after the clouds go off and on and 64.1 ms held on; the table's is the first.Invariants
three/webgpuandthree/tsl. The port's own build importsthree, which sharesthree.core.js; one copy of three resolves.render/warmup.ts. The port's march and shadow pipelines have no compile-ahead and build on the first frame drawn. See Left out.scripts/drive.mjson one rig, under the GPU lock.length(position) − bottomRadius, which steps by half a meter at Earth's radius. That is inside the dependency and is not held to rule 52; no artifact showed on a still camera.Screenshots
G1, same camera and sun, 2880 × 1800, shown at half size. The native renderer:
Takram,
highas shipped:Takram,
highwithshadow.maxFar200,000:One cloud edge against sky at 2×, nearest-neighbor. The native renderer, then takram:
Takram's presets on G1 at 1920 × 1080:
lowandmediumabove,highandultrabelow.G3 (
weather-g3-underlit-dusk), 2880 × 1800 at half size. The native renderer, then takram. Takram draws its stock layers, not ourdusk-altocumulusregime, so these are two skies.E1 (
weather-e1-cumulus-orbit, Earth from 400 km), 1920 × 1080: takram on the left, the native renderer on the right. The port's march ends at 200 km.Takram on G1 at 1920 × 1080, a slow turn of 2.4° a second, then a held camera:
https://agentic-media-dumpster.jonjaques.com/2026/11/7y8m56ebdz/takram-high-slow-turn-1080p.mp4
https://agentic-media-dumpster.jonjaques.com/2026/11/hk5zca53b2/takram-high-held-1080p.mp4
Verification
pnpm checkgreen at28903d80: 21 stages, 139.3 s. Itssimstage passed; I did not read the capability count. The commit after it,6274b60c, isCONTEXT.mdalone, andspelling,formatanddocspassed on it; the full check was not run again.pnpm vitest run takramFrame: four properties on the frame placement pass. With the east axis flipped, one fails.CONTEXT.mdupdated. No ADR: a spike, and the choice between the renderers is not made.pnpm test:gpu: not run.pnpm presets:compare: not run. Without the flag the takram chunk is never loaded, andcheck-site-chunksholds that, but no plate was compared.*.gpu.test.ts, which is not written.the-weatherhas not moved fromc34cd9f7, so nothing was replayed.invariant-auditorwas not launched. The diff would warrant it: a dependency in the render layer and a second system in the sensor's chain.Left out
Each is a fork point, sized in the build log's entry and in the thread, and none is started:
cloudShadowAtanswers the sun's transmittance at any point; no material of ours reads it.highdrawing during boot the cover lifts 34 s after the page attaches at 1920 × 1080, and not within 90 s atultra.ir.gpuframes. Both are worked round, in the adapter and in how the rows were taken.renderPipeline_MeshBasicNodeMaterial_39refused, in two boots atlowEnd. The picture drew.🤖 Generated with Claude Code