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(render): an opaque mesh tests and writes depth whatever its material says, so a new material no longer shows a sphere's inside
yhh0d54b6d77bf0
diff --git a/desktop b/desktopindex d19b3ba2c..7f69480a7 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit d19b3ba2c7609ca5877c1e9e9443a53c18ccc1c9+Subproject commit 7f69480a7128470408f256532b9c162234b4b39ddiff --git a/src/esengine/renderer/plugins/MeshPlugin.cpp b/src/esengine/renderer/plugins/MeshPlugin.cppindex 77d629fa2..bf29ecc46 100644--- a/src/esengine/renderer/plugins/MeshPlugin.cpp+++ b/src/esengine/renderer/plugins/MeshPlugin.cpp@@ -830,7 +830,7 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {// A material that bends its vertices can put them outside the mesh's own box; culling the// box would drop a bent mesh that is still on screen, so it grows by what the material says.const f32 bend = material ? ctx.materials->vertexBounds(mesh.material) : 0.0f;- const bool depthTested = material ? material->depthTest : mesh.opaque;+ const bool depthTested = mesh.opaque || (material && material->depthTest);glm::vec3 aabbCenter(0.0f), halfExtents(0.0f);orientedWorldAabb(position, rotation, scale, localMin - glm::vec3(bend), localMax + glm::vec3(bend),@@ -974,8 +974,10 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {// no surface record (screen-space reflections and rain read nothing) and a cut-out lost its alpha-to-coverage.key.blend = mesh.opaque ? BlendMode::None : m->blend;key.materialId = mesh.material;- key.depthTest = m->depthTest;- key.depthWrite = m->depthWrite;+ // Depth likewise, or a sphere's far side draws over its near side: a new material says depthTest false, and+ // the surface reads as the inside of a bowl, under light and shadow that look wrong for no reason a person can see.+ key.depthTest = mesh.opaque || m->depthTest;+ key.depthWrite = mesh.opaque || m->depthWrite;key.cull = static_cast<u8>(m->cull);key.depthBias = m->depthBias;}