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
fix(render): a shipped game's textures are mipmapped
esengineb70f1073ea17
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 57ee2b2e1..a70d51737 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,10 @@ published separately; it ships inside the editor.- **A cutout's edge is antialiased.** With multisampling on (the default), a material with an alpha cutoff turns its alpha into multisample coverage along the cut instead of testing it, so leaves, grass and fences stop stair-stepping at their edges. A shader opts in with `#pragma coverage <param>`, which the built-in Model shader declares for `u_alphaCutoff`; a material without a cutoff, and a blended one, draw as before. A project in gamma space with no post-processing has no multisampled target, and there the cut stays hard.- **Project Health names the textures a material reads as data while they are still decoded as colour.** In a linear project, a normal map or packed roughness marked sRGB is bent on the way in; models imported before 0.74 left every one of them that way. The report lists them in one finding and its Fix turns sRGB off on all of them. Which texture params hold numbers is the shader's to say: `#pragma param … texture … texel(data)`, which the built-in Model and Lit shaders now declare. The same report names settings in `project.esproject` that nothing reads.+### Fixed++- A shipped game's textures are sampled through mip levels. An image the engine uploads itself — in a web export, a mini-game and the editor's Play — got no mip chain on WebGL2, so a texture drawn smaller than itself took one texel per pixel: in ORCA Bistro the trees turned to noise and the shutters to broken bright lines, while the editor's viewport, which uploads through its own path, looked right. The chain is now built from the pixels and rebuilt whenever they change, as that path does. WebGPU does not build one yet.+## [0.74.0] - 2026-09-27### Addeddiff --git a/fixtures/scenes/corpus-distant-texture.esscene b/fixtures/scenes/corpus-distant-texture.esscenenew file mode 100644index 000000000..4d2745cda--- /dev/null+++ b/fixtures/scenes/corpus-distant-texture.esscene@@ -0,0 +1,96 @@+{+ "version": 4,+ "name": "CorpusDistantTexture",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -2.6,+ "y": 0.6,+ "z": 40+ },+ "rotation": {+ "x": 0,+ "y": 0,+ "z": 0,+ "w": 1+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 0,+ "fov": 50,+ "nearPlane": 0.1,+ "farPlane": 100,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Sun",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 1,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "Sky",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Light",+ "data": {+ "type": 2,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 0.4+ }+ }+ ]+ }+ ]+}\ No newline at end of filediff --git a/sdk/src/asset/loaders/TextureLoader.ts b/sdk/src/asset/loaders/TextureLoader.tsindex cc617bffc..c85a5d5ea 100644--- a/sdk/src/asset/loaders/TextureLoader.ts+++ b/sdk/src/asset/loaders/TextureLoader.ts@@ -58,6 +58,11 @@ export interface TextureImportSettings {export type TextureImportSettingsResolver = (ref: string) => TextureImportSettings | undefined;+/** An asset's settings for the engine's pixel upload: mipmapped unless it says not, as the WebGL upload is. */+function pixelParams(settings: TextureImportSettings | undefined): TextureParams {+ return { filterMode: settings?.filter, wrapMode: settings?.wrap, srgb: settings?.srgb, mipmaps: settings?.mipmaps ?? true };+}+/*** Canonical residency key for a texture: the resolved load path plus the* flip-orientation flag (flipped and raw uploads are genuinely different GPU@@ -214,10 +219,7 @@ export class TextureLoader implements AssetLoader<TextureResult> {// runtimeLoader.loadTextures used — instead of a URL-based <img>.if (this.pixelDecoder_) {const result = await this.pixelDecoder_(path, flip);- const params: TextureParams = {- filterMode: settings?.filter, wrapMode: settings?.wrap, srgb: settings?.srgb,- };- const handle = createTextureFromPixels(this.module_, result, TextureContent.Asset, flip, params);+ const handle = createTextureFromPixels(this.module_, result, TextureContent.Asset, flip, pixelParams(settings));return { handle, width: result.width, height: result.height };}const url = ctx.backend.resolveUrl(ctx.catalog.getBuildPath(path));@@ -419,17 +421,9 @@ export class TextureLoader implements AssetLoader<TextureResult> {if (!this.module_) {throw new Error('TextureLoader: 2D-canvas fallback needs a wasm module (native uses the pixel-decode path)');}- const module = this.module_;const { pixels } = readImagePixels(img);-- const rm = requireResourceManager();- // Format 2 = sRGB color under the linear pipeline (see rm_createTexture).- const format = samplesAsSrgb(settings?.srgb) ? 2 : 1;- const handle = withMalloc(module, pixels.length, ptr => {- module.HEAPU8.set(pixels, ptr);- return rm.createTexture(width, height, ptr, pixels.length, format, flip, TextureContent.Asset);- });-+ const handle = createTextureFromPixels(this.module_, { width, height, pixels }, TextureContent.Asset, flip,+ pixelParams(settings));return { handle, width, height };}}diff --git a/sdk/src/runtime/runtimeAssets.ts b/sdk/src/runtime/runtimeAssets.tsindex bb2518ba0..c34ac4bea 100644--- a/sdk/src/runtime/runtimeAssets.ts+++ b/sdk/src/runtime/runtimeAssets.ts@@ -74,9 +74,18 @@ export interface TextureParams {wrapMode?: string;/** sRGB-encoded color image (default true); see TextureImportSettings.srgb. */srgb?: boolean;+ /** A mip chain, rebuilt whenever the pixels change. */+ mipmaps?: boolean;}const FILTER_MODE_MAP: Record<string, number> = { 'nearest': 0, 'linear': 1 };+/** Set on a filter code to ask `rm_createTextureEx` for a mip chain. */+const FILTER_MIPMAPPED = 2;++/** The `rm_createTextureEx` filter code: nearest or linear, and whether it has mips. */+export function textureFilterCode(params: TextureParams): number {+ return (FILTER_MODE_MAP[params.filterMode ?? 'linear'] ?? 1) | (params.mipmaps ? FILTER_MIPMAPPED : 0);+}const WRAP_MODE_MAP: Record<string, number> = { 'repeat': 0, 'clamp': 1, 'mirror': 2 };/** Upload decoded RGBA pixels as a GL texture; returns the engine texture handle.@@ -146,7 +155,7 @@ export function createTextureFromPixels(// The wasm embind object has no createTextureFromBytes, so web falls through// to the heap path below unchanged.if (rm.createTextureFromBytes) {- const filter = params?.filterMode ? FILTER_MODE_MAP[params.filterMode] ?? 1 : undefined;+ const filter = params ? textureFilterCode(params) : undefined;const wrap = params?.wrapMode ? WRAP_MODE_MAP[params.wrapMode] ?? 1 : undefined;return rm.createTextureFromBytes(result.width, result.height, result.pixels, format, flipY, content, filter, wrap);}@@ -156,8 +165,8 @@ export function createTextureFromPixels(return withMalloc(module, result.pixels.length, ptr => {module.HEAPU8.set(result.pixels, ptr);- if (params && (params.filterMode || params.wrapMode) && rm.createTextureEx) {- const filter = FILTER_MODE_MAP[params.filterMode ?? 'linear'] ?? 1;+ if (params && (params.filterMode || params.wrapMode || params.mipmaps) && rm.createTextureEx) {+ const filter = textureFilterCode(params);const wrap = WRAP_MODE_MAP[params.wrapMode ?? 'clamp'] ?? 1;return rm.createTextureEx(result.width, result.height, ptr, result.pixels.length, format, flipY, filter, wrap, content);}diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex 929cb9637..c40398b83 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -74,6 +74,7 @@ export function textureContentName(content: TextureContent): string {export interface CppResourceManager {/** `content` is a {@link TextureContent}: who refills the texture after a device loss. */createTexture(width: number, height: number, pixels: number, pixelsLen: number, format: number, flipY: boolean, content: TextureContent): number;+ /** `filterMode`: bit 0 is linear over nearest, bit 1 a mip chain (see `textureFilterCode`). */createTextureEx(width: number, height: number, pixels: number, pixelsLen: number, format: number, flipY: boolean, filterMode: number, wrapMode: number, content: TextureContent): number;/*** Module-free texture upload: take the RGBA bytes directly instead of a wasmdiff --git a/sdk/tests/native-assets.test.ts b/sdk/tests/native-assets.test.tsindex fdde31b64..9377b346c 100644--- a/sdk/tests/native-assets.test.ts+++ b/sdk/tests/native-assets.test.ts@@ -127,11 +127,11 @@ describe('native Assets.loadTexture', () => {expect(tex.height).toBe(2);// The bytes reached the engine entry point: 4×2 RGBA, format 1 (gamma),- // flip=true, and — with no import settings on this texture — the defaults- // the plain rm_createTexture path applies (Linear filter, ClampToEdge wrap).+ // flip=true, and — with no import settings on this texture — Linear with a+ // mip chain (code 1|2), as the WebGL upload gives an asset, and ClampToEdge.expect(createSpy).toHaveBeenCalledTimes(1);const [w, h, pixels, pixelsLen, format, flip, filter, wrap] = createSpy.mock.calls[0];- expect([w, h, format, flip, filter, wrap]).toEqual([4, 2, 1, true, 1, 1]);+ expect([w, h, format, flip, filter, wrap]).toEqual([4, 2, 1, true, 3, 1]);expect((pixels as Uint8Array).length).toBe(4 * 2 * 4);expect(pixelsLen).toBe(4 * 2 * 4);diff --git a/src/esengine/bindings/ResourceManagerBindings.cpp b/src/esengine/bindings/ResourceManagerBindings.cppindex 7d4fef211..b6bbb55a5 100644--- a/src/esengine/bindings/ResourceManagerBindings.cpp+++ b/src/esengine/bindings/ResourceManagerBindings.cpp@@ -59,9 +59,11 @@ u32 rm_createTextureEx(resource::ResourceManager& rm, u32 width, u32 height,spec.width = width;spec.height = height;spec.format = texFormat;- spec.generateMips = false;-- spec.minFilter = (filterMode == 0) ? TextureFilter::Nearest : TextureFilter::Linear;+ // Bit 0 of the filter code picks linear over nearest; bit 1 asks for a mip+ // chain, which the device rebuilds whenever the pixels change.+ const bool coded = filterMode >= 0;+ spec.generateMips = coded && (filterMode & 2) != 0;+ spec.minFilter = (coded && (filterMode & 1) == 0) ? TextureFilter::Nearest : TextureFilter::Linear;spec.magFilter = spec.minFilter;switch (wrapMode) {diff --git a/src/esengine/renderer/rhi/GLDevice.cpp b/src/esengine/renderer/rhi/GLDevice.cppindex 608ff0489..bc4b6149c 100644--- a/src/esengine/renderer/rhi/GLDevice.cpp+++ b/src/esengine/renderer/rhi/GLDevice.cpp@@ -102,6 +102,12 @@ GLenum toGLFilter(TextureFilter filter) {}}+/** A texture with a chain samples through it; GL ignores the chain otherwise. */+GLenum toGLMinFilter(const TextureDesc& desc) {+ if (!desc.mipmaps) return toGLFilter(desc.minFilter);+ return desc.minFilter == TextureFilter::Nearest ? GL_NEAREST_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR;+}+GLenum toGLWrap(TextureWrap wrap) {switch (wrap) {case TextureWrap::Repeat: return GL_REPEAT;@@ -1091,7 +1097,7 @@ bool GLDevice::backendCreateTexture(u32 id, const TextureDesc& desc, const void*0, gl.format, gl.type, pixels);if (pixels && desc.flipY) glPixelStorei(GL_UNPACK_FLIP_Y_WEBGL, GL_FALSE);- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLFilter(desc.minFilter));+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLMinFilter(desc));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, toGLFilter(desc.magFilter));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, toGLWrap(desc.wrapS));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, toGLWrap(desc.wrapT));@@ -1177,7 +1183,7 @@ void GLDevice::backendUpdateTexture(u32 id, i32 x, i32 y, u32 width, u32 height,void GLDevice::backendSetTextureParams(u32 id, const TextureDesc& desc) {bindTextureForEdit(nameOf(texture_names_, id));- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLFilter(desc.minFilter));+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLMinFilter(desc));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, toGLFilter(desc.magFilter));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, toGLWrap(desc.wrapS));glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, toGLWrap(desc.wrapT));@@ -1186,6 +1192,9 @@ void GLDevice::backendSetTextureParams(u32 id, const TextureDesc& desc) {void GLDevice::backendGenerateMipmaps(u32 id) {bindTextureForEdit(nameOf(texture_names_, id));glGenerateMipmap(GL_TEXTURE_2D);+ if (const TextureDesc* desc = textureDesc(TextureHandle{id})) {+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, toGLMinFilter(*desc));+ }}// =============================================================================diff --git a/src/esengine/renderer/rhi/GfxDevice.cpp b/src/esengine/renderer/rhi/GfxDevice.cppindex c0aef9754..8b1455eb9 100644--- a/src/esengine/renderer/rhi/GfxDevice.cpp+++ b/src/esengine/renderer/rhi/GfxDevice.cpp@@ -534,7 +534,10 @@ void GfxDevice::updateTexture(TextureHandle texture, i32 x, i32 y, u32 width, u3keepBytes(record->bytes, uploadOrderImage(upload, pixels));}if (record->realized) backendUpdateTexture(id, x, y, width, height, pixels, flipY);+ // An owed texture's chain is rebuilt when it is paid.+ const bool rebuildChain = record->realized && desc.mipmaps && !record->owed;if (whole) payTexture(id, *record);+ if (rebuildChain) backendGenerateMipmaps(id);}void GfxDevice::setTextureParams(TextureHandle texture, TextureFilter min, TextureFilter mag,diff --git a/tests/renderer/test_texture_fb.cpp b/tests/renderer/test_texture_fb.cppindex c696a6727..da417cf7e 100644--- a/tests/renderer/test_texture_fb.cpp+++ b/tests/renderer/test_texture_fb.cpp@@ -73,6 +73,24 @@ int main() {CHECK(d.updateTextureCalls == before + 1, "setDataRaw uploads when size is sufficient");}+ // --- a mipmapped texture's chain follows its pixels; a plain one has none ---+ {+ MockGfxDevice d;+ TextureSpecification spec;+ spec.width = 4; spec.height = 4; spec.format = TextureFormat::RGBA8; spec.generateMips = true;+ auto mipped = Texture::create(d, GfxContent::transient(), spec);+ std::vector<u8> pixels(64, 0xAB);+ mipped->setDataRaw(pixels.data(), static_cast<u32>(pixels.size()));+ CHECK(d.generateMipmapsCalls == 1, "filling a mipmapped texture builds its chain");+ mipped->setDataRaw(pixels.data(), static_cast<u32>(pixels.size()));+ CHECK(d.generateMipmapsCalls == 2, "new pixels rebuild the chain, or distant samples show the old image");++ spec.generateMips = false;+ auto plain = Texture::create(d, GfxContent::transient(), spec);+ plain->setDataRaw(pixels.data(), static_cast<u32>(pixels.size()));+ CHECK(d.generateMipmapsCalls == 2, "a texture without mips is never given a chain");+ }+// --- create() fails (returns null) when the device can't allocate a texture ---// createTexture returns Invalid on OOM / lost context; initialize() must surface// that instead of returning a "valid" texture wrapping the null handle.diff --git a/tools/check-render-scenes.mjs b/tools/check-render-scenes.mjsindex aaea35c44..cd7c827c4 100644--- a/tools/check-render-scenes.mjs+++ b/tools/check-render-scenes.mjs@@ -46,7 +46,7 @@ for (const s of SCENES) {|| s.env.ESTELLA_VERIFY_SEAM|| s.env.ESTELLA_VERIFY_GRID || s.env.ESTELLA_VERIFY_PREVIEW|| s.env.ESTELLA_VERIFY_MESH_PREVIEW || s.env.ESTELLA_VERIFY_DEPTH_LAYERS- || s.env.ESTELLA_VERIFY_COUNTERS || s.env.ESTELLA_VERIFY_COUNTERS_MAX || s.env.ESTELLA_VERIFY_FRAME_DEBUG || s.env.ESTELLA_VERIFY_EDGE || s.env.ESTELLA_VERIFY_CUTOUT_EDGE+ || s.env.ESTELLA_VERIFY_COUNTERS || s.env.ESTELLA_VERIFY_COUNTERS_MAX || s.env.ESTELLA_VERIFY_FRAME_DEBUG || s.env.ESTELLA_VERIFY_EDGE || s.env.ESTELLA_VERIFY_CUTOUT_EDGE || s.env.ESTELLA_VERIFY_MINIFIED|| s.env.ESTELLA_VERIFY_DRAW_CALLS|| s.env.ESTELLA_VERIFY_YSORT || s.id === 'sprite-default';if (!asserts && !s.rendersOnly) {diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex c70c10e2f..8f8f8bfc1 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1256,6 +1256,8 @@ export const NOTED = {{ note: 'Project Health names the textures a material reads as data while they are still decoded as colour' },'feat(render): a cutout\'s edge is antialiased':{ note: 'A cutout\'s edge is antialiased' },+ 'fix(render): a shipped game\'s textures are mipmapped':+ { note: 'A shipped game\'s textures are sampled through mip levels' },'fix(eht): the generator writes LF on every platform':{ internal: 'The engine header tool is a repository generator; on Windows it rewrote every generated file with CRLF, which only a contributor there ever saw.' },};diff --git a/tools/render-host/host.ts b/tools/render-host/host.tsindex 3f86ec75d..50c4a468c 100644--- a/tools/render-host/host.ts+++ b/tools/render-host/host.ts@@ -43,6 +43,9 @@ const msaaSamples = Number(params.get('msaa')) || undefined;const seedParam = params.get('seed');const randomSeed = seedParam !== null && Number.isFinite(Number(seedParam)) ? Number(seedParam) : undefined;const depthLayers = Number(params.get('depthLayers')) || undefined;+// `runtime`: images decode to pixels and upload through the engine, as a shipped+// game and Play do, instead of through this page's WebGL context.+const runtimeTextures = params.get('textures') === 'runtime';// The project's render-resolution policy (RenderResolution). Passed with the fit// OFF, so the camera keeps its authored orthoSize and the frame differs by the// policy alone — which is what a gate about the policy has to isolate.@@ -144,6 +147,13 @@ async function boot(): Promise<void> {wasmBaseUrl: '/wasm',});app.enableStats();+ if (runtimeTextures) {+ app.getResource(Assets).getTextureLoader().setPixelDecoder(async (path) => {+ const res = await fetch(path);+ if (!res.ok) throw new Error(`texture ${res.status}: ${path}`);+ return decodeImagePixels(await res.blob());+ });+ }// The fixtures are AUTHORING scenes and were captured in authoring mode, where// gameplay systems stay frozen so a capture is the same frame every time.diff --git a/tools/render-host/run.mjs b/tools/render-host/run.mjsindex 48952b010..1463fd57f 100644--- a/tools/render-host/run.mjs+++ b/tools/render-host/run.mjs@@ -36,9 +36,11 @@* ESTELLA_VERIFY_UNIFORM the frame is one colour on purpose; ESTELLA_VERIFY_COUNT says which* ESTELLA_VERIFY_EDGE how straight a straight edge is drawn (JSON: box, lit, dark, maxJag)* ESTELLA_VERIFY_CUTOUT_EDGE how often a cutout's edge pixel is a blend (JSON: box, lit, run, partial, minShare)+ * ESTELLA_VERIFY_MINIFIED how much a far-off texture shimmers pixel to pixel (JSON: box, maxRipple, minMean)* ESTELLA_VERIFY_SCALE copy the scene's content onto a grid (JSON), for a cost gate* ESTELLA_VERIFY_OUTPUT_TRANSFORM the frame's output curve ("aces")* ESTELLA_VERIFY_MSAA multisample count the scene asks for (the app's default otherwise)+ * ESTELLA_VERIFY_TEXTURES "runtime": images upload through the engine, as a shipped game's do* ESTELLA_VERIFY_PROFILE record N further frames and report the TS/C++ cost split* ESTELLA_VERIFY_TIMEOUT_MS how long this run may take before it reports one*/@@ -91,6 +93,7 @@ const COLORSPACE = process.env.ESTELLA_VERIFY_COLORSPACE === 'linear' ? 'linear'// is a curve on the way out and engages the capture on its own.const OUTPUT_TRANSFORM = process.env.ESTELLA_VERIFY_OUTPUT_TRANSFORM === 'aces' ? 'aces' : '';const MSAA = process.env.ESTELLA_VERIFY_MSAA ?? '';+const TEXTURES = process.env.ESTELLA_VERIFY_TEXTURES === 'runtime' ? 'runtime' : '';// A scene whose emitters roll dice has no constant to assert until the run is// seeded; the engine seeds itself from the clock when nobody says otherwise.const SEED = process.env.ESTELLA_VERIFY_SEED ?? '';@@ -218,7 +221,7 @@ function finish(result, server) {(result.seam?.ok ?? true) &&(result.resize?.ok ?? true) && (result.preview?.ok ?? true) &&(result.meshPreview?.ok ?? true) && (result.grid?.ok ?? true) &&- (result.draws?.ok ?? true) && (result.counters?.ok ?? true) && (result.frameDebug?.ok ?? true) && (result.edge?.ok ?? true) && (result.cutoutEdge?.ok ?? true) &&+ (result.draws?.ok ?? true) && (result.counters?.ok ?? true) && (result.frameDebug?.ok ?? true) && (result.edge?.ok ?? true) && (result.cutoutEdge?.ok ?? true) && (result.minified?.ok ?? true) &&(result.roundtrip?.ok ?? true) && deviceLossOk && meshOk && pickOk;const why = assetsOk ? '' : `: could not load ${result.missingAssets.join(', ')}`;console.log(`\n[verify:render] ${ok ? 'PASS' : 'FAIL'} — ${SCENE} (${BACKEND})${why}`);@@ -238,7 +241,7 @@ app.whenReady().then(async () => {let server;try {server = await serveHost(DIST);- const url = `http://127.0.0.1:${server.address().port}/${PAGE}?w=${W}&h=${H}&backend=${BACKEND}${COLORSPACE ? `&colorSpace=${COLORSPACE}` : ''}${OUTPUT_TRANSFORM ? `&outputTransform=${OUTPUT_TRANSFORM}` : ''}${MSAA ? `&msaa=${MSAA}` : ''}${DEPTH_LAYERS ? `&depthLayers=${DEPTH_LAYERS}` : ''}${RENDER_RESOLUTION ? `&renderResolution=${RENDER_RESOLUTION}` : ''}${SEED ? `&seed=${SEED}` : ''}`;+ const url = `http://127.0.0.1:${server.address().port}/${PAGE}?w=${W}&h=${H}&backend=${BACKEND}${COLORSPACE ? `&colorSpace=${COLORSPACE}` : ''}${OUTPUT_TRANSFORM ? `&outputTransform=${OUTPUT_TRANSFORM}` : ''}${MSAA ? `&msaa=${MSAA}` : ''}${TEXTURES ? `&textures=${TEXTURES}` : ''}${DEPTH_LAYERS ? `&depthLayers=${DEPTH_LAYERS}` : ''}${RENDER_RESOLUTION ? `&renderResolution=${RENDER_RESOLUTION}` : ''}${SEED ? `&seed=${SEED}` : ''}`;// useContentSize: the capture rectangle must be the page area, not the// outer frame (the same trap the parity runner documents).@@ -803,6 +806,28 @@ app.whenReady().then(async () => {return { rows, blended, share, minShare: e.minShare, ok: rows >= (y1 - y0) * 0.8 && share >= e.minShare };`);}+ // ESTELLA_VERIFY_MINIFIED = { box, maxRipple, minMean }: the mean gap between each pixel+ // and its four neighbours over a far-off texture — flat through a mip chain, shimmering+ // from the top level. minMean keeps a blank box from passing.+ let minified = null;+ if (process.env.ESTELLA_VERIFY_MINIFIED) {+ minified = await readFrame(`+ const e = ${JSON.stringify(JSON.parse(process.env.ESTELLA_VERIFY_MINIFIED))};+ const lum = (x, y) => { const i = (((h - 1) - y) * w + x) * 4; return (px[i] + px[i + 1] + px[i + 2]) / 3; };+ const [x0, y0, x1, y1] = [e.box[0] * w, e.box[1] * h, e.box[2] * w, e.box[3] * h].map(Math.round);+ let ripple = 0, sum = 0, n = 0;+ for (let y = y0 + 1; y < y1 - 1; y++) {+ for (let x = x0 + 1; x < x1 - 1; x++) {+ const v = lum(x, y);+ ripple += Math.abs(v - (lum(x - 1, y) + lum(x + 1, y) + lum(x, y - 1) + lum(x, y + 1)) / 4);+ sum += v; n++;+ }+ }+ const mean = n ? sum / n : 0;+ ripple = n ? ripple / n : Infinity;+ return { ripple, maxRipple: e.maxRipple, mean, minMean: e.minMean, ok: ripple <= e.maxRipple && mean >= e.minMean };+ `);+ }// ESTELLA_VERIFY_COUNT is a JSON array of { rgb:[r,g,b], tol?, atLeast?, atMost? }:// HOW MANY pixels of the frame are that colour, rather than which ones — a// point probe cannot ask that without also naming where a font put them.@@ -1001,7 +1026,7 @@ app.whenReady().then(async () => {`);if (respaced != null) grid = { ...grid, respacedPixels: respaced, ok: grid.ok && respaced > 300 };}- finish({ ok: true, entityCount, missingAssets, drawCalls, draws, counters, frameDebug, edge, cutoutEdge, profile, capture, expect, count, seam, resize, preview, meshPreview, grid, deviceLoss, roundtrip, meshResident, meshAsset, meshMaterial, meshPrefab, setField, animator, pick, cameraTarget }, server);+ finish({ ok: true, entityCount, missingAssets, drawCalls, draws, counters, frameDebug, edge, cutoutEdge, minified, profile, capture, expect, count, seam, resize, preview, meshPreview, grid, deviceLoss, roundtrip, meshResident, meshAsset, meshMaterial, meshPrefab, setField, animator, pick, cameraTarget }, server);} catch (e) {finish({ ok: false, error: String((e && e.stack) || e) }, server);}diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex 0482a99c1..4bdd12168 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -705,6 +705,10 @@ export const SCENES = [// multisampling on, coverage from alpha makes the texel before the cut a blend in a// share of rows (0.35 WebGL2, 0.26 WebGPU) that an alpha test does not (0.14, 0.07).{ id: "corpus-cutout-edge", tier: "pr", webgpu: true, corpora: ["khronos-alpha-blend-mode-test"], env: { ESTELLA_VERIFY_PREFAB: "/corpora/khronos-alpha-blend-mode-test/imported/AlphaBlendModeTest.esprefab", ESTELLA_VERIFY_SCENE: "/scenes/corpus-cutout-edge.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/corpus-alpha-modes.textures.json", ESTELLA_VERIFY_COLORSPACE: "linear", ESTELLA_VERIFY_MSAA: "4", ESTELLA_VERIFY_W: "640", ESTELLA_VERIFY_H: "640", ESTELLA_VERIFY_STEPS: "8", ESTELLA_VERIFY_CUTOUT_EDGE: "{\"box\":[0.5813,0.4219,0.6641,0.6875],\"lit\":180,\"run\":4,\"partial\":[115,180],\"minShare\":0.2}" } },+ // The same asset forty metres off, its textures uploaded as a shipped game's are:+ // with a mip chain the stripes average to a flat tint (ripple 7.8), sampling the top+ // level they shimmer (17.5). WebGL2 only: WebGPU builds no chain yet.+ { id: "corpus-distant-texture", tier: "pr", webgpu: false, corpora: ["khronos-alpha-blend-mode-test"], env: { ESTELLA_VERIFY_PREFAB: "/corpora/khronos-alpha-blend-mode-test/imported/AlphaBlendModeTest.esprefab", ESTELLA_VERIFY_SCENE: "/scenes/corpus-distant-texture.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/corpus-alpha-modes.textures.json", ESTELLA_VERIFY_COLORSPACE: "linear", ESTELLA_VERIFY_TEXTURES: "runtime", ESTELLA_VERIFY_W: "640", ESTELLA_VERIFY_H: "640", ESTELLA_VERIFY_STEPS: "8", ESTELLA_VERIFY_MINIFIED: "{\"box\":[0.469,0.461,0.688,0.516],\"maxRipple\":11,\"minMean\":100}" } },// Khronos's AlphaBlendModeTest (tools/corpora.mjs): the opaque box ignores its alpha, and// each cutout box is cut exactly at its own threshold — wall above the mark, stripes below.{ id: "corpus-alpha-modes", tier: "pr", webgpu: true, corpora: ["khronos-alpha-blend-mode-test"], env: { ESTELLA_VERIFY_PREFAB: "/corpora/khronos-alpha-blend-mode-test/imported/AlphaBlendModeTest.esprefab", ESTELLA_VERIFY_SCENE: "/scenes/corpus-alpha-modes.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/corpus-alpha-modes.textures.json", ESTELLA_VERIFY_W: "960", ESTELLA_VERIFY_H: "540", ESTELLA_VERIFY_STEPS: "8", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.2344,\"y\":0.3185,\"rgb\":[255,255,107],\"tol\":40},{\"x\":0.5135,\"y\":0.3167,\"rgb\":[255,255,255],\"tol\":40},{\"x\":0.5125,\"y\":0.4444,\"rgb\":[255,255,108],\"tol\":40},{\"x\":0.651,\"y\":0.3704,\"rgb\":[255,255,255],\"tol\":40},{\"x\":0.651,\"y\":0.487,\"rgb\":[255,255,108],\"tol\":40},{\"x\":0.7896,\"y\":0.4444,\"rgb\":[255,255,255],\"tol\":40},{\"x\":0.7875,\"y\":0.5185,\"rgb\":[107,255,255],\"tol\":40}]" } },