A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
perf(render): the sky's clouds are worked out at a quarter of the size
yhhd956a09e4395
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 784a741a8..e80fb670d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -47,6 +47,7 @@ published separately; it ships inside the editor.### Changed+- **The sky's clouds are worked out at a quarter of the size, 0.9 ms cheaper.** The cloud layer marches sixteen steps a pixel, each with three octaves of noise and three more samples toward the sun, and the surfaces' shadow from it costs almost nothing: all of the 1.6 ms of the `sky_clouds` pass in the terrain-water example was the layer over the sky. The clouds are smooth, so the pass now runs at a quarter of the width and height (half before) and the composite reads it back as it did. In a cloud scene no pixel is more than 2 of 255 from the half-size picture; in the example the difference is below what two runs of the same build differ by. 1.6 ms to 0.7 ms of a 1080p frame.- **Lens flare costs a third of what it did.** The flare looked ninety places in the picture for something bright at every pixel of the full-size frame, to light almost none of them: 0.76 ms of a 1080p frame in the terrain-water example. It is now worked out at half size and laid over the full-size picture (0.22 ms and 0.07 ms), 0.47 ms less. The picture is the same except along the hard edges of whatever throws the flare, where it softens by a pixel or two (0.6 of 255 on average in a scene built to make that worst). A new render scene, `hdr-lens-flare`, is the first to check a flare on both backends.- **The engine's own examples and fixtures no longer commit a generated WebGPU shader twin.** The `wgsl full` section of a `.esshader` is a translation of its GLSL joined to the engine's headers, so every edit to an engine header (the render origin in `FrameConstants`, a lighting function) changed it in dozens of files nobody had touched: 83% of that text is the engine's own lighting code, 2% the author's. It is now derived when the shader is read: by the export (`cookAssets`), by the fixture server the render checks use, and by the editor when it serves a project of the repo. Deriving all 44 shaders takes 2.3 s. `gen-shader-twins --derived` checks that each one still translates and that none commits a twin again; a project of your own keeps its twin in the file as before, because the converters are not in a packaged editor. 18 files lose about 11,000 lines; the 248 WebGPU render scenes draw the same.- **The web module is 144 KB smaller (50 KB gzipped) because it no longer carries a C++ stream library.** `Log`, the shader parser, the font and material parsers, file reads and one JSON status string used `ostringstream`, `istringstream` and `ifstream`, which link libc++'s whole iostream and locale machinery (money, number and time facets, global locale setup at start-up) into every build. They now use `std::string`, a small line reader and stdio, with output kept the same: all 69 shaders parse and assemble to byte-identical text for both targets, a log line prints as before, and the 262 WebGL2 render scenes still draw what they claim. 2,202,592 to 2,058,299 bytes.diff --git a/sdk/src/postprocess/effects.ts b/sdk/src/postprocess/effects.tsindex 8bf69c6f5..1df33f08d 100644--- a/sdk/src/postprocess/effects.ts+++ b/sdk/src/postprocess/effects.ts@@ -316,10 +316,12 @@ registerEffect({type: 'skyAtmosphere',label: 'Sky Atmosphere',factory: () => postProcessEffects.createSkyClouds(),- // The clouds (and the shadow they cast on the ground) are smooth and dear, so they are worked out at half size and the composite- // reads them back by the way a pixel's neighbours agree with it; the dome, sun, moon and stars, which have an edge, stay full size.+ // The clouds (and the shadow they cast on the ground) are smooth and dear, so they are worked out at a quarter of the size (a sixteenth of the+ // pixels; half size was a quarter of them) and the composite reads them back by the way a pixel's neighbours agree with it; the dome, sun, moon+ // and stars, which have an edge, stay full size. Measured against half size: 1.6 ms to 0.7 ms of a 1080p frame, no pixel in a cloud scene more+ // than 2 of 255 apart.multiPass: [- { name: 'sky_clouds', factory: () => postProcessEffects.createSkyClouds(), scale: 0.5 },+ { name: 'sky_clouds', factory: () => postProcessEffects.createSkyClouds(), scale: 0.25 },{ name: 'sky_composite', factory: () => postProcessEffects.createSkyAtmosphere() },],uniforms: [diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex c67c6653c..a5813083c 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3076,4 +3076,6 @@ export const NOTED = {{"note":"The engine's own examples and fixtures no longer commit a generated WebGPU shader twin"},"perf(render): the lens flare is worked out at half size and laid over the full-size picture":{"note":"Lens flare costs a third of what it did"},+ "perf(render): the sky's clouds are worked out at a quarter of the size":+ {"note":"The sky's clouds cost 0.9 ms less"},};