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
feat(environment): one number turns the sky, the irradiance and the reflection
esengine2c245f1641c9
diff --git a/fixtures/scenes/azimuth.esenv b/fixtures/scenes/azimuth.esenvnew file mode 100644index 000000000..5b9dc32ba--- /dev/null+++ b/fixtures/scenes/azimuth.esenv@@ -0,0 +1,36 @@+{+ "version": 1,+ "irradiance": [+ 2.154755115509033,+ 0.13225169479846954,+ 0.13225169479846954,+ -8.497218573211285e-7,+ -4.585568813553209e-9,+ -4.585568813553209e-9,+ -1.51440626705579e-9,+ 1.4102564949158847e-10,+ 1.4102564949158847e-10,+ -1.2033172845840454,+ -0.035615939646959305,+ -0.035615939646959305,+ 9.179405680015407e-9,+ 9.72157132572704e-10,+ 9.72157132572704e-10,+ -2.0345339302174636e-10,+ 1.255159517987714e-11,+ 1.255159517987714e-11,+ -0.000242426001932472,+ -0.000014881657079968136,+ -0.000014881657079968136,+ -3.17149140283135e-10,+ 2.2406053401535786e-10,+ 2.2406053401535786e-10,+ -0.00041976390639320016,+ -0.000025765943064470775,+ -0.000025765943064470775+ ],+ "specular": "azimuth_env.png",+ "faceSize": 64,+ "mipCount": 4,+ "maxRange": 8+}diff --git a/fixtures/scenes/azimuth.esenv.meta b/fixtures/scenes/azimuth.esenv.metanew file mode 100644index 000000000..6f963ca5f--- /dev/null+++ b/fixtures/scenes/azimuth.esenv.meta@@ -0,0 +1,6 @@+{+ "uuid": "6570d38c-dfd8-4e4e-9e3e-89533ad44932",+ "version": "2.0",+ "type": "environment",+ "importer": {}+}diff --git a/fixtures/scenes/azimuth.hdr b/fixtures/scenes/azimuth.hdrnew file mode 100644index 000000000..55c43bc7d--- /dev/null+++ b/fixtures/scenes/azimuth.hdr@@ -0,0 +1,5 @@+#?RADIANCE+FORMAT=32-bit_rle_rgbe++-Y 32 +X 64+�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{�������������������������������������������������������������������{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{���{\ No newline at end of filediff --git a/fixtures/scenes/azimuth_env.png b/fixtures/scenes/azimuth_env.pngnew file mode 100644index 000000000..f76a27005Binary files /dev/null and b/fixtures/scenes/azimuth_env.png differdiff --git a/fixtures/scenes/azimuth_env.png.meta b/fixtures/scenes/azimuth_env.png.metanew file mode 100644index 000000000..8565c3450--- /dev/null+++ b/fixtures/scenes/azimuth_env.png.meta@@ -0,0 +1,19 @@+{+ "uuid": "32c38a60-b1ab-422d-8682-e85608ad152a",+ "version": "2.0",+ "type": "texture",+ "importer": {+ "maxSize": 2048,+ "compress": false,+ "compressFormat": "uastc",+ "filterMode": "linear",+ "wrapMode": "clamp",+ "sRGB": false,+ "sliceBorder": {+ "left": 0,+ "right": 0,+ "top": 0,+ "bottom": 0+ }+ }+}diff --git a/fixtures/scenes/diffuse-azimuth.esscene b/fixtures/scenes/diffuse-azimuth.esscenenew file mode 100644index 000000000..c5c6898b3--- /dev/null+++ b/fixtures/scenes/diffuse-azimuth.esscene@@ -0,0 +1,145 @@+{+ "version": 4,+ "name": "DiffuseAzimuth",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 10+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 1,+ "orthoSize": 300,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Sky",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 2,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1,+ "environment": "/scenes/azimuth.esenv"+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "Mirror",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": -150,+ "y": 0,+ "z": 0+ },+ "scale": {+ "x": 200,+ "y": 200,+ "z": 1+ }+ }+ },+ {+ "type": "MeshRenderer",+ "data": {+ "mesh": "/scenes/shadow-quad.esmesh",+ "material": "/scenes/mat-env/dielectric.esmaterial",+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "lit": true,+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 3,+ "name": "Rough",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 150,+ "y": 0,+ "z": 0+ },+ "scale": {+ "x": 200,+ "y": 200,+ "z": 1+ }+ }+ },+ {+ "type": "MeshRenderer",+ "data": {+ "mesh": "/scenes/shadow-quad.esmesh",+ "material": "/scenes/mat-env/dielectric.esmaterial",+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "lit": true,+ "enabled": true+ }+ }+ ]+ }+ ]+}\ No newline at end of filediff --git a/fixtures/scenes/diffuse-azimuth.esscene.meta b/fixtures/scenes/diffuse-azimuth.esscene.metanew file mode 100644index 000000000..baaf7b471--- /dev/null+++ b/fixtures/scenes/diffuse-azimuth.esscene.meta@@ -0,0 +1,4 @@+{+ "uuid": "30eb7c7d-bb65-4917-9fe7-e36b78b0f706",+ "type": "scene"+}\ No newline at end of filediff --git a/fixtures/scenes/mat-env/dielectric.esmaterial b/fixtures/scenes/mat-env/dielectric.esmaterialnew file mode 100644index 000000000..6eb62a47a--- /dev/null+++ b/fixtures/scenes/mat-env/dielectric.esmaterial@@ -0,0 +1,11 @@+{+ "version": "1.0",+ "type": "material",+ "shader": "builtin:model",+ "blendMode": 0,+ "depthTest": false,+ "properties": {+ "u_metallic": 0,+ "u_roughness": 1+ }+}diff --git a/fixtures/scenes/sky-azimuth.esscene b/fixtures/scenes/sky-azimuth.esscenenew file mode 100644index 000000000..131f35d11--- /dev/null+++ b/fixtures/scenes/sky-azimuth.esscene@@ -0,0 +1,70 @@+{+ "version": 4,+ "name": "SkyAzimuth",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 0,+ "fov": 90,+ "nearPlane": 1,+ "farPlane": 1000,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Sky",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 2,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1,+ "environment": "/scenes/azimuth.esenv",+ "drawEnvironment": true+ }+ }+ ]+ }+ ]+}\ No newline at end of filediff --git a/fixtures/scenes/sky-azimuth.esscene.meta b/fixtures/scenes/sky-azimuth.esscene.metanew file mode 100644index 000000000..9e7c0d404--- /dev/null+++ b/fixtures/scenes/sky-azimuth.esscene.meta@@ -0,0 +1,4 @@+{+ "uuid": "b2641d3e-ac9d-4d22-93e4-9d07f25e460b",+ "type": "scene"+}\ No newline at end of filediff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 88f1e56cc..2c259dc45 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 113 public · 92 beta · 1663 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"7756afcaec734824"+"840383cc170f0e8f"```## ANCHOR_AXES — const @experimental@@ -4438,6 +4438,7 @@ color: ColordrawEnvironment: booleanenabled: booleanenvironment: number+environmentRotation: numberinnerAngle: numberintensity: numbermeshShadows: booleandiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 1ececcb03..ccacd9497 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 113 public · 97 beta · 1682 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"7756afcaec734824"+"840383cc170f0e8f"```## ANCHOR_AXES — const @experimental@@ -4446,6 +4446,7 @@ color: ColordrawEnvironment: booleanenabled: booleanenvironment: number+environmentRotation: numberinnerAngle: numberintensity: numbermeshShadows: booleandiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex a87c96175..be7190b0f 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -4433,6 +4433,7 @@ color: ColordrawEnvironment: booleanenabled: booleanenvironment: number+environmentRotation: numberinnerAngle: numberintensity: numbermeshShadows: booleandiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 9c7bc1231..e1bf647dc 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -4433,6 +4433,7 @@ color: ColordrawEnvironment: booleanenabled: booleanenvironment: number+environmentRotation: numberinnerAngle: numberintensity: numbermeshShadows: booleandiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex b46f612e5..18219ca17 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -4440,6 +4440,7 @@ color: ColordrawEnvironment: booleanenabled: booleanenvironment: number+environmentRotation: numberinnerAngle: numberintensity: numbermeshShadows: booleandiff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex f98e251ac..d8959eaa5 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -810,6 +810,7 @@ export interface LightPtrData {meshShadows: boolean;shadowExtent: number;environment: number;+ environmentRotation: number;drawEnvironment: boolean;enabled: boolean;}@@ -830,8 +831,9 @@ export function fillLight(out.meshShadows = u8[ptr + 48] !== 0;out.shadowExtent = f32[(ptr + 52) >> 2];out.environment = u32[(ptr + 56) >> 2];- out.drawEnvironment = u8[ptr + 60] !== 0;- out.enabled = u8[ptr + 61] !== 0;+ out.environmentRotation = f32[(ptr + 60) >> 2];+ out.drawEnvironment = u8[ptr + 64] !== 0;+ out.enabled = u8[ptr + 65] !== 0;}export function writeLight(@@ -850,8 +852,9 @@ export function writeLight(u8[ptr + 48] = data.meshShadows ? 1 : 0;f32[(ptr + 52) >> 2] = data.shadowExtent;u32[(ptr + 56) >> 2] = data.environment;- u8[ptr + 60] = data.drawEnvironment ? 1 : 0;- u8[ptr + 61] = data.enabled ? 1 : 0;+ f32[(ptr + 60) >> 2] = data.environmentRotation;+ u8[ptr + 64] = data.drawEnvironment ? 1 : 0;+ u8[ptr + 65] = data.enabled ? 1 : 0;}export function createLightData(): LightPtrData {@@ -868,6 +871,7 @@ export function createLightData(): LightPtrData {meshShadows: false,shadowExtent: 0,environment: 0,+ environmentRotation: 0,drawEnvironment: false,enabled: false,};diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex 0894b0168..557cdda9a 100644--- a/sdk/src/ecs/component.generated.ts+++ b/sdk/src/ecs/component.generated.ts@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, Cl* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = '7756afcaec734824';+export const ABI_LAYOUT_HASH = '840383cc170f0e8f';/*** One asset-valued field of a component: which field, and what kind of@@ -456,6 +456,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {meshShadows: false,shadowExtent: 0,environment: 0,+ environmentRotation: 0,drawEnvironment: false,enabled: true,},@@ -476,6 +477,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {meshShadows: { tooltip: "Cast a shadow map over 3D meshes (Directional, Spot, Point).", shownWhen: { field: "type", values: [0, 1, 3] } },shadowExtent: { min: 0, tooltip: "Shadow map coverage radius; 0 = fit the view.", advanced: true, shownWhen: { field: "type", values: [1] } },environment: { tooltip: "Baked environment (.esenv) this Ambient light casts.", shownWhen: { field: "type", values: [2] } },+ environmentRotation: { unit: "deg", tooltip: "Turn the environment about the up axis, in degrees.", shownWhen: { field: "type", values: [2] } },drawEnvironment: { tooltip: "Draw this environment as the sky behind the scene.", shownWhen: { field: "type", values: [2] } },},},@@ -1298,6 +1300,7 @@ export interface LightData {meshShadows: boolean;shadowExtent: number;environment: number;+ environmentRotation: number;drawEnvironment: boolean;enabled: boolean;}diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex 50d9e09f0..7c461f251 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -239,8 +239,9 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'meshShadows', type: 'bool', offset: 48 },{ name: 'shadowExtent', type: 'f32', offset: 52 },{ name: 'environment', type: 'u32', offset: 56 },- { name: 'drawEnvironment', type: 'bool', offset: 60 },- { name: 'enabled', type: 'bool', offset: 61 },+ { name: 'environmentRotation', type: 'f32', offset: 60 },+ { name: 'drawEnvironment', type: 'bool', offset: 64 },+ { name: 'enabled', type: 'bool', offset: 65 },],},MeshCollider3D: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex f549c58b4..719d095d0 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -542,6 +542,7 @@ export interface Light {meshShadows: boolean;shadowExtent: number;environment: number;+ environmentRotation: number;drawEnvironment: boolean;enabled: boolean;}diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex cc316121b..fd4bf0a87 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -2,10 +2,10 @@* @file EditorAPI.generated.cpp* @brief Auto-generated editor API with string-dispatched component access* @details Generated by EHT - DO NOT EDIT- * @schema_hash 723eabb232b5334a+ * @schema_hash b6a802e71e3a8026*/-#define ES_EDITOR_API_SCHEMA_HASH "723eabb232b5334a"+#define ES_EDITOR_API_SCHEMA_HASH "b6a802e71e3a8026"#include <emscripten/bind.h>#include <string>@@ -333,6 +333,7 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"meshShadows","type":"bool","group":"Light"},{"key":"shadowExtent","type":"float","group":"Light"},{"key":"environment","type":"asset","group":"Light"},+ {"key":"environmentRotation","type":"float","group":"Light"},{"key":"drawEnvironment","type":"bool","group":"Light"},{"key":"enabled","type":"bool","group":"Light"}])JSON";@@ -1217,6 +1218,7 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::selse if (field == "sourceAngle") { c.sourceAngle = value; }else if (field == "shadowDistance") { c.shadowDistance = value; }else if (field == "shadowExtent") { c.shadowExtent = value; }+ else if (field == "environmentRotation") { c.environmentRotation = value; }else { return false; }return true;} else if (comp == "MeshCollider3D") {@@ -1691,6 +1693,7 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "sourceAngle") { return c.sourceAngle; }else if (field == "shadowDistance") { return c.shadowDistance; }else if (field == "shadowExtent") { return c.shadowExtent; }+ else if (field == "environmentRotation") { return c.environmentRotation; }} else if (comp == "MeshCollider3D") {if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return 0.0f;const auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 90de3d552..af1650b80 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -581,6 +581,7 @@ struct LightJS {bool meshShadows;f32 shadowExtent;u32 environment;+ f32 environmentRotation;bool drawEnvironment;bool enabled;};@@ -598,6 +599,7 @@ void lightApplyJS(esengine::ecs::Light& c, const LightJS& js) {c.meshShadows = js.meshShadows;c.shadowExtent = js.shadowExtent;c.environment = resource::EnvironmentHandle(js.environment);+ c.environmentRotation = js.environmentRotation;c.drawEnvironment = js.drawEnvironment;c.enabled = js.enabled;}@@ -622,6 +624,7 @@ LightJS lightToJS(const esengine::ecs::Light& c) {js.meshShadows = c.meshShadows;js.shadowExtent = c.shadowExtent;js.environment = c.environment.id();+ js.environmentRotation = c.environmentRotation;js.drawEnvironment = c.drawEnvironment;js.enabled = c.enabled;return js;@@ -1564,6 +1567,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("meshShadows", &LightJS::meshShadows).field("shadowExtent", &LightJS::shadowExtent).field("environment", &LightJS::environment)+ .field("environmentRotation", &LightJS::environmentRotation).field("drawEnvironment", &LightJS::drawEnvironment).field("enabled", &LightJS::enabled);@@ -2974,8 +2978,9 @@ static_assert(offsetof(esengine::ecs::Light, shadowDistance) == 44, "ABI offsetstatic_assert(offsetof(esengine::ecs::Light, meshShadows) == 48, "ABI offset drift: esengine::ecs::Light.meshShadows (EHT expected 48)");static_assert(offsetof(esengine::ecs::Light, shadowExtent) == 52, "ABI offset drift: esengine::ecs::Light.shadowExtent (EHT expected 52)");static_assert(offsetof(esengine::ecs::Light, environment) == 56, "ABI offset drift: esengine::ecs::Light.environment (EHT expected 56)");-static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 60, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 60)");-static_assert(offsetof(esengine::ecs::Light, enabled) == 61, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 61)");+static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 60, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 60)");+static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 64, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 64)");+static_assert(offsetof(esengine::ecs::Light, enabled) == 65, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 65)");static_assert(offsetof(esengine::ecs::MeshCollider3D, mesh) == 0, "ABI offset drift: esengine::ecs::MeshCollider3D.mesh (EHT expected 0)");static_assert(offsetof(esengine::ecs::MeshCollider3D, friction) == 4, "ABI offset drift: esengine::ecs::MeshCollider3D.friction (EHT expected 4)");static_assert(offsetof(esengine::ecs::MeshCollider3D, restitution) == 8, "ABI offset drift: esengine::ecs::MeshCollider3D.restitution (EHT expected 8)");@@ -3208,7 +3213,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "7756afcaec734824";+static const char* kEsAbiLayoutHash = "840383cc170f0e8f";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hppindex f870b41de..057499333 100644--- a/src/esengine/ecs/components/Light.hpp+++ b/src/esengine/ecs/components/Light.hpp@@ -128,6 +128,14 @@ struct Light {tooltip="Baked environment (.esenv) this Ambient light casts.")resource::EnvironmentHandle environment;+ /** @brief Turn the environment about +Y, in degrees. One number turns all three+ * of it — sky, diffuse irradiance and specular reflection — because+ * moving a reflection to the other side of a model means all three or+ * none. Here rather than in the `.esenv` so one bake is reusable. */+ ES_PROPERTY(unit=deg, shown_when=type:Ambient,+ tooltip="Turn the environment about the up axis, in degrees.")+ f32 environmentRotation{0.0f};+/** @brief Draw @ref environment as the background as well as reflecting it. Off by* default, so a scene that adopts an environment for its lighting does not* also acquire a sky it did not ask for. Ignored without one — and thediff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex 95439d588..7768edfbc 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -1082,7 +1082,8 @@ bool RenderFrame::collectEnvironment(const ecs::Light& light, const glm::vec3& sconst glm::vec4 params{textureId != 0 ? 1.0f : 0.0f, environment->maxRange,static_cast<f32>(environment->mipCount) - 1.0f,environment->faceSize};- if (!context_.lights().setEnvironment(environment->irradiance.data(), params, scale)) {+ if (!context_.lights().setEnvironment(environment->irradiance.data(), params, scale,+ glm::radians(light.environmentRotation))) {return false;}environment_texture_id_ = textureId;diff --git a/src/esengine/renderer/store/LightStore.hpp b/src/esengine/renderer/store/LightStore.hppindex db3556669..95b6f3f97 100644--- a/src/esengine/renderer/store/LightStore.hpp+++ b/src/esengine/renderer/store/LightStore.hpp@@ -94,16 +94,16 @@ public:dirty_ = true;}- /// Sets the frame's environment: nine irradiance coefficients, the reflection- /// params, and the tint scaling both. The FIRST ambient light carrying one wins —- /// several environments do not sum the way flat terms do.+ /// The frame's environment. The FIRST ambient light carrying one wins — several+ /// do not sum the way flat terms do. `yaw` turns it about +Y in RADIANS and rides+ /// in the tint's alpha, which std140 pads into existence whether it is used or not./// @return false when one was already set this frame.bool setEnvironment(const glm::vec3* irradiance, const glm::vec4& params,- const glm::vec3& tint) {+ const glm::vec3& tint, f32 yaw) {if (hasEnvironment_) return false;for (usize i = 0; i < 9; ++i) data_.envIrradiance[i] = glm::vec4(irradiance[i], 0.0f);data_.envParams = params;- data_.envTint = glm::vec4(tint, 0.0f);+ data_.envTint = glm::vec4(tint, yaw);hasEnvironment_ = true;dirty_ = true;return true;diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 3674a066f..2406d28a3 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -1074,7 +1074,17 @@ fn envBRDFApprox(NdotV : f32, roughness : f32) -> vec2f {let a = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y;return vec2f(-1.04, 1.04) * a + r.zw;}-fn envIrradiance(N : vec3f) -> vec3f {+// One authority for the environment's orientation: every direction that asks the+// environment anything comes through here, so a turned sky cannot disagree with a+// turned reflection. The query turns the other way, the world under it.+fn envDirection(d : vec3f) -> vec3f {+ let a = -lc.u_envTint.a;+ let s = sin(a);+ let c = cos(a);+ return vec3f(c * d.x + s * d.z, d.y, -s * d.x + c * d.z);+}+fn envIrradiance(Nw : vec3f) -> vec3f {+ let N = envDirection(Nw);let sh = lc.u_envIrradiance[0].rgb * 0.282095+ lc.u_envIrradiance[1].rgb * (0.488603 * N.y)+ lc.u_envIrradiance[2].rgb * (0.488603 * N.z)@@ -1104,7 +1114,7 @@ fn envSampleMip(R : vec3f, mip : f32) -> vec3f {let atlasW = face + 2.0;let atlasH = 2.0 * face * (1.0 - exp2(-(lc.u_envParams.z + 1.0)))+ 2.0 * (lc.u_envParams.z + 1.0);- let uv = octEncode(R);+ let uv = octEncode(envDirection(R));let px = vec2f(1.0 + uv.x * size, yOff + 1.0 + uv.y * size);let t = textureSampleLevel(t3, s3, px / vec2f(atlasW, atlasH), 0.0);return t.rgb * t.rgb * (t.a * t.a * lc.u_envParams.y);@@ -1799,10 +1809,18 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp float a = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y;\n"" return vec2(-1.04, 1.04) * a + r.zw;\n""}\n"+ // The WGSL twin's envDirection, for the same reason.+ "highp vec3 envDirection(in highp vec3 d) {\n"+ " highp float a = -u_envTint.a;\n"+ " highp float s = sin(a);\n"+ " highp float c = cos(a);\n"+ " return vec3(c * d.x + s * d.z, d.y, -s * d.x + c * d.z);\n"+ "}\n"// The environment's diffuse half. With no environment the coefficients are// zero and this IS the flat ambient term, which is what keeps every existing// scene pixel-identical rather than merely close.- "highp vec3 envIrradiance(in highp vec3 N) {\n"+ "highp vec3 envIrradiance(in highp vec3 Nw) {\n"+ " highp vec3 N = envDirection(Nw);\n"" highp vec3 sh = u_envIrradiance[0].rgb * 0.282095\n"" + u_envIrradiance[1].rgb * (0.488603 * N.y)\n"" + u_envIrradiance[2].rgb * (0.488603 * N.z)\n"@@ -1836,7 +1854,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp float atlasW = face + 2.0;\n"" highp float atlasH = 2.0 * face * (1.0 - exp2(-(u_envParams.z + 1.0)))\n"" + 2.0 * (u_envParams.z + 1.0);\n"- " highp vec2 uv = octEncode(R);\n"+ " highp vec2 uv = octEncode(envDirection(R));\n"" highp vec2 px = vec2(1.0 + uv.x * size, yOff + 1.0 + uv.y * size);\n"" highp vec4 t = texture(u_envMap, px / vec2(atlasW, atlasH));\n"" return t.rgb * t.rgb * (t.a * t.a * u_envParams.y);\n"diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex 3e96e6487..a97bfc1b6 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -234,7 +234,13 @@ export const SCENES = [// surface reflects +Z, which is the image centre — green there, and the whole// sphere averaged at the rough end. One flat term would draw them alike.{ id: "mat-env-mirror", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-env-mirror.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,228,0],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[29,23,24],\"tol\":20},{\"x\":0.5,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },- // A glTF animation, through the shipped importer. The scene puts the quad at+ // Sky and DIELECTRIC apart: they read the atlas and the irradiance coefficients+ // through different code, and one turning without the other is the defect. The+ // fixture is half bright — a symmetric sky reads the same at every angle.+ { id: "sky-azimuth", tier: "pr", webgpu: false, env: { ESTELLA_VERIFY_SCENE: "/scenes/sky-azimuth.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.1,\"y\":0.5,\"rgb\":[255,14,14],\"tol\":24},{\"x\":0.5,\"y\":0.5,\"rgb\":[145,9,9],\"tol\":24},{\"x\":0.9,\"y\":0.5,\"rgb\":[5,5,5],\"tol\":18}]" } },+ { id: "sky-azimuth-turned", tier: "pr", webgpu: false, env: { ESTELLA_VERIFY_SCENE: "/scenes/sky-azimuth.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Light\",\"key\":\"environmentRotation\",\"value\":-20}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.1,\"y\":0.5,\"rgb\":[255,14,14],\"tol\":24},{\"x\":0.5,\"y\":0.5,\"rgb\":[255,14,14],\"tol\":24},{\"x\":0.9,\"y\":0.5,\"rgb\":[5,5,5],\"tol\":18}]" } },+ { id: "diffuse-azimuth", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/diffuse-azimuth.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[157,10,10],\"tol\":24},{\"x\":0.75,\"y\":0.5,\"rgb\":[157,10,10],\"tol\":24}]" } },+ { id: "diffuse-azimuth-turned", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/diffuse-azimuth.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Light\",\"key\":\"environmentRotation\",\"value\":90}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[255,14,14],\"tol\":24},{\"x\":0.75,\"y\":0.5,\"rgb\":[255,14,14],\"tol\":24}]" } }, // A glTF animation, through the shipped importer. The scene puts the quad at// x=150 and the clip runs -120 to 120 over a second, so 30 fixed steps is its// midpoint: the model is at the origin and where the SCENE put it is empty.{ id: "model-animation", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_SCENE: "/scenes/model-animation.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "30", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.875,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20},{\"x\":0.2,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },