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): a mesh with tangents and a normal map links its shadow program when the sun casts shadows
yhh27049a03009a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a32aeab03..925361546 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,27 +14,9 @@ published separately; it ships inside the editor.## [Unreleased]-### Fixed--- **Selection outline across a plane.** The selection outline of a mesh no longer draws a stray line across a large plane seen from close by: a triangle with a corner behind the camera was judged by a different rule than its neighbour, so their shared diagonal showed as an edge.-- **Normal maps read against the frame they were baked in.** Imported meshes now carry a tangent at each vertex (a glTF's own direction, or one made from the UVs), and normal maps on them are read against that frame instead of one derived per pixel, which was wrong at UV seams and on stretched textures. Re-import a model to get them; one imported before keeps its old shading. A mesh whose vertices carry a tangent is drawn with an extra vertex attribute and one more varying; a shader of your own that calls `perturbNormal` picks the frame up with no change.-- **New Project keeps the wrong template name.** The New Project page no longer keeps the previous template's name when you pick another: the suggested name follows the template, and a name you typed stays.--### Changed--- **A lite engine for mini-games.** A WeChat or Douyin package whose scenes and scripts use no particle emitter, post-process volume or tilemap now ships a lite engine, the same engine without those three subsystems and about 200 KB smaller, so a UI-only game has room under the 4 MB main-package limit. It is chosen from the same evidence as the lean SDK entry plus a scan of the project's scripts; any mention of one of the three carries the full engine. Build it with `node build-tools/cli.js build -t wechat-lite` (`-t all` includes it).-- **Post-process effects are optional groups.** The post-process effects' shaders are now three optional groups, esengine/fx-basic, esengine/fx-atmosphere and esengine/fx-lighting: a package carries a group when a PostProcessVolume names one of its effects (or a Weather or TimeOfDay component is in the content), and a game with no volumes ships none of them (about 180 KB less in a UI-only mini-game). An effect a script adds by code needs its group imported (`esengine/fx-basic` and the others) or the module set to Include; the editor and a non-lean entry carry all three.-- **Timelines are an optional module.** Timelines are now an optional module, esengine/timeline: a package carries the timeline runtime and its loader when a scene has a TimelinePlayer, the content has an .estimeline, or a script imports the subpath, and a game with none of them ships neither. The API is unchanged and still reachable from `esengine`.-- **Terrain and Foliage are optional modules.** Terrain and Foliage are now optional modules, esengine/terrain and esengine/foliage: a package carries them when a scene has a Terrain or Foliage component or a script imports the subpath, and a game with neither ships none of them (about 33 KB less in a UI-only mini-game). The API is unchanged and still reachable from `esengine`; the export installs the module for a scene that uses either component.--## [0.94.0] - 2026-10-22-### Added-- **GPU particles.** Particle emitters can now simulate on the GPU: turn on gpuSimulation and a compute kernel advances every particle, so an emitter of a hundred thousand or a million particles costs a dispatch instead of a loop. The kernel runs the same emitter: shapes, curl noise, force fields, gravity, damping, a floor plane, colour, size and speed over life and sprite sheets, up to 2,000,000 particles. Sub-emitters, trails and physics collision stay on the CPU, the particles are not sorted, and it needs WebGPU: on WebGL2 and mini-games the same emitter runs on the CPU, capped at 20,000 particles.-- **Contact shadows and screen-space bounce light.** Contact Shadows and Screen Space GI effects add small sharp shadows at contacts and one bounce of colour between surfaces, and the weather softens the sun's shadows. `contactShadows` marches a short ray toward the scene's sun in the depth buffer; `ssgi` gathers eight rays a pixel over the G-buffer's normals at half size into a float target and averages the neighbours on the same surface before laying the light, times the receiver's colour, over the picture. The Weather component raises the sun's `sourceAngle` and lowers its `shadowStrength` as the sky clouds over.-- **Terrain and Foliage.** A Terrain component makes ground from a heightmap or noise, paints it with grass, dirt, snow and rock layers and draws it in chunks that coarsen with distance; a Foliage component scatters grass or a mesh over it, swaying in the wind and thinning out with distance.-- **Separate material maps packed on import.** Importing an FBX with separate metalness, roughness and occlusion images now packs them into the one map the Model shader samples, instead of dropping them. Occlusion goes in red, roughness in green and metal in blue, each from its image's red channel (a glossiness map is inverted); a channel with no image stays at full so the material's own value speaks. Only PNG and DDS can be read.+- **Hair maps from the model.** A hair material's strand-direction map, highlight-shift map and tip softness are now imported from the model: a glTF has no slot for them, so a material names them in its extras (flow_map, shift_map, suggested_tipSoftness) and the importer binds them to the Hair shader instead of leaving the highlight to be worked out from the surface.- **Spring-bone data in the file.** The Spring Bones import setting now reads what a model states before it looks at names: the VRM spring-bone extension (VRMC_springBone, with its stiffness and gravity converted to units the engine uses) and a node's own extras.estella.springBone and springCollider properties, which carry exact sizes from a Blender custom property. Names fill in whatever those leave out, a chain with no collider list is kept out of every collider in the model, and springs that cannot be used are reported in the import warnings.- **Spring-bone collider handles.** A selected spring-bone collider carries six square handles in the viewport: on a sphere any of them sets the radius, on a capsule the four round its middle set the radius and the two on its ends set the height. The ones on the far side of the shape are faded, the value shows beside the pointer while one is dragged, a drag is one undo step, and with Preview FX on the strands follow it live.- **Spring-bone import.** A model's new Spring Bones import setting (By Bone Name) builds hair motion from names the file already carries: a bone called Hair_<region>_<chain>_00 becomes a SpringBone with the bones below it as the strand, and an empty called SBC_Sphere_<name>_r<cm> or SBC_Capsule_<name>_r<cm>_h<cm> becomes a collider every chain is kept out of. The region sets a starting stiffness and drag, sizes follow the model's metres and the import scale, and the result is ordinary components to adjust in Details.@@ -63,6 +45,29 @@ published separately; it ships inside the editor.- **Cutout shadows for hair cards and leaves.** A material whose alpha is coverage (`u_alphaCutoff` above 0, now also on the Hair shader) casts its cut-out shape into shadow maps instead of the rectangle it is drawn on, and Hair cards feather their edges with alpha-to-coverage.- **Eye lid shadow.** The Eye shader shades the eye the lids sit on: `u_lidMap` is an authored occlusion map, and `u_lidShadow` darkens, and fades the cornea's reflections, where the surface faces up from `u_lidStart`, which is the upper lid on an upright head.- **Eye shader.** A new Eye shader (`builtin:eye`) draws an eye from a mask and a dome normal map: the iris sits behind a refracting cornea so it moves as the eye turns, with a pupil, fibres and a limbal ring, a white lit with wrapped light, and a near-mirror cornea that shows every light as a catchlight.++### Fixed++- **Shadow program for a normal-mapped mesh with tangents.** A model with tangents and a normal map no longer stops its shadow program from linking when the sun casts shadows. The depth pass wrote no tangent varying while the fragment stage still read one, so the shader failed on WebGL2 and the logged error named no material; the depth variant now leaves the tangent frame out.+- **Selection outline across a plane.** The selection outline of a mesh no longer draws a stray line across a large plane seen from close by: a triangle with a corner behind the camera was judged by a different rule than its neighbour, so their shared diagonal showed as an edge.+- **Normal maps read against the frame they were baked in.** Imported meshes now carry a tangent at each vertex (a glTF's own direction, or one made from the UVs), and normal maps on them are read against that frame instead of one derived per pixel, which was wrong at UV seams and on stretched textures. Re-import a model to get them; one imported before keeps its old shading. A mesh whose vertices carry a tangent is drawn with an extra vertex attribute and one more varying; a shader of your own that calls `perturbNormal` picks the frame up with no change.+- **New Project keeps the wrong template name.** The New Project page no longer keeps the previous template's name when you pick another: the suggested name follows the template, and a name you typed stays.++### Changed++- **A lite engine for mini-games.** A WeChat or Douyin package whose scenes and scripts use no particle emitter, post-process volume or tilemap now ships a lite engine, the same engine without those three subsystems and about 200 KB smaller, so a UI-only game has room under the 4 MB main-package limit. It is chosen from the same evidence as the lean SDK entry plus a scan of the project's scripts; any mention of one of the three carries the full engine. Build it with `node build-tools/cli.js build -t wechat-lite` (`-t all` includes it).+- **Post-process effects are optional groups.** The post-process effects' shaders are now three optional groups, esengine/fx-basic, esengine/fx-atmosphere and esengine/fx-lighting: a package carries a group when a PostProcessVolume names one of its effects (or a Weather or TimeOfDay component is in the content), and a game with no volumes ships none of them (about 180 KB less in a UI-only mini-game). An effect a script adds by code needs its group imported (`esengine/fx-basic` and the others) or the module set to Include; the editor and a non-lean entry carry all three.+- **Timelines are an optional module.** Timelines are now an optional module, esengine/timeline: a package carries the timeline runtime and its loader when a scene has a TimelinePlayer, the content has an .estimeline, or a script imports the subpath, and a game with none of them ships neither. The API is unchanged and still reachable from `esengine`.+- **Terrain and Foliage are optional modules.** Terrain and Foliage are now optional modules, esengine/terrain and esengine/foliage: a package carries them when a scene has a Terrain or Foliage component or a script imports the subpath, and a game with neither ships none of them (about 33 KB less in a UI-only mini-game). The API is unchanged and still reachable from `esengine`; the export installs the module for a scene that uses either component.++## [0.94.0] - 2026-10-22++### Added++- **GPU particles.** Particle emitters can now simulate on the GPU: turn on gpuSimulation and a compute kernel advances every particle, so an emitter of a hundred thousand or a million particles costs a dispatch instead of a loop. The kernel runs the same emitter: shapes, curl noise, force fields, gravity, damping, a floor plane, colour, size and speed over life and sprite sheets, up to 2,000,000 particles. Sub-emitters, trails and physics collision stay on the CPU, the particles are not sorted, and it needs WebGPU: on WebGL2 and mini-games the same emitter runs on the CPU, capped at 20,000 particles.+- **Contact shadows and screen-space bounce light.** Contact Shadows and Screen Space GI effects add small sharp shadows at contacts and one bounce of colour between surfaces, and the weather softens the sun's shadows. `contactShadows` marches a short ray toward the scene's sun in the depth buffer; `ssgi` gathers eight rays a pixel over the G-buffer's normals at half size into a float target and averages the neighbours on the same surface before laying the light, times the receiver's colour, over the picture. The Weather component raises the sun's `sourceAngle` and lowers its `shadowStrength` as the sky clouds over.+- **Terrain and Foliage.** A Terrain component makes ground from a heightmap or noise, paints it with grass, dirt, snow and rock layers and draws it in chunks that coarsen with distance; a Foliage component scatters grass or a mesh over it, swaying in the wind and thinning out with distance.+- **Separate material maps packed on import.** Importing an FBX with separate metalness, roughness and occlusion images now packs them into the one map the Model shader samples, instead of dropping them. Occlusion goes in red, roughness in green and metal in blue, each from its image's red channel (a glossiness map is inverted); a channel with no image stays at full so the material's own value speaks. Only PNG and DDS can be read.- **Skin and hair.** Two new shaders for characters: Skin softens diffuse light by colour, warms the terminator and lets light through thin places without blurring the picture, and Hair lights strands along a flow map with two shifted highlights. Normal maps on stretched UVs (a face unwrapped into an atlas) now keep their shape, and mipmapped textures are sampled with anisotropic filtering where the device has it. Both read a normal map and an occlusion/roughness map as data textures (import them with sRGB off); the Skin shader shades each pixel with three lighting passes, so it is for characters in view. Hair is shaded as strands but a hair model is still cards or ribbons.- **Anisotropic filtering.** Mipmapped textures are now sampled with up to 16x anisotropic filtering where the device has it (WebGL2 with the extension, WebGPU always), so a floor, a hair card or a sleeve seen at a slant keeps its detail instead of washing out to grey.- **Wilds example.** Wilds is a new 3D example: a lake under mountains at dusk, made from a generated heightmap with the Terrain, Water and Foliage features and the sky's cloud shadows. Everything in it is made from numbers by `examples/wilds/tools/build.mjs`, so there is no art to credit.diff --git a/src/esengine/renderer/plugins/MeshPlugin.cpp b/src/esengine/renderer/plugins/MeshPlugin.cppindex 15a6d3aa1..dcd669a21 100644--- a/src/esengine/renderer/plugins/MeshPlugin.cpp+++ b/src/esengine/renderer/plugins/MeshPlugin.cpp@@ -397,7 +397,8 @@ u32 MeshPlugin::meshProgram(RenderFrameContext& ctx, u32 variant) {if (normalMapped) features.emplace_back("NORMAL_MAP");if (skinned) features.emplace_back("SKINNED");if (lightmapped) features.emplace_back("MESH_LIGHTMAP");- if (tangents && normals) features.emplace_back("MESH_TANGENTS");+ // Not in a depth pass: its vertex stage writes no tangent varying, and a fragment that declares one fails to link.+ if (tangents && normals && !depthOnly) features.emplace_back("MESH_TANGENTS");if (weightHeat) features.emplace_back("WEIGHT_HEAT");if (depthOnly) features.emplace_back("SHADOW_DEPTH");if (motion) features.emplace_back("ES_VELOCITY");diff --git a/src/esengine/renderer/store/MaterialStore.cpp b/src/esengine/renderer/store/MaterialStore.cppindex 094f1afdb..9599ef455 100644--- a/src/esengine/renderer/store/MaterialStore.cpp+++ b/src/esengine/renderer/store/MaterialStore.cpp@@ -139,7 +139,8 @@ u32 MaterialStore::shadowProgram(u32 materialId, resource::ResourceManager& resostd::vector<std::string> features;if (withNormals) features.emplace_back("MESH_NORMALS");- if (tangents && withNormals) features.emplace_back("MESH_TANGENTS");+ // A depth pass has no use for a tangent frame, and the vertex stage of SHADOW_DEPTH does not write the varying the fragment prelude would then read.+ // The variant is still keyed by `tangents` so a mesh with and without them keeps its own program.if (skinned) features.emplace_back("SKINNED");features.emplace_back("SHADOW_DEPTH");if (hooked) features.emplace_back("ES_MATERIAL_VERTEX");diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex dc759fa78..ec29ae95d 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -37,6 +37,11 @@ export const NOTED = {'fix: restore gizmo hover CI and optimize 3d multi-selection': { note: 'Faster 3D multi-selection.' },'feat: add shared web runtime support for LAN device preview': { note: 'One-click LAN device preview.' },'feat(editor): add quick QR device preview beside Play': { note: 'One-click LAN device preview.' },+ 'feat(pipeline): a hair material\'s flow map, shift map and tip softness are read from the model\'s material extras':+ {"note":"A hair material's strand-direction map, highlight-shift map and tip softness are now imported from the model: a glTF has no slot for them, so a material names them in its extras (flow_map, shift_map, suggested_tipSoftness) and the importer binds them to the Hair shader instead of leaving the highlight to be worked out from the surface."},+ 'fix(render): a mesh with tangents and a normal map links its shadow program when the sun casts shadows':+ {"note":"A model with tangents and a normal map no longer stops its shadow program from linking when the sun casts shadows. The depth pass wrote no tangent varying while the fragment stage still read one, so the shader failed on WebGL2 and the logged error named no material; the depth variant now leaves the tangent frame out."},+ 'fix(editor): the spring-bone note uses the inset token, and a model import passes the Spring Bones setting through': { internal: 'A theme token for a line of Details and the import setting passed through to the importer, both inside the spring-bone work that has its own notes.' },'fix: serialize binaryen optimization on windows': { internal: 'Uses one optimizer worker after wider builds reproduced heap corruption with four; release optimization flags stay unchanged.' },'feat: add budgeted 2d and 3d particle scene collisions': { note: 'Budgeted particle scene collisions.' },'feat(editor): add particle collision authoring and diagnostics': { note: 'Budgeted particle scene collisions.' },