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): ambient occlusion works behind another effect

esengine9f2ff6c150d1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 471cb0d87..e959d6d16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ published separately; it ships inside the editor.
### Fixed
+- Ambient occlusion works behind another post-process effect. The scene's image went back to the pool after the last pass that read its colour, taking its depth with it, so an SSAO placed after a colour grade — as ORCA Bistro's volume has it — found no depth and occluded nothing, at any radius or intensity. The scene now lives until the chain's last pass.
- 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
diff --git a/fixtures/scenes/ssao-after-grade.esscene b/fixtures/scenes/ssao-after-grade.esscene
new file mode 100644
index 000000000..28515dec0
--- /dev/null
+++ b/fixtures/scenes/ssao-after-grade.esscene
@@ -0,0 +1,353 @@
+{
+ "version": 4,
+ "name": "SsaoAfterGrade",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 320,
+ "z": 480
+ },
+ "rotation": {
+ "x": -0.284,
+ "y": 0,
+ "z": 0,
+ "w": 0.9588
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60,
+ "nearPlane": 10,
+ "farPlane": 3000,
+ "isActive": true,
+ "priority": 0
+ }
+ },
+ {
+ "type": "PostProcessVolume",
+ "data": {
+ "isGlobal": true,
+ "priority": 0,
+ "weight": 1,
+ "effects": [
+ {
+ "type": "colorGrade",
+ "enabled": true,
+ "uniforms": {
+ "u_exposure": 0,
+ "u_contrast": 1,
+ "u_saturation": 1,
+ "u_temperature": 0,
+ "u_tint": 0
+ }
+ },
+ {
+ "type": "ssao",
+ "enabled": true,
+ "uniforms": {
+ "u_radius": 100,
+ "u_intensity": 1,
+ "u_bias": 0.12,
+ "u_power": 1.6
+ }
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Floor",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -200
+ },
+ "scale": {
+ "x": 14,
+ "y": 1,
+ "z": 14
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:plane",
+ "color": {
+ "r": 0.75,
+ "g": 0.75,
+ "b": 0.75,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "WallBack",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 125,
+ "z": -600
+ },
+ "scale": {
+ "x": 14,
+ "y": 2.5,
+ "z": 0.2
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:cube",
+ "color": {
+ "r": 0.7,
+ "g": 0.72,
+ "b": 0.78,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "WallLeft",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -600,
+ "y": 125,
+ "z": -200
+ },
+ "scale": {
+ "x": 0.2,
+ "y": 2.5,
+ "z": 8
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:cube",
+ "color": {
+ "r": 0.7,
+ "g": 0.72,
+ "b": 0.78,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Step",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -330,
+ "y": 25,
+ "z": -80
+ },
+ "scale": {
+ "x": 2,
+ "y": 0.5,
+ "z": 2
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:cube",
+ "color": {
+ "r": 0.65,
+ "g": 0.75,
+ "b": 0.6,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 5,
+ "name": "BoxContact",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -110,
+ "y": 50,
+ "z": -80
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:cube",
+ "color": {
+ "r": 0.8,
+ "g": 0.55,
+ "b": 0.4,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 6,
+ "name": "BoxFloating",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 110,
+ "y": 100,
+ "z": -80
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:cube",
+ "color": {
+ "r": 0.45,
+ "g": 0.65,
+ "b": 0.8,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 7,
+ "name": "Sphere",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 330,
+ "y": 50,
+ "z": -80
+ },
+ "scale": {
+ "x": 1,
+ "y": 1,
+ "z": 1
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "builtin:sphere",
+ "color": {
+ "r": 0.78,
+ "g": 0.7,
+ "b": 0.5,
+ "a": 1
+ },
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/esengine/renderer/frame/PostProcessPipeline.cpp b/src/esengine/renderer/frame/PostProcessPipeline.cpp
index 22ddb7a5e..701dc976e 100644
--- a/src/esengine/renderer/frame/PostProcessPipeline.cpp
+++ b/src/esengine/renderer/frame/PostProcessPipeline.cpp
@@ -485,8 +485,8 @@ void PostProcessPipeline::renderPass(PostProcessPass& pass, const rg::PassContex
}
}
// Scene depth, bound whether or not this pass reads it: the WGSL twin
- // declares the unit either way, and the scene is already every pass's
- // declared read, so its depth lives exactly as long as it does.
+ // declares the unit either way. runChain keeps the scene alive through
+ // every pass for it.
// A target with no depth binds nothing, and an effect over a scene that
// wrote none then finds no edge — the right answer for a flat one.
@@ -598,6 +598,10 @@ void PostProcessPipeline::runChain(std::vector<PostProcessPass>& passes, rg::Res
// (bloom's and SSAO's last link) lays its result over — not the untouched
// scene, which would discard every effect earlier in the chain.
node.reads = {input, effectInput};
+ // Every pass samples the scene's depth, so the scene target has to outlive
+ // the last pass that reads its colour: returned to the pool any earlier,
+ // an SSAO behind a colour grade found no depth and occluded nothing.
+ if (scene_needs_depth_) node.dependencies = {scene};
// The last pass feeds the blit, which copies into the output rect at the
// chain's size — so it draws full-size whatever fraction it asked for.
rg::TargetDesc writeDesc = (i == lastEnabled) ? blitDesc : desc;
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 104e53a13..20140692a 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -1262,6 +1262,8 @@ export const NOTED = {
{ note: 'A cutout\'s mip levels keep its coverage' },
'feat(import): images several materials share get every setting they ask for':
{ note: 'A cutout\'s mip levels keep its coverage' },
+ 'fix(render): ambient occlusion works behind another effect':
+ { note: 'Ambient occlusion works behind another post-process effect' },
'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':
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 4bdd12168..be56a4611 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -681,6 +681,10 @@ export const SCENES = [
// The other half: the same edges, read through an identity post chain.
{ id: "aa-edge-post", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/aa-edge-post.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.2353,\"y\":0.502,\"rgb\":[128,128,128],\"tol\":64},{\"x\":0.2392,\"y\":0.502,\"rgb\":[128,128,128],\"tol\":64},{\"x\":0.749,\"y\":0.502,\"rgb\":[128,128,128],\"tol\":64},{\"x\":0.7529,\"y\":0.502,\"rgb\":[128,128,128],\"tol\":64},{\"x\":0.502,\"y\":0.502,\"rgb\":[255,255,255],\"tol\":6},{\"x\":0.0784,\"y\":0.0784,\"rgb\":[0,0,0],\"tol\":6}]" } },
{ id: "ssao", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/ssao.esscene", ESTELLA_VERIFY_W: "320", ESTELLA_VERIFY_H: "240", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5016,\"y\":0.8996,\"rgb\":[191,191,191],\"tol\":6},{\"x\":0.3762,\"y\":0.4937,\"rgb\":[144,144,144],\"tol\":20},{\"x\":0.627,\"y\":0.4812,\"rgb\":[172,172,172],\"tol\":9},{\"x\":0.8527,\"y\":0.4686,\"rgb\":[147,147,147],\"tol\":9},{\"x\":0.1881,\"y\":0.5272,\"rgb\":[123,141,113],\"tol\":22},{\"x\":0.1285,\"y\":0.1967,\"rgb\":[133,136,148],\"tol\":9},{\"x\":0.627,\"y\":0.2008,\"rgb\":[179,184,199],\"tol\":5}]" } },
+ // The same occlusion with a neutral colour grade ahead of it in the chain: a pass
+ // behind another one still samples the scene's depth. WebGL2 only: on WebGPU each
+ // fullscreen pass turns the colour upside down while the occlusion stays upright.
+ { id: "ssao-after-grade", tier: "pr", webgpu: false, env: { ESTELLA_VERIFY_SCENE: "/scenes/ssao-after-grade.esscene", ESTELLA_VERIFY_W: "320", ESTELLA_VERIFY_H: "240", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5016,\"y\":0.8996,\"rgb\":[191,191,191],\"tol\":6},{\"x\":0.3762,\"y\":0.4937,\"rgb\":[144,144,144],\"tol\":20},{\"x\":0.627,\"y\":0.4812,\"rgb\":[172,172,172],\"tol\":9},{\"x\":0.8527,\"y\":0.4686,\"rgb\":[147,147,147],\"tol\":9},{\"x\":0.1881,\"y\":0.5272,\"rgb\":[123,141,113],\"tol\":22},{\"x\":0.1285,\"y\":0.1967,\"rgb\":[133,136,148],\"tol\":9},{\"x\":0.627,\"y\":0.2008,\"rgb\":[179,184,199],\"tol\":5}]" } },
{ id: "depth-outline-flat", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/depth-outline-flat.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[230,102,26],\"tol\":20}]" } },
{ id: "mesh-opaque", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-depth.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh-depth.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.42,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40},{\"x\":0.58,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },
{ id: "mesh-opaque-off", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SET_FIELD: "{\"entity\":2,\"component\":\"MeshRenderer\",\"key\":\"opaque\",\"value\":false}", ESTELLA_VERIFY_SCENE: "/scenes/mesh-depth.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh-depth.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.42,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40},{\"x\":0.58,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40}]" } },