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): a drawn sky fills the frame from every angle

esengine14c510c1f752
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e118c6bc4..c95f13f5c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,7 @@ published separately; it ships inside the editor.
### Fixed
+- **A drawn sky no longer vanishes, or half-vanishes, as the view turns.** The sky was a quad on the far plane, and where rounding put it a hair past that plane it was clipped: in the editor, with its distant far plane, more than half the angles showed black behind the grid, or a sky cut along a diagonal. It now sits inside the view volume and fills the frame from every angle, in the editor and in the game.
- **With more than one camera, the profiler and the draw-call count cover the whole frame.** Each camera reset the frame's tally and closed the profiler's frame, so a split screen, or a scene with a UI camera, reported only the last camera's draw calls, triangles, merge counts and C++ timings, and the batch-break reasons of the others were lost. The frame now counts every camera and the screen overlay, once, and an asset preview rendered in between counts toward none of them.
- **A game started right after the project opened no longer restarts itself about ten seconds in.** Pressing Play while the editor was still warming the game's engine up handed the scene over twice: once when the engine greeted the editor, and again when the warm-up's ten-second wait ran out — so the game restarted, and everything that had happened in it was gone. It now starts once, as soon as the engine is up.
- A mini-game whose host's WebGL2 context also offers `OES_vertex_array_object` renders instead of hanging: the WebGL1 extensions WebGL2 made core are withheld from a WebGL2 context, as the spec says, so Emscripten no longer swaps in the host's broken extension path (vivo's).
diff --git a/desktop b/desktop
index c1a71f039..70e68fe54 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit c1a71f03913140e906f6ff1c852e97c203c69e46
+Subproject commit 70e68fe5448547170e05435d2e81607408db5ff3
diff --git a/src/esengine/data/shaders/sky.esshader b/src/esengine/data/shaders/sky.esshader
index d5412aca0..42298b148 100644
--- a/src/esengine/data/shaders/sky.esshader
+++ b/src/esengine/data/shaders/sky.esshader
@@ -6,7 +6,7 @@
// sky behind it are the same baked panorama; without this only one of them was
// ever visible, and a scene lit by a sky sat in front of a flat clear colour.
//
-// Geometry is a quad on the far plane, so the vertex stage needs no matrix of its
+// Geometry is a quad over the whole screen, so the vertex stage needs no matrix of its
// own — the fragment's direction is the one from the eye through it, which is
// what viewDirection() already answers (negated: it points AT the viewer).
diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cpp
index 01a8f7763..c88693732 100644
--- a/src/esengine/renderer/frame/RenderFrame.cpp
+++ b/src/esengine/renderer/frame/RenderFrame.cpp
@@ -1840,9 +1840,9 @@ void RenderFrame::executeShadowPass(ecs::Registry& registry) {
}
/**
- * The background an environment is, as a quad on the far plane. Not a plugin and
- * not an entity: a sky belongs to no transform and is culled by nothing. Its
- * corners are the far plane's, unprojected, so a fragment's direction is the one
+ * The background an environment is, as a quad covering the screen. Not a plugin
+ * and not an entity: a sky belongs to no transform and is culled by nothing. Its
+ * corners are unprojected screen corners, so a fragment's direction is the one
* from the eye through it — which viewDirection() already answers.
*/
void RenderFrame::collectSky(RenderCollectContext& ctx) {
@@ -1862,13 +1862,14 @@ void RenderFrame::collectSky(RenderCollectContext& ctx) {
}
if (sky_program_ == 0) return;
- // The far plane's four corners in world space. Clip z = 1 is that plane under
- // both backends' shared projection, and w divides out whichever it is.
+ // The rays through the screen's corners, at a depth inside both backends'
+ // ranges: a quad at clip z = 1 rounds past the far plane at some view angles and
+ // is clipped whole. The depth does not change which rays are drawn.
const glm::mat4 invVP = glm::inverse(ctx.frame_context.view_projection);
glm::vec3 corners[4];
const glm::vec2 ndc[4] = {{-1.0f, -1.0f}, {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};
for (u32 i = 0; i < 4; ++i) {
- const glm::vec4 p = invVP * glm::vec4(ndc[i], 1.0f, 1.0f);
+ const glm::vec4 p = invVP * glm::vec4(ndc[i], 0.5f, 1.0f);
corners[i] = glm::vec3(p) / p.w;
}
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 4c3750cb2..be6066aaf 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -988,6 +988,8 @@ export const NOTED = {
{ note: 'A frame can be captured draw call by draw call, and replayed up to any one of them.' },
'feat(render): a frame capture lists every texture a draw bound':
{ note: 'A frame can be captured draw call by draw call, and replayed up to any one of them.' },
+ 'fix(render): a drawn sky fills the frame from every angle':
+ { note: 'A drawn sky no longer vanishes, or half-vanishes, as the view turns.' },
'fix(render): the profiler and the draw-call count cover every camera of the frame':
{ note: 'With more than one camera, the profiler and the draw-call count cover the whole frame.' },
'fix(play): a Play pressed while the engine warms up starts the game once, not again ten seconds later':
diff --git a/tools/render-host/run.mjs b/tools/render-host/run.mjs
index a2004672f..89d66a711 100644
--- a/tools/render-host/run.mjs
+++ b/tools/render-host/run.mjs
@@ -33,6 +33,7 @@
* ESTELLA_VERIFY_COUNTERS engine counters the drawn frame must report (JSON)
* ESTELLA_VERIFY_COUNTERS_MAX counters the frame must stay UNDER — a budget (JSON)
* ESTELLA_VERIFY_FRAME_DEBUG capture the frame and replay it (the frame debugger)
+ * ESTELLA_VERIFY_UNIFORM the frame is one colour on purpose; ESTELLA_VERIFY_COUNT says which
* 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_PROFILE record N further frames and report the TS/C++ cost split
@@ -202,7 +203,10 @@ function finish(result, server) {
// A hit test answering the wrong entity (or nothing) is the box being wrong,
// which no pixel in the frame can show.
const pickOk = !result.pick || result.pick.hit === result.pick.want;
- const renderedOk = result.capture?.rendered ?? false;
+ // A frame of one colour reads as a bare clear. Where one colour IS the answer, a
+ // count of that colour is what proves something drew it.
+ const uniformByDesign = Boolean(process.env.ESTELLA_VERIFY_UNIFORM) && result.count?.ok === true;
+ const renderedOk = (result.capture?.rendered ?? false) || uniformByDesign;
// A scene that could not load an asset it names draws a frame nobody declared, so
// its pixels answer a different question — say which asset instead.
const assetsOk = (result.missingAssets?.length ?? 0) === 0;
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 2131aa6f8..2c1dc2c6f 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -298,6 +298,12 @@ export const SCENES = [
// white colour, normals up and down under a sky blue above and red below. A flat
// ambient term draws the halves identically, which is why the probes invert.
{ id: "mesh-sky", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-sky.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.15,\"rgb\":[0,0,153],\"tol\":20},{\"x\":0.5,\"y\":0.85,\"rgb\":[153,0,0],\"tol\":20},{\"x\":0.5,\"y\":0.5,\"rgb\":[106,0,33],\"tol\":20},{\"x\":0.15,\"y\":0.5,\"rgb\":[76,0,70],\"tol\":20}]" } },
+ // The sky from the editor eye. Level is where a quad on the far plane rounded past
+ // it and was clipped whole; down and up hold which half is which. The editor's own
+ // sweep (desktop editor check sky-angles) covers the angles this eye does not.
+ { id: "sky-eye-down", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-sky.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PERSPECTIVE: "1", ESTELLA_VERIFY_ORBIT: "0,60", ESTELLA_VERIFY_UNIFORM: "1", ESTELLA_VERIFY_COUNT: "[{\"rgb\":[153,0,0],\"tol\":48,\"atLeast\":60000}]" } },
+ { id: "sky-eye-up", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-sky.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PERSPECTIVE: "1", ESTELLA_VERIFY_ORBIT: "0,-60", ESTELLA_VERIFY_UNIFORM: "1", ESTELLA_VERIFY_COUNT: "[{\"rgb\":[0,0,153],\"tol\":48,\"atLeast\":60000}]" } },
+ { id: "sky-eye-level", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-sky.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PERSPECTIVE: "1", ESTELLA_VERIFY_ORBIT: "180,0", ESTELLA_VERIFY_COUNT: "[{\"rgb\":[0,0,153],\"tol\":48,\"atLeast\":6000},{\"rgb\":[153,0,0],\"tol\":48,\"atLeast\":2500}]" } },
{ id: "mat-env", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-env.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.55,\"rgb\":[0,6,149],\"tol\":20},{\"x\":0.75,\"y\":0.55,\"rgb\":[148,8,0],\"tol\":20},{\"x\":0.5,\"y\":0.55,\"rgb\":[0,0,0],\"tol\":20}]" } },
// The same sky in a MIRROR: two metal quads, roughness 0 and 1. A head-on
// surface reflects +Z, which is the image centre — green there, and the whole