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.

fix(render): bind all 8 batch samplers so multi-texture draws are WebGL2-complete — REARCH_RENDER RC7-2 fix

esengine91ecd83651cf
diff --git a/desktop/package.json b/desktop/package.json
index 37d327f32..ba0d526a0 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -15,6 +15,7 @@
"verify:render": "vite build && electron scripts/headless-verify.mjs",
"verify:render:spine": "vite build && ESTELLA_VERIFY_SCENE=/scenes/spine-test.esscene ESTELLA_VERIFY_MANIFEST=/scenes/spine-test.textures.json electron scripts/headless-verify.mjs",
"verify:render:particles": "vite build && ESTELLA_VERIFY_PLAY=1 ESTELLA_VERIFY_SCENE=/scenes/particle-demo.esscene ESTELLA_VERIFY_MANIFEST=/scenes/particle-demo.textures.json ESTELLA_VERIFY_STEPS=90 electron scripts/headless-verify.mjs",
+ "verify:render:postprocess": "vite build && ESTELLA_VERIFY_PLAY=1 ESTELLA_VERIFY_SCENE=/scenes/postprocess-effects.esscene ESTELLA_VERIFY_MANIFEST=/scenes/postprocess-effects.textures.json ESTELLA_VERIFY_STEPS=30 electron scripts/headless-verify.mjs",
"verify:smoke": "vite build && electron scripts/headless-smoke.mjs",
"mcp": "electron electron/mcp/server.mjs",
"mcp:smoke": "vite build && node electron/mcp/smoke.mjs"
diff --git a/desktop/public/scenes/postprocess-effects.esscene b/desktop/public/scenes/postprocess-effects.esscene
new file mode 100644
index 000000000..cacce4528
--- /dev/null
+++ b/desktop/public/scenes/postprocess-effects.esscene
@@ -0,0 +1,158 @@
+{
+ "version": "1.0",
+ "name": "Main",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },
+ { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 300, "isActive": true, "priority": 0 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 1,
+ "name": "OrbitSprite0",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 100, "y": 0, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.96, "g": 0.24, "b": 0.24, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 0.5, "radius": 80 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 2,
+ "name": "OrbitSprite1",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 70.71, "y": 70.71, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.96, "g": 0.78, "b": 0.24, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 0.6, "radius": 110, "angle": 0.79 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 3,
+ "name": "OrbitSprite2",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 0, "y": 100, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.6, "g": 0.96, "b": 0.24, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 0.7, "radius": 140, "angle": 1.57 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 4,
+ "name": "OrbitSprite3",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": -70.71, "y": 70.71, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.24, "g": 0.96, "b": 0.42, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 0.8, "radius": 80, "angle": 2.36 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 5,
+ "name": "OrbitSprite4",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": -100, "y": 0, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.24, "g": 0.96, "b": 0.96, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 0.9, "radius": 110, "angle": 3.14 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 6,
+ "name": "OrbitSprite5",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": -70.71, "y": -70.71, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.24, "g": 0.42, "b": 0.96, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 1.0, "radius": 140, "angle": 3.93 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 7,
+ "name": "OrbitSprite6",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 0, "y": -100, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.6, "g": 0.24, "b": 0.96, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 1.1, "radius": 80, "angle": 4.71 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 8,
+ "name": "OrbitSprite7",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 70.71, "y": -70.71, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 50, "y": 50 }, "color": { "r": 0.96, "g": 0.24, "b": 0.78, "a": 1 } } },
+ { "type": "Orbit", "data": { "speed": 1.2, "radius": 110, "angle": 5.50 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 9,
+ "name": "CenterSprite",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": {} },
+ { "type": "Sprite", "data": { "size": { "x": 60, "y": 60 } } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 10,
+ "name": "PostProcess",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": {} },
+ { "type": "PostProcessVolume", "data": {
+ "isGlobal": true,
+ "priority": 0,
+ "weight": 1,
+ "effects": [
+ {
+ "type": "bloom",
+ "enabled": true,
+ "uniforms": {
+ "u_threshold": 0.3,
+ "u_intensity": 1.5,
+ "u_radius": 6
+ }
+ },
+ {
+ "type": "vignette",
+ "enabled": true,
+ "uniforms": {
+ "u_intensity": 0.8,
+ "u_softness": 0.5
+ }
+ }
+ ]
+ }}
+ ],
+ "visible": true
+ }
+ ]
+}
diff --git a/desktop/public/scenes/postprocess-effects.textures.json b/desktop/public/scenes/postprocess-effects.textures.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/desktop/public/scenes/postprocess-effects.textures.json
@@ -0,0 +1 @@
+{}
diff --git a/src/esengine/renderer/DrawList.cpp b/src/esengine/renderer/DrawList.cpp
index 5ba3a3fa4..5588f5a53 100644
--- a/src/esengine/renderer/DrawList.cpp
+++ b/src/esengine/renderer/DrawList.cpp
@@ -136,8 +136,19 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,
if (stencil != GfxStencilMode::Off) {
device.setStencilReference(cmd.stencil_ref);
}
- for (u8 slot = 0; slot < cmd.texture_count; ++slot) {
- device.bindTexture(slot, cmd.texture_ids[slot]);
+ // The batch shader declares 8 samplers, and WebGL2 invalidates a draw if any
+ // referenced sampler unit lacks a complete texture — even units the per-vertex
+ // branch never samples. For the Batch layout, fill the unused slots with slot 0's
+ // (always-valid) texture; other layouts bind only the samplers they declare.
+ if (cmd.layout_id == LayoutId::Batch) {
+ for (u8 slot = 0; slot < MAX_CMD_TEXTURE_SLOTS; ++slot) {
+ u32 tex = (slot < cmd.texture_count) ? cmd.texture_ids[slot] : cmd.texture_ids[0];
+ device.bindTexture(slot, tex);
+ }
+ } else {
+ for (u8 slot = 0; slot < cmd.texture_count; ++slot) {
+ device.bindTexture(slot, cmd.texture_ids[slot]);
+ }
}
if (cmd.instance_count > 0) {