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(terrain): a splatmap is numbers too - cooked as a picture its three weights were overwritten wherever the fourth was 0, and the whole ground was painted as grass; it is marked Data when it is set, as the heightmap is
yhhfc2b171f9de7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 16fe0962f..edc2d397d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,7 +16,7 @@ published separately; it ships inside the editor.### Added-- **A texture says whether it is a picture or numbers.** Import settings have a **Use**: Colour, or Data for an image read a number a texel (a heightmap, a mask of measured values, a lookup table). A build treats Data as what it is: never compressed, never decoded as sRGB or filled, kept at its depth, and at its own size unless Max Size (which now offers Source size) says otherwise, in which case it is resampled at 16 bits and not through 8. Nobody has to know to set it: a PNG of 16 bits a sample is imported as Data from the editor and the CLI alike, a texture put in a `Terrain`'s heightmap is marked Data there and then, and Project Health lists textures a component reads as numbers that are still set up as pictures, with the fix on the row.+- **A texture says whether it is a picture or numbers.** Import settings have a **Use**: Colour, or Data for an image read a number a texel (a heightmap, a mask of measured values, a lookup table). A build treats Data as what it is: never compressed, never decoded as sRGB or filled, kept at its depth, and at its own size unless Max Size (which now offers Source size) says otherwise, in which case it is resampled at 16 bits and not through 8. Nobody has to know to set it: a PNG of 16 bits a sample is imported as Data from the editor and the CLI alike, a texture put in a `Terrain`'s heightmap or splatmap is marked Data there and then (a splatmap cooked as a picture had its weights overwritten wherever the fourth was 0, and the ground fell back to grass everywhere), and Project Health lists textures a component reads as numbers that are still set up as pictures, with the fix on the row.- **An ocean reaches the horizon.** The sea's surface is rings of mesh round the camera, and it ended where they did: from a hill, or with a small `cells` and `rings`, a straight edge with nothing past it. A flat apron now carries it on to 80 km, at the cost of one row of quads.- **One setting says what a unit is, for materials too.** A shader param declares `unit(length)` or `unit(perLength)` and its default and range follow the project's Units per Metre, as a component's lengths and a post-process effect's already did; the inspector shows the project's numbers. The water was the reason: its shader, `WaterBody`, `WaterZone` and the sky's World Units per km held their defaults in metres while the engine's reference is centimetres, so stock water in a default project was a hundredth of its size and a scene in metres copied from one in centimetres drew clear water. They are now written once, at the reference, and are the same water in either. **A scene that relied on the old defaults in a centimetre project** (a `WaterBody` or `WaterZone` field left unset, a Water material with unset lengths, clouds with World Units per km unset) draws them a hundred times larger than before, which is what they were meant to be; state the values, or set Units per Metre to 1 if the scene is in metres.diff --git a/desktop b/desktopindex d09d5335a..5e82bd41e 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit d09d5335ae772b95dcc7efe07c6fe99a3b73a4d9+Subproject commit 5e82bd41e446981355b1828d82782df0639b5f5ediff --git a/pipeline/tests/texture-cook.test.ts b/pipeline/tests/texture-cook.test.tsindex 6731a2cb6..3baa67b7a 100644--- a/pipeline/tests/texture-cook.test.ts+++ b/pipeline/tests/texture-cook.test.ts@@ -160,7 +160,7 @@ describe('a PNG of 16 bits a channel', () => {});describe('a texture a component reads as numbers', () => {- it('is found, while its Use is still Colour, from the Terrain that names it as its heightmap', async () => {+ it('is found, while its Use is still Colour, from the Terrain that names it as its heightmap or a splatmap', async () => {const { numberTexturesMarkedColour } = await import('../src/assets/dataTextureAudit');const scene = JSON.stringify({ entities: [{ components: [{ type: 'Terrain', data: { heightmap: 'assets/height.png', splatmap: 'assets/colour.png' } }] },@@ -173,8 +173,9 @@ describe('a texture a component reads as numbers', () => {resolveRef: (ref) => (ref === '@uuid:h2' ? 'assets/other.png' : ref.startsWith('@uuid:') ? null : ref),importer: (p) => importers[p],});- expect(findings.map((f) => f.texture)).toEqual(['assets/height.png', 'assets/other.png']);- expect(findings[0]!.readBy[0]).toEqual({ document: 'assets/scenes/a.esscene', component: 'Terrain', field: 'heightmap' });+ expect(findings.map((f) => f.texture)).toEqual(['assets/colour.png', 'assets/height.png', 'assets/other.png']);+ expect(findings[0]!.readBy[0]).toEqual({ document: 'assets/scenes/a.esscene', component: 'Terrain', field: 'splatmap' });+ expect(findings[1]!.readBy[0]).toEqual({ document: 'assets/scenes/a.esscene', component: 'Terrain', field: 'heightmap' });});it('marked Data ships uncapped by default, and at its own depth when its Max Size caps it', async () => {diff --git a/sdk/src/asset/textureUse.ts b/sdk/src/asset/textureUse.tsindex 39e7b5721..96aa565c7 100644--- a/sdk/src/asset/textureUse.ts+++ b/sdk/src/asset/textureUse.ts@@ -4,14 +4,15 @@* @file textureUse.ts — which component fields read a texture as numbers.** A texture is a picture unless something says otherwise, and a build treats a picture as one: capped at a size, compressed,- * decoded as colour. The fields here read each texel as a number instead (a Terrain's heights), where every one of those is+ * decoded as colour. The fields here read each texel as a number instead (a Terrain's heights and its layer weights), where every one of those is* different data. The texture's own import setting (`use: 'data'`) is what a build obeys; this is what the editor sets it by* when a texture is put in such a field, and what Project Health holds the two together with.*//** Component type to the texture fields of it that are read as numbers. */export const DATA_TEXTURE_FIELDS: Readonly<Record<string, readonly string[]>> = {- Terrain: ['heightmap'],+ // The splatmaps are weights, four a texel: a picture's clear-texel fill writes its neighbours' colour wherever the fourth is 0.+ Terrain: ['heightmap', 'splatmap', 'splatmap2'],};/** Whether `component.field` reads its texture as numbers. */diff --git a/sdk/tests/texture-use.test.ts b/sdk/tests/texture-use.test.tsindex 3db1b09a2..1aa1cc7c6 100644--- a/sdk/tests/texture-use.test.ts+++ b/sdk/tests/texture-use.test.ts@@ -15,7 +15,8 @@ describe('the fields that read a texture as numbers', () => {it('answer for one field', () => {expect(readsTextureAsNumbers('Terrain', 'heightmap')).toBe(true);- expect(readsTextureAsNumbers('Terrain', 'splatmap')).toBe(false);+ expect(readsTextureAsNumbers('Terrain', 'splatmap')).toBe(true);+ expect(readsTextureAsNumbers('Terrain', 'material')).toBe(false);expect(readsTextureAsNumbers('Sprite', 'texture')).toBe(false);});});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 3ac2ce06d..265f74073 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4518,4 +4518,6 @@ export const NOTED = {{"note": "One setting says what a unit is, for materials too."},"feat(assets): a texture's Use says whether it is a picture or numbers - Data keeps its depth and its size in a build, a 16-bit PNG is imported as Data, a Terrain's heightmap is marked Data when it is set, and Project Health lists the ones that are not":{"note": "A texture says whether it is a picture or numbers."},+ "feat(editor): a texture given to a Terrain as its heightmap is marked Data, and Project Health lists the ones read as numbers that are still pictures":+ {"note": "A texture says whether it is a picture or numbers."},};