Skip to content

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.

chore(gates): the note for a mesh shader's eighth texture, and voxel ground's test reads its wet map

yhhda321efb3243
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2911685ce..e21f72896 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@ published separately; it ships inside the editor.
- **The ground's lengths follow the project's units.** A `Terrain`'s size, height, cell, draw distance and collision distance were plain numbers, and so were its shaders' layer tiles, relief and wet line and a layer file's default tile: a new terrain in a default project was ten metres of ground on 2 cm cells with collision built 64 cm round a body. They are lengths now (`worldUnitFields`, `unit(length)`), written at 100 units a metre: a kilometre of ground on 2 m cells, collision 64 m round a body, a layer 24 m across, in a centimetre project and a metre one. What a scene, a material or a layer file states is untouched; a scene that left `collisionDistance` or `drawDistance` to the default gets the new one, so state the old (64, 4000) to keep it. Ground with `layers` is also no longer sent the four layer colours of the plain shader, which warned four times a load.
- **Water mirrors only what is there.** Over open sea with no ground behind it the water's reflection went black: the ray through the picture took a sky pixel for something it had met, and the sky is painted after that picture is taken. From above, the sea darkened along the edge of the terrain under it, a line across the water. And a ripple steep enough to send the ray down met the sea bed in the picture, undimmed by its water: white flecks all over a shallow sea. The copy of the scene's distances now marks where the picture holds nothing, a ray sent down goes on up as off the next wave, and waves finer than a pixel widen the sun's highlight instead of flashing pixel by pixel. The ray's step and the thickness of what it meets are shares of the distance to the water, where they were a number of units (a centimetre in one project, a metre in another).
+- **A mesh shader's eighth texture finds a unit.** A material's textures past the seventh take an engine unit the shader never reads. A shader that named `u_textures` at all was counted as reading all eight batch units, though a mesh shader reads only its base texture, `u_textures[0]`: so anything built on Model had seven textures and no more. Ground Blend has eight, lost the last (the wet-ground map), and did not compile on WebGPU (`unresolved value 'u_wetMask'`); voxel ground had dropped its wet map to stay under. A literal index now counts as that one unit, so a Lit mesh shader has eight, Ground Blend draws on WebGPU, and voxel ground is wet where the weather says, as other ground is.
- **A 16-bit heightmap keeps its depth and size in a build.** A texture is capped at its Max Size (2048 unless set) when a build cooks it, and the cap decodes a PNG to 8 bits a channel on the way. A `Terrain` heightmap of 4096 samples and 16 bits therefore shipped as 2048 samples of 256 steps: the exported ground was terraced and coarser than the same ground in the editor, which reads the file itself, and nothing said so. See Use, above; a PNG of 16 bits that is still marked Colour ships byte for byte and the build says so.
## [0.103.0] - 2026-11-12
diff --git a/sdk/tests/voxel-shader.test.ts b/sdk/tests/voxel-shader.test.ts
index 0ae52afc2..637ab09bc 100644
--- a/sdk/tests/voxel-shader.test.ts
+++ b/sdk/tests/voxel-shader.test.ts
@@ -11,15 +11,15 @@ const textureParams = (source: string): string[] =>
describe('Voxel Ground, derived from the Model shader', () => {
const derived = deriveVoxelGround(MODEL);
- it('declares no more textures than a shader has units for', () => {
- // What the Model shader gains, Voxel Ground (which adds three maps of its own) must give up, or its last texture is dropped
- // and the shader no longer compiles on WebGPU.
- expect(textureParams(derived).length).toBeLessThanOrEqual(7);
+ it('declares no more textures than a Lit mesh shader has units for', () => {
+ // Seven material units and unit 1, the one engine unit a shader that reads only its base texture leaves (ShaderParser::materialOverflowUnits).
+ expect(textureParams(derived).length).toBeLessThanOrEqual(8);
});
- it('has no wet map to read, and nothing in either language still names one', () => {
- expect(textureParams(derived)).not.toContain('u_wetMask');
- expect(derived).not.toMatch(/textureLod\(u_wetMask|u_wetMask_s/);
+ it('reads the wet map as other ground does, in both languages', () => {
+ expect(textureParams(derived)).toContain('u_wetMask');
+ expect(derived).toMatch(/textureLod\(u_wetMask/);
+ expect(derived).toMatch(/u_wetMask_s/);
});
it('keeps the three materials it lays by world position', () => {
diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cpp
index aca795197..0860a12f9 100644
--- a/src/esengine/resource/ShaderParser.cpp
+++ b/src/esengine/resource/ShaderParser.cpp
@@ -4335,13 +4335,10 @@ u32 batchUnitsRead(const std::string& text) {
} // namespace
/**
- * The units below MATERIAL_TEXTURE_UNIT_BASE a material texture may take on @p shader, as a mask.
- * @details The engine binds those units per draw, so one is free only where this shader never reads what the engine puts
- * there. Two questions decide it. What the domain's injected code reads: a Lit stage takes the shadow map, the
- * reflection atlas, the bake and both 2D masks, and every mesh variant takes the morph deltas. And what the
- * shader's own text names, in either language, all variants at once: the batch textures (u_textures: the one a
- * literal index names, every one where the index is worked out), an engine sampler by name, or a `tN`/`sN` unit. A
- * fullscreen pass and the UI reach their low units through their own conventions, so they keep none free.
+ * The units below MATERIAL_TEXTURE_UNIT_BASE a material texture may take on @p shader, as a mask: those the engine binds per draw that
+ * this shader never reads. Read are what its domain's injected code takes (Lit: shadow map, reflections, bake, both 2D masks; every
+ * mesh: morph deltas) and what its own text names in either language: batch textures (batchUnitsRead), an engine sampler, a `tN`/`sN`
+ * unit. A fullscreen pass and the UI reach their low units through their own conventions and keep none free.
*/
u32 ShaderParser::materialOverflowUnits(const ParsedShader& shader) {
u32 reads = 0;
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index cc2b9e973..2df84dc97 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -4540,6 +4540,8 @@ export const NOTED = {
{"note": "Water is a body and a surface."},
"feat(terrain): a colour map over the ground - Terrain.colorMap is a picture laid over a whole area and mixed into the ground's colour by its alpha, on the plain shader and on the layered one, with colorMapStrength read each frame":
{"note": "A colour map over the ground."},
+ "fix(materials): a mesh shader's eighth texture finds a unit - reading its base texture as u_textures[0] was counted as reading all eight batch units, so Ground Blend lost its wet map and did not compile on WebGPU, and voxel ground had given its own up; a literal index is that unit alone":
+ {"note": "A mesh shader's eighth texture finds a unit."},
"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":
{"note": "A texture says whether it is a picture or numbers."},
};