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.

feat(render): an ambient light's diffuse has its own scale and tint - Diffuse Scale and Diffuse Tint multiply the light an environment gives surfaces and leave what they reflect of it and the sky drawn behind them alone, as Unreal's Sky Light keeps Intensity apart from its Indirect Lighting and Specular scales: a sky whose irradiance is too dark or too blue for a look is lifted without brightening every reflection

yhh2f9e84cb6b45
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0bd81874..5186268c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ published separately; it ships inside the editor.
### Added
+- **An ambient light's diffuse has its own scale and tint.** `diffuseScale` and `diffuseTint` on an Ambient light multiply the light its environment gives surfaces, and leave the reflections and the sky drawn behind them as they were: a sky whose irradiance is too dark or too blue for a look is lifted without brightening every reflection. At 1 and white (the defaults) nothing changes.
- **Things that break.** A model can end with a `fracture` step, `{ op: "fracture", pieces: 12, at, focus }`, which cuts it beforehand into pieces that fit together with no gap, each a closed solid whose cut faces are tagged apart from its skin, smaller round `at` where it will be struck. It is still drawn whole; the editor also writes a mesh for each piece and a prefab of them, each with a dynamic body and a convex hull, and the reply hands over a `Breakable` to put beside the MeshRenderer. Raising `Breakable.broken` hides the whole (its renderer, body and colliders are switched off, not removed), puts the pieces where it stood and throws them out from `origin` at `burst` world units a second; `lifetime` takes them away later, and lowering the flag makes it whole again. Its pieces are loaded while it stands whole, so they appear on the frame it breaks. In the editor a clay pot written by `model_write` and placed on a floor broke into the 12 pieces asked for, then the 5 asked for after an edit, each of which moved, spread apart and came to rest on the floor, and was whole again when the flag was lowered. Nothing breaks it of itself yet: a script, a graph or a collision handler raises the flag. `Physics3D.setLinearVelocity(entity, velocity)` is what throws the pieces and is there for anything else that sends a body off. `Prefabs.prepare(path)` loads a prefab and everything its entities use and holds it, so a later `instantiate` does not wait on files.
- **A thing breaks when it is hit hard enough.** `Breakable.breakImpulse` breaks it on a contact at least that hard, the speed at which the two came together times the mass they met with, and the pieces leave from where it was hit. It needs a collider of its own, which the editor's reply to a fractured model now hands over as `hull` (a `ConvexCollider3D` of its shape); with a dynamic body as well it can be knocked over and break where it lands. Every `Physics3DEvents.contactEnters` entry now carries `speed` (how fast the first body was closing on the second along the normal, read before the solver answered), `mass` (the kilograms they met with, 1 / (1/a + 1/b), a body that does not move counting as none) and `impulse`, their product, from both the Jolt and PhysX worlds. A sphere of 0.5 m dropped 1.5 m onto a pad reported 5.56 m/s from Jolt and 5.40 from PhysX against the 5.42 the fall gives, and met it with 523.60 kg, its own mass, from both. In the editor a 2 kg stone dropped six metres onto a pot broke it from its rim and took its collider away, and a 50 g pebble dropped from as high onto another left it whole. Native builds carry the new buffers but were only compiled on Windows, not run.
- **A 3D body has a mass of its own.** `RigidBody3D.mass` sets a moving body's mass in kilograms, its inertia scaled with it; 0, the default, keeps the mass its shape gives at the density of water, so scenes made before it weigh what they did. It reaches a body already in play when it changes. Both worlds were given 2 kg and answered 2, and refused a mass that is not a positive number.
diff --git a/docs/astro/src/content/docs/graphics/lighting.mdx b/docs/astro/src/content/docs/graphics/lighting.mdx
index 7534483d9..05d8f0249 100644
--- a/docs/astro/src/content/docs/graphics/lighting.mdx
+++ b/docs/astro/src/content/docs/graphics/lighting.mdx
@@ -69,6 +69,8 @@ const addSun = defineSystem([Commands()], (cmds) => {
| `drawEnvironment` | `false` | Ambient only: also draw the environment as the sky behind the scene. |
| `reflectionScale` | `1` | Ambient only: scale what baked reflection probes show (`1` = as baked). |
| `reflectionSaturation` | `1` | Ambient only: how much colour baked reflection probes keep (`0` = grey). |
+| `diffuseScale` | `1` | Ambient only: scale the light the environment gives surfaces, not what they reflect of it or the sky drawn behind them (`1` = as the sky gives it). |
+| `diffuseTint` | `{1,1,1,1}` | Ambient only: tint the light the environment gives surfaces, not what they reflect of it (white = as the sky gives it). |
| `bakedTint` | `{1,1,1,1}` | Ambient only: multiplies baked indirect light (lightmaps, probe volumes) — a day or weather scales the bake here. |
| `enabled` | `true` | Turn the light off without removing it. |
diff --git a/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx b/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx
index 85e8fba47..4a0972446 100644
--- a/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx
+++ b/docs/astro/src/content/docs/zh-cn/graphics/lighting.mdx
@@ -67,6 +67,8 @@ const addSun = defineSystem([Commands()], (cmds) => {
| `drawEnvironment` | `false` | 仅 Ambient:同时把环境画成场景背后的天空。 |
| `reflectionScale` | `1` | 仅 Ambient:缩放烘焙反射探针显示的内容(`1` = 烘焙原样)。 |
| `reflectionSaturation` | `1` | 仅 Ambient:烘焙反射探针保留多少颜色(`0` = 灰)。 |
+| `diffuseScale` | `1` | 仅 Ambient:缩放环境照到表面上的光,不影响表面映出的反射和背后画出的天空(`1` = 天空原样)。 |
+| `diffuseTint` | `{1,1,1,1}` | 仅 Ambient:给环境照到表面上的光染色,不影响表面映出的反射(白色 = 天空原样)。 |
| `bakedTint` | `{1,1,1,1}` | 仅 Ambient:乘到烘焙间接光(光照图、探针体积)上——一天或天气的变化通过它缩放烘焙。 |
| `enabled` | `true` | 不移除也能关掉光源。 |
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index a687560f5..ed6dfb807 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -3967,6 +3967,19 @@
"range": "≥ 0",
"advanced": true
},
+ {
+ "key": "diffuseScale",
+ "type": "number",
+ "default": "1",
+ "doc": "Scale the light the environment gives surfaces, not what they reflect of it (1 = as the sky gives it).",
+ "range": "≥ 0"
+ },
+ {
+ "key": "diffuseTint",
+ "type": "Color",
+ "default": "#ffffff",
+ "doc": "Tint the light the environment gives surfaces, not what they reflect of it (white = as the sky gives it)."
+ },
{
"key": "reflectionSaturation",
"type": "number",
@@ -4017,6 +4030,11 @@
"shadowSoftness",
"sourceAngle",
"shadowDistance",
+ "diffuseScale",
+ "diffuseTint.r",
+ "diffuseTint.g",
+ "diffuseTint.b",
+ "diffuseTint.a",
"groundColor.r",
"groundColor.g",
"groundColor.b",
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 85a7b50c4..4c4e8d496 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -5,7 +5,7 @@ Symbols: 115 public · 166 beta · 2190 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"08d1bbb8d5e2107c"
+"19dcbf4878f79091"
```
## ANCHOR_AXES — const @experimental
@@ -5912,6 +5912,8 @@ bakedTint: Color
color: Color
cookie: number
cookieSize: Vec2
+diffuseScale: number
+diffuseTint: Color
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index d12070210..54b754349 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -5,7 +5,7 @@ Symbols: 115 public · 171 beta · 2210 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"08d1bbb8d5e2107c"
+"19dcbf4878f79091"
```
## ANCHOR_AXES — const @experimental
@@ -5920,6 +5920,8 @@ bakedTint: Color
color: Color
cookie: number
cookieSize: Vec2
+diffuseScale: number
+diffuseTint: Color
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 61c83a5cc..13e221558 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -5907,6 +5907,8 @@ bakedTint: Color
color: Color
cookie: number
cookieSize: Vec2
+diffuseScale: number
+diffuseTint: Color
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 3445b2059..c069b0a12 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -5907,6 +5907,8 @@ bakedTint: Color
color: Color
cookie: number
cookieSize: Vec2
+diffuseScale: number
+diffuseTint: Color
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 27c4d184f..f6af70038 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -5914,6 +5914,8 @@ bakedTint: Color
color: Color
cookie: number
cookieSize: Vec2
+diffuseScale: number
+diffuseTint: Color
drawEnvironment: boolean
enabled: boolean
environment: number
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index f046a6ce5..98cb673db 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -951,6 +951,8 @@ export interface LightPtrData {
environmentRotation: number;
drawEnvironment: boolean;
reflectionScale: number;
+ diffuseScale: number;
+ diffuseTint: Color;
reflectionSaturation: number;
bakedTint: Color;
hemisphere: boolean;
@@ -987,11 +989,13 @@ export function fillLight(
out.environmentRotation = f32[(ptr + 100) >> 2];
out.drawEnvironment = u8[ptr + 104] !== 0;
out.reflectionScale = f32[(ptr + 108) >> 2];
- out.reflectionSaturation = f32[(ptr + 112) >> 2];
- const bakedTint_ = out.bakedTint; bakedTint_.r = f32[(ptr + 116) >> 2]; bakedTint_.g = f32[((ptr + 116) >> 2) + 1]; bakedTint_.b = f32[((ptr + 116) >> 2) + 2]; bakedTint_.a = f32[((ptr + 116) >> 2) + 3];
- out.hemisphere = u8[ptr + 132] !== 0;
- const groundColor_ = out.groundColor; groundColor_.r = f32[(ptr + 136) >> 2]; groundColor_.g = f32[((ptr + 136) >> 2) + 1]; groundColor_.b = f32[((ptr + 136) >> 2) + 2]; groundColor_.a = f32[((ptr + 136) >> 2) + 3];
- out.enabled = u8[ptr + 152] !== 0;
+ out.diffuseScale = f32[(ptr + 112) >> 2];
+ const diffuseTint_ = out.diffuseTint; diffuseTint_.r = f32[(ptr + 116) >> 2]; diffuseTint_.g = f32[((ptr + 116) >> 2) + 1]; diffuseTint_.b = f32[((ptr + 116) >> 2) + 2]; diffuseTint_.a = f32[((ptr + 116) >> 2) + 3];
+ out.reflectionSaturation = f32[(ptr + 132) >> 2];
+ const bakedTint_ = out.bakedTint; bakedTint_.r = f32[(ptr + 136) >> 2]; bakedTint_.g = f32[((ptr + 136) >> 2) + 1]; bakedTint_.b = f32[((ptr + 136) >> 2) + 2]; bakedTint_.a = f32[((ptr + 136) >> 2) + 3];
+ out.hemisphere = u8[ptr + 152] !== 0;
+ const groundColor_ = out.groundColor; groundColor_.r = f32[(ptr + 156) >> 2]; groundColor_.g = f32[((ptr + 156) >> 2) + 1]; groundColor_.b = f32[((ptr + 156) >> 2) + 2]; groundColor_.a = f32[((ptr + 156) >> 2) + 3];
+ out.enabled = u8[ptr + 172] !== 0;
}
export function writeLight(
@@ -1023,11 +1027,13 @@ export function writeLight(
f32[(ptr + 100) >> 2] = data.environmentRotation;
u8[ptr + 104] = data.drawEnvironment ? 1 : 0;
f32[(ptr + 108) >> 2] = data.reflectionScale;
- f32[(ptr + 112) >> 2] = data.reflectionSaturation;
- f32[(ptr + 116) >> 2] = data.bakedTint.r; f32[((ptr + 116) >> 2) + 1] = data.bakedTint.g; f32[((ptr + 116) >> 2) + 2] = data.bakedTint.b; f32[((ptr + 116) >> 2) + 3] = data.bakedTint.a;
- u8[ptr + 132] = data.hemisphere ? 1 : 0;
- f32[(ptr + 136) >> 2] = data.groundColor.r; f32[((ptr + 136) >> 2) + 1] = data.groundColor.g; f32[((ptr + 136) >> 2) + 2] = data.groundColor.b; f32[((ptr + 136) >> 2) + 3] = data.groundColor.a;
- u8[ptr + 152] = data.enabled ? 1 : 0;
+ f32[(ptr + 112) >> 2] = data.diffuseScale;
+ f32[(ptr + 116) >> 2] = data.diffuseTint.r; f32[((ptr + 116) >> 2) + 1] = data.diffuseTint.g; f32[((ptr + 116) >> 2) + 2] = data.diffuseTint.b; f32[((ptr + 116) >> 2) + 3] = data.diffuseTint.a;
+ f32[(ptr + 132) >> 2] = data.reflectionSaturation;
+ f32[(ptr + 136) >> 2] = data.bakedTint.r; f32[((ptr + 136) >> 2) + 1] = data.bakedTint.g; f32[((ptr + 136) >> 2) + 2] = data.bakedTint.b; f32[((ptr + 136) >> 2) + 3] = data.bakedTint.a;
+ u8[ptr + 152] = data.hemisphere ? 1 : 0;
+ f32[(ptr + 156) >> 2] = data.groundColor.r; f32[((ptr + 156) >> 2) + 1] = data.groundColor.g; f32[((ptr + 156) >> 2) + 2] = data.groundColor.b; f32[((ptr + 156) >> 2) + 3] = data.groundColor.a;
+ u8[ptr + 172] = data.enabled ? 1 : 0;
}
export function createLightData(): LightPtrData {
@@ -1057,6 +1063,8 @@ export function createLightData(): LightPtrData {
environmentRotation: 0,
drawEnvironment: false,
reflectionScale: 0,
+ diffuseScale: 0,
+ diffuseTint: { r: 0, g: 0, b: 0, a: 0 },
reflectionSaturation: 0,
bakedTint: { r: 0, g: 0, b: 0, a: 0 },
hemisphere: false,
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index 787b5cf9f..d47fad9ec 100644
--- a/sdk/src/ecs/component.generated.ts
+++ b/sdk/src/ecs/component.generated.ts
@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BillboardMode, BodyType, Canv
* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to
* run on mismatch, because mismatched offsets read the wrong heap bytes.
*/
-export const ABI_LAYOUT_HASH = '08d1bbb8d5e2107c';
+export const ABI_LAYOUT_HASH = '19dcbf4878f79091';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -545,6 +545,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
environmentRotation: 0,
drawEnvironment: false,
reflectionScale: 1,
+ diffuseScale: 1,
+ diffuseTint: { r: 1, g: 1, b: 1, a: 1 },
reflectionSaturation: 1,
bakedTint: { r: 1, g: 1, b: 1, a: 1 },
hemisphere: false,
@@ -554,8 +556,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
renderableField: 'enabled',
assetFields: [{ field: 'cookie', type: 'texture' as AssetFieldType }, { field: 'environment', type: 'environment' as AssetFieldType }],
entityFields: [],
- colorFields: ['color', 'bakedTint', 'groundColor'],
- animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerRadius', 'falloff', 'shadowStrength', 'cookieSize.x', 'cookieSize.y', 'innerAngle', 'outerAngle', 'shadowSoftness', 'sourceAngle', 'shadowDistance', 'groundColor.r', 'groundColor.g', 'groundColor.b', 'groundColor.a'],
+ colorFields: ['color', 'diffuseTint', 'bakedTint', 'groundColor'],
+ animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'intensity', 'radius', 'innerRadius', 'falloff', 'shadowStrength', 'cookieSize.x', 'cookieSize.y', 'innerAngle', 'outerAngle', 'shadowSoftness', 'sourceAngle', 'shadowDistance', 'diffuseScale', 'diffuseTint.r', 'diffuseTint.g', 'diffuseTint.b', 'diffuseTint.a', 'groundColor.r', 'groundColor.g', 'groundColor.b', 'groundColor.a'],
fields: {
type: { enum: [{ label: 'Point', value: 0 }, { label: 'Directional', value: 1 }, { label: 'Ambient', value: 2 }, { label: 'Spot', value: 3 }], tooltip: "Point, Directional, Ambient, or Spot." },
intensity: { min: 0, tooltip: "Brightness multiplier of the light." },
@@ -581,6 +583,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
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] } },
reflectionScale: { min: 0, tooltip: "Scale what baked reflection probes show (1 = as baked).", advanced: true, shownWhen: { field: "type", values: [2] } },
+ diffuseScale: { min: 0, tooltip: "Scale the light the environment gives surfaces, not what they reflect of it (1 = as the sky gives it).", shownWhen: { field: "type", values: [2] } },
+ diffuseTint: { tooltip: "Tint the light the environment gives surfaces, not what they reflect of it (white = as the sky gives it).", shownWhen: { field: "type", values: [2] } },
reflectionSaturation: { min: 0, max: 1, tooltip: "How much colour baked reflection probes keep (0 = grey).", advanced: true, shownWhen: { field: "type", values: [2] } },
bakedTint: { tooltip: "Multiply baked indirect light (lightmaps, probe volumes) by this colour (1 = as baked).", advanced: true, shownWhen: { field: "type", values: [2] } },
hemisphere: { tooltip: "Light from above in Color, from below in Ground Color, blended by which way a surface faces.", shownWhen: { field: "type", values: [2] } },
@@ -1757,6 +1761,8 @@ export interface LightData {
environmentRotation: number;
drawEnvironment: boolean;
reflectionScale: number;
+ diffuseScale: number;
+ diffuseTint: Color;
reflectionSaturation: number;
bakedTint: Color;
hemisphere: boolean;
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index d57729955..8de48d957 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -284,11 +284,13 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ name: 'environmentRotation', type: 'f32', offset: 100 },
{ name: 'drawEnvironment', type: 'bool', offset: 104 },
{ name: 'reflectionScale', type: 'f32', offset: 108 },
- { name: 'reflectionSaturation', type: 'f32', offset: 112 },
- { name: 'bakedTint', type: 'color', offset: 116 },
- { name: 'hemisphere', type: 'bool', offset: 132 },
- { name: 'groundColor', type: 'color', offset: 136 },
- { name: 'enabled', type: 'bool', offset: 152 },
+ { name: 'diffuseScale', type: 'f32', offset: 112 },
+ { name: 'diffuseTint', type: 'color', offset: 116 },
+ { name: 'reflectionSaturation', type: 'f32', offset: 132 },
+ { name: 'bakedTint', type: 'color', offset: 136 },
+ { name: 'hemisphere', type: 'bool', offset: 152 },
+ { name: 'groundColor', type: 'color', offset: 156 },
+ { name: 'enabled', type: 'bool', offset: 172 },
],
},
LightProbeVolume: {
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 65844cdb5..f7b1451f7 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -707,6 +707,8 @@ export interface Light {
environmentRotation: number;
drawEnvironment: boolean;
reflectionScale: number;
+ diffuseScale: number;
+ diffuseTint: Vec4;
reflectionSaturation: number;
bakedTint: Vec4;
hemisphere: boolean;
diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
index b1ca2fbe6..bc6c1e662 100644
--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
@@ -306,6 +306,25 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho
},
"tooltip": "Cookie size in world units; 0 = the light's own reach.",
},
+ "diffuseScale": {
+ "min": 0,
+ "shownWhen": {
+ "field": "type",
+ "values": [
+ 2,
+ ],
+ },
+ "tooltip": "Scale the light the environment gives surfaces, not what they reflect of it (1 = as the sky gives it).",
+ },
+ "diffuseTint": {
+ "shownWhen": {
+ "field": "type",
+ "values": [
+ 2,
+ ],
+ },
+ "tooltip": "Tint the light the environment gives surfaces, not what they reflect of it (white = as the sky gives it).",
+ },
"drawEnvironment": {
"shownWhen": {
"field": "type",
diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.h
index 60eb7e08f..4f8c6fe2d 100644
--- a/src/esengine/aot/EngineDigest.generated.h
+++ b/src/esengine/aot/EngineDigest.generated.h
@@ -6,7 +6,7 @@
/* One per address width, because the width is IN the digest: a host that
took the other one would refuse every module built for it. */
-#define ES_ENGINE_ABI_DIGEST_32 0xc399cbaff9d6f7ceULL
-#define ES_ENGINE_ABI_DIGEST_64 0xc34abad701e12e82ULL
+#define ES_ENGINE_ABI_DIGEST_32 0xb84bf4b1f18d650fULL
+#define ES_ENGINE_ABI_DIGEST_64 0x96474bc81a301acbULL
#define ES_ENGINE_ABI_DIGEST \
(sizeof(es_addr_t) == 8 ? ES_ENGINE_ABI_DIGEST_64 : ES_ENGINE_ABI_DIGEST_32)
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 9f704c52e..52d4ecacd 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 3cc1f95c10724533
+ * @schema_hash 099ea6187d8a5ca3
*/
-#define ES_EDITOR_API_SCHEMA_HASH "3cc1f95c10724533"
+#define ES_EDITOR_API_SCHEMA_HASH "099ea6187d8a5ca3"
#include <emscripten/bind.h>
#include <string>
@@ -404,6 +404,11 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"environmentRotation","type":"float","group":"Light"},
{"key":"drawEnvironment","type":"bool","group":"Light"},
{"key":"reflectionScale","type":"float","group":"Light"},
+ {"key":"diffuseScale","type":"float","group":"Light"},
+ {"key":"diffuseTint.r","type":"color","group":"Light"},
+ {"key":"diffuseTint.g","type":"color","group":"Light"},
+ {"key":"diffuseTint.b","type":"color","group":"Light"},
+ {"key":"diffuseTint.a","type":"color","group":"Light"},
{"key":"reflectionSaturation","type":"float","group":"Light"},
{"key":"bakedTint.r","type":"color","group":"Light"},
{"key":"bakedTint.g","type":"color","group":"Light"},
@@ -1586,6 +1591,11 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
else if (field == "shadowExtent") { c.shadowExtent = value; }
else if (field == "environmentRotation") { c.environmentRotation = value; }
else if (field == "reflectionScale") { c.reflectionScale = value; }
+ else if (field == "diffuseScale") { c.diffuseScale = value; }
+ else if (field == "diffuseTint.r") { c.diffuseTint.r = value; }
+ else if (field == "diffuseTint.g") { c.diffuseTint.g = value; }
+ else if (field == "diffuseTint.b") { c.diffuseTint.b = value; }
+ else if (field == "diffuseTint.a") { c.diffuseTint.a = value; }
else if (field == "reflectionSaturation") { c.reflectionSaturation = value; }
else if (field == "bakedTint.r") { c.bakedTint.r = value; }
else if (field == "bakedTint.g") { c.bakedTint.g = value; }
@@ -2211,6 +2221,11 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "shadowExtent") { return c.shadowExtent; }
else if (field == "environmentRotation") { return c.environmentRotation; }
else if (field == "reflectionScale") { return c.reflectionScale; }
+ else if (field == "diffuseScale") { return c.diffuseScale; }
+ else if (field == "diffuseTint.r") { return c.diffuseTint.r; }
+ else if (field == "diffuseTint.g") { return c.diffuseTint.g; }
+ else if (field == "diffuseTint.b") { return c.diffuseTint.b; }
+ else if (field == "diffuseTint.a") { return c.diffuseTint.a; }
else if (field == "reflectionSaturation") { return c.reflectionSaturation; }
else if (field == "bakedTint.r") { return c.bakedTint.r; }
else if (field == "bakedTint.g") { return c.bakedTint.g; }
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index f8571152c..60bb9dc0f 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -679,6 +679,8 @@ struct LightJS {
f32 environmentRotation;
bool drawEnvironment;
f32 reflectionScale;
+ f32 diffuseScale;
+ glm::vec4 diffuseTint;
f32 reflectionSaturation;
glm::vec4 bakedTint;
bool hemisphere;
@@ -712,6 +714,8 @@ void lightApplyJS(esengine::ecs::Light& c, const LightJS& js) {
c.environmentRotation = js.environmentRotation;
c.drawEnvironment = js.drawEnvironment;
c.reflectionScale = js.reflectionScale;
+ c.diffuseScale = js.diffuseScale;
+ c.diffuseTint = js.diffuseTint;
c.reflectionSaturation = js.reflectionSaturation;
c.bakedTint = js.bakedTint;
c.hemisphere = js.hemisphere;
@@ -752,6 +756,8 @@ LightJS lightToJS(const esengine::ecs::Light& c) {
js.environmentRotation = c.environmentRotation;
js.drawEnvironment = c.drawEnvironment;
js.reflectionScale = c.reflectionScale;
+ js.diffuseScale = c.diffuseScale;
+ js.diffuseTint = c.diffuseTint;
js.reflectionSaturation = c.reflectionSaturation;
js.bakedTint = c.bakedTint;
js.hemisphere = c.hemisphere;
@@ -2082,6 +2088,8 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("environmentRotation", &LightJS::environmentRotation)
.field("drawEnvironment", &LightJS::drawEnvironment)
.field("reflectionScale", &LightJS::reflectionScale)
+ .field("diffuseScale", &LightJS::diffuseScale)
+ .field("diffuseTint", &LightJS::diffuseTint)
.field("reflectionSaturation", &LightJS::reflectionSaturation)
.field("bakedTint", &LightJS::bakedTint)
.field("hemisphere", &LightJS::hemisphere)
@@ -4126,11 +4134,13 @@ static_assert(offsetof(esengine::ecs::Light, environment) == 96, "ABI offset dri
static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 100, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 100)");
static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 104, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 104)");
static_assert(offsetof(esengine::ecs::Light, reflectionScale) == 108, "ABI offset drift: esengine::ecs::Light.reflectionScale (EHT expected 108)");
-static_assert(offsetof(esengine::ecs::Light, reflectionSaturation) == 112, "ABI offset drift: esengine::ecs::Light.reflectionSaturation (EHT expected 112)");
-static_assert(offsetof(esengine::ecs::Light, bakedTint) == 116, "ABI offset drift: esengine::ecs::Light.bakedTint (EHT expected 116)");
-static_assert(offsetof(esengine::ecs::Light, hemisphere) == 132, "ABI offset drift: esengine::ecs::Light.hemisphere (EHT expected 132)");
-static_assert(offsetof(esengine::ecs::Light, groundColor) == 136, "ABI offset drift: esengine::ecs::Light.groundColor (EHT expected 136)");
-static_assert(offsetof(esengine::ecs::Light, enabled) == 152, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 152)");
+static_assert(offsetof(esengine::ecs::Light, diffuseScale) == 112, "ABI offset drift: esengine::ecs::Light.diffuseScale (EHT expected 112)");
+static_assert(offsetof(esengine::ecs::Light, diffuseTint) == 116, "ABI offset drift: esengine::ecs::Light.diffuseTint (EHT expected 116)");
+static_assert(offsetof(esengine::ecs::Light, reflectionSaturation) == 132, "ABI offset drift: esengine::ecs::Light.reflectionSaturation (EHT expected 132)");
+static_assert(offsetof(esengine::ecs::Light, bakedTint) == 136, "ABI offset drift: esengine::ecs::Light.bakedTint (EHT expected 136)");
+static_assert(offsetof(esengine::ecs::Light, hemisphere) == 152, "ABI offset drift: esengine::ecs::Light.hemisphere (EHT expected 152)");
+static_assert(offsetof(esengine::ecs::Light, groundColor) == 156, "ABI offset drift: esengine::ecs::Light.groundColor (EHT expected 156)");
+static_assert(offsetof(esengine::ecs::Light, enabled) == 172, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 172)");
static_assert(offsetof(esengine::ecs::LightProbeVolume, probes) == 0, "ABI offset drift: esengine::ecs::LightProbeVolume.probes (EHT expected 0)");
static_assert(offsetof(esengine::ecs::LightProbeVolume, capture) == 4, "ABI offset drift: esengine::ecs::LightProbeVolume.capture (EHT expected 4)");
static_assert(offsetof(esengine::ecs::LightProbeVolume, captureInterval) == 8, "ABI offset drift: esengine::ecs::LightProbeVolume.captureInterval (EHT expected 8)");
@@ -4446,7 +4456,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "08d1bbb8d5e2107c";
+static const char* kEsAbiLayoutHash = "19dcbf4878f79091";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hpp
index 86b9f8e03..c42d8a65d 100644
--- a/src/esengine/ecs/components/Light.hpp
+++ b/src/esengine/ecs/components/Light.hpp
@@ -234,6 +234,20 @@ struct Light {
tooltip="Scale what baked reflection probes show (1 = as baked).")
f32 reflectionScale{1.0f};
+ /** @brief What the light this Ambient light's environment gives a surface (its diffuse half, the sky's
+ * irradiance) is multiplied by, apart from what a surface reflects of it: a scene can be lit warmer
+ * or brighter than its sky looks, as Unreal's sky light is through its own colour. 1 = as the sky gives
+ * it. A flat or Hemisphere ambient light has nothing to reflect apart from its Color, so this is its
+ * environment's alone. */
+ ES_PROPERTY(min=0, animatable, shown_when=type:Ambient,
+ tooltip="Scale the light the environment gives surfaces, not what they reflect of it (1 = as the sky gives it).")
+ f32 diffuseScale{1.0f};
+
+ /** @brief The colour @ref diffuseScale's light is tinted by, authored as @ref color is. White = as the sky gives it. */
+ ES_PROPERTY(animatable, shown_when=type:Ambient,
+ tooltip="Tint the light the environment gives surfaces, not what they reflect of it (white = as the sky gives it).")
+ glm::vec4 diffuseTint{1.0f, 1.0f, 1.0f, 1.0f};
+
/** @brief How much colour baked reflections keep: 1 as baked, 0 grey. An overcast
* sky drains colour from what it lights, and from what a probe mirrors. */
ES_PROPERTY(min=0, max=1, shown_when=type:Ambient, advanced,
diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cpp
index a431e4759..d65a36afe 100644
--- a/src/esengine/renderer/frame/RenderFrame.cpp
+++ b/src/esengine/renderer/frame/RenderFrame.cpp
@@ -2011,7 +2011,15 @@ bool RenderFrame::collectEnvironment(const ecs::Light& light, const glm::vec3& s
const glm::vec4 params{textureId != 0 ? 1.0f : 0.0f, environment->maxRange,
static_cast<f32>(environment->mipCount) - 1.0f,
environment->faceSize};
- const auto& irradiance = withoutSun ? environment->skyIrradiance : environment->irradiance;
+ const auto& baked = withoutSun ? environment->skyIrradiance : environment->irradiance;
+ // The diffuse half on its own: the nine coefficients carry only what a surface is lit by, and the tint the shader
+ // applies (scale) covers what it reflects as well, so this light's diffuse colour goes on the coefficients alone.
+ const glm::vec3 tint = linear_color_ ? srgbToLinearCpu(glm::vec3{light.diffuseTint}) : glm::vec3{light.diffuseTint};
+ const glm::vec3 diffuse = tint * std::max(light.diffuseScale, 0.0f);
+ auto irradiance = baked;
+ if (diffuse != glm::vec3(1.0f)) {
+ for (glm::vec3& c : irradiance) c *= diffuse;
+ }
if (!context_.lights().setEnvironment(irradiance.data(), params, scale,
glm::radians(light.environmentRotation))) {
return false;
diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.h
index d992b536e..b7869a9de 100644
--- a/tests/aot/generated/conformance/handshake.h
+++ b/tests/aot/generated/conformance/handshake.h
@@ -1,5 +1,5 @@
/* GENERATED by sdk/tests/aot-conformance.test.ts — do not edit. */
/* The contract half of the handshake. The width half is the harness. */
-#define ES_CONF_EXPECTED_CONTRACT_HASH 0xc34abad701e12e82ULL
+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x96474bc81a301acbULL
/* And which BUILD the artifact beside this one is. */
#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULL
diff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.c
index 618d3f67c..1eea885b7 100644
--- a/tests/aot/generated/conformance/systems_decl.c
+++ b/tests/aot/generated/conformance/systems_decl.c
@@ -10,7 +10,7 @@
answer, it is a read of a different field. The address width belongs
to the MACHINE, so it mixes in here rather than in the compiler and a
32-bit artifact cannot load into a 64-bit host. */
-#define ES_ABI_ENGINE_DIGEST 0xc34abad701e12e82ULL
+#define ES_ABI_ENGINE_DIGEST 0x96474bc81a301acbULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_decl.c b/tests/aot/generated/move_system_decl.c
index 1ddf12dce..a43da2686 100644
--- a/tests/aot/generated/move_system_decl.c
+++ b/tests/aot/generated/move_system_decl.c
@@ -10,7 +10,7 @@
answer, it is a read of a different field. The address width belongs
to the MACHINE, so it mixes in here rather than in the compiler and a
32-bit artifact cannot load into a 64-bit host. */
-#define ES_ABI_ENGINE_DIGEST 0xc34abad701e12e82ULL
+#define ES_ABI_ENGINE_DIGEST 0x96474bc81a301acbULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_hash.h b/tests/aot/generated/move_system_hash.h
index 0bc8fad6c..d450dfbb0 100644
--- a/tests/aot/generated/move_system_hash.h
+++ b/tests/aot/generated/move_system_hash.h
@@ -1,6 +1,6 @@
/* GENERATED by @estella/compiler — do not edit. */
/* The contract half of the handshake. The width half is the harness. */
-#define ES_EXPECTED_CONTRACT_HASH 0xc34abad701e12e82ULL
+#define ES_EXPECTED_CONTRACT_HASH 0x96474bc81a301acbULL
/* And which BUILD the artifact beside this one is, which the sidecar
written with it has to carry too. */
#define ES_EXPECTED_MODULE_CONTRACT 0x10bf77bb714ea1e3ULL
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 996508f1c..af1792ebb 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -4718,6 +4718,8 @@ export const NOTED = {
{"note": "A meadow at rest no longer costs the frame 9 ms."},
"fix(render): a cloud's shadow dims the sun, not the sky - a sky's clouds multiplied every surface in its post pass, ambient and emission included; now the sky draws a cloud shadow map before the scene into a tile of the sun's shadow atlas and the first directional light reads it where each surface is shaded, as Unreal's atmosphere sun reads its clouds' shadow map":
{"note": "A cloud's shadow dims the sun, not the sky."},
+ "feat(render): an ambient light's diffuse has its own scale and tint - Diffuse Scale and Diffuse Tint multiply the light an environment gives surfaces and leave what they reflect of it and the sky drawn behind them alone, as Unreal's Sky Light keeps Intensity apart from its Indirect Lighting and Specular scales: a sky whose irradiance is too dark or too blue for a look is lifted without brightening every reflection":
+ {"note": "An ambient light's diffuse has its own scale and tint."},
"chore(gates): what the checks asked of this week's work - a disposition for esengine/image in a native script and its namespace there, Waterfall's width and its place in the corpus, the recipe worker's bundle as not a contract, shadeLight2D's inout against its return, and a test that named App as a type":
{"internal": "tables the gates read, brought level; a natively packaged script can now import esengine/image, which no native game has run yet"},
"feat(image): a picture's source goes where a texture goes, and its maps are recipes too - a texture field takes an .esimage, the image tools write a picture's normal and surface maps as recipes beside it and answer their refs, text is set by the drawer a game sets it with, and the viewport draws a recipe as a game does":
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index df56fb452..b312793a0 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -555,6 +555,10 @@ export const SCENES = [
{ id: "env-handed", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/env-handed.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[255,8,8],\"tol\":30},{\"x\":0.75,\"y\":0.5,\"rgb\":[8,8,255],\"tol\":30}]" } },
{ id: "env-handed-sky", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/env-handed-sky.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[255,8,8],\"tol\":30},{\"x\":0.75,\"y\":0.5,\"rgb\":[8,8,255],\"tol\":30}]" } },
{ 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}]" } },
+ // An ambient light's diffuse scale and tint reach the irradiance a surface is lit by: half the scale is half the light, and a
+ // tint with no red leaves a red sky's surfaces dark. A copy that scaled nothing, or scaled the sky drawn behind them, passes the rest.
+ { id: "diffuse-scale", 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\":\"diffuseScale\",\"value\":0.5}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[79,5,5],\"tol\":12},{\"x\":0.75,\"y\":0.5,\"rgb\":[79,5,5],\"tol\":12}]" } },
+ { id: "diffuse-tint", 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\":\"diffuseTint\",\"value\":{\"r\":0,\"g\":1,\"b\":1,\"a\":1}}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[2,10,10],\"tol\":8},{\"x\":0.75,\"y\":0.5,\"rgb\":[2,10,10],\"tol\":8}]" } },
{ 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.