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(render): baked reflection probes follow the weather through the ambient light's reflection scale and saturation
yhh3081b9b583f8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d11672d38..cda69c28e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,7 +16,7 @@ published separately; it ships inside the editor.### Added-- **Weather.** A Weather component puts a scene under clear, mist, overcast, rain or storm, turns between them and cycles by itself. A preset is a set of multipliers of what the scene already has — the sun at a fraction of its strength, the fog thicker, the picture greyer — plus absolute levels for rain and wetness, so one preset fits any project. The component drives the directional and ambient lights (in play mode only), the effects the scene's volumes resolve (Height Fog, Rain, Screen Space Reflections, Colour Grade, Auto Exposure), and takes `registerWeatherPreset` for weathers of a project's own. Volumes whose effects differ only in numbers now write the numbers into the passes they have instead of rebuilding them.+- **Weather.** A Weather component puts a scene under clear, mist, overcast, rain or storm, turns between them and cycles by itself. A preset is a set of multipliers of what the scene already has — the sun at a fraction of its strength, the fog thicker, the picture greyer — plus absolute levels for rain and wetness, so one preset fits any project. The component drives the directional and ambient lights (in play mode only), the effects the scene's volumes resolve (Height Fog, Rain, Screen Space Reflections, Colour Grade, Auto Exposure), and takes `registerWeatherPreset` for weathers of a project's own. Volumes whose effects differ only in numbers now write the numbers into the passes they have instead of rebuilding them. Reflection probes follow the weather: the ambient light scales what baked probes show and how much colour they keep. The Ambient `Light` gains `reflectionScale` and `reflectionSaturation`, which the weather drives.- **Quality levels are edited in Settings.** Settings → Project → Rendering edits each quality level, including which effects it runs. **Editing level** picks Low, Medium or High and the groups below — Rendering (render scale, minimum scale, MSAA), Shadows, Reflections and particles, Post-processing — show and change that level, so a level is read the way Unity's Quality page reads: a level, then its settings by subsystem. Post-processing lists every effect the engine has, ticked where the level runs it; an unticked one is skipped at that level wherever a camera's volume asks for it, with all of its passes. Device rules — the model, GPU, memory and core conditions Auto chooses a level by — are a table, shown when the mode is Auto, that says so on a row with no condition instead of dropping it while it is typed. Only what you change is saved to `project.esproject`, as a difference to that level, so an engine default that improves later still reaches a project that never touched it; a row's "changed" mark and reset follow the default of the level it is showing. The old per-level shadow distance rows are the Shadows group's Distance now. The effects a level leaves out had been matched by the prefix of a pass's name, which found none of Auto Exposure's passes; they are now matched by effect type. A new Quality Levels page in the performance docs describes it.- **A G-buffer, and reflections that read it.** Reflections now know how rough and how metal each surface is, from a G-buffer the frame draws on request. A post-process shader that says `#pragma gbuffer` makes the scene target carry a second RGBA8 colour attachment, written in the same pass by the scene's own shaders — octahedral normal in `r`/`g`, roughness in `b`, metalness in `a` (0 where nothing wrote) — and finds it at `u_gbuffer`. A frame whose chain has no such effect makes none and compiles no variant. The render device grew multiple colour attachments for it on both backends: WebGL2 attaches and resolves a second target and sets the draw buffers per pipeline, and WebGPU declares the second target on every pipeline of the pass (written by the ones that write it, an empty write mask for the rest), clears it to zero and resolves it with the colour. Pipelines say whether they write it (`PipelineDesc::gbuffer`), a blended draw never does, and the second output is its own shader variant (`ES_GBUFFER`), so no pass pays for what it did not ask for. The built-in Model shader — what an imported glTF material becomes — writes it from the material's roughness, metalness and normal map. `ssr` reads it: it takes the surface's own normal (normal-map detail that depth cannot see), weighs and blurs the reflection by roughness, reflects a metal at nearly full strength where a dielectric reflects 4%, skips a surface rougher than `maxRoughness` before marching the ray, and takes the Rain effect's `wetness` as a film that smooths the ground. Where nothing wrote a record, it falls back to depth and the dielectric it has always assumed. Verified in the editor on both backends: of two floors that differ only in their material's roughness, the glossy one changes ten times the pixels the rough one does. Quality levels can also leave out expensive effects now: quality levels can now skip expensive post-process effects by name. A level's `skipEffects` lists the effects it leaves out, each named by its effect type (`ssr`, `taa`, `depthOfField`, `lightShafts`, `autoExposure`, …), and an effect leaves with all of its passes however they are named; a project's own list in its quality profile replaces the level's. By default low leaves out reflections, temporal anti-aliasing, depth of field and light shafts, and medium leaves out reflections and depth of field; high leaves out nothing. These defaults come from the work each effect does per pixel, not from a weak device: the editor's new `fx-cost` check measured every effect on Bistro at 2560×1600 on a fast desktop GPU, and none added more than about 6 ms (reflections ~5, bloom ~4, the example's whole eight-effect chain ~11, the rest within the ±3 ms the run drifts by), so the levels have not been checked against the hardware they are for. Screen-space reflections leave a surface that recorded nothing alone, plain meshes now record a rough dielectric, and a puddle reflects the sky and what lies off screen.- **Rain, wet ground and puddles.** A Rain post-process effect adds falling rain, wet ground, puddles and ripples. `rain` draws three layers of slanted streaks, each at its own distance so a nearer surface hides them and the sky does not; darkens the ground that faces up by `wetness`; lays ripples and splashes where drops land on a grid in the world, so they stay on the ground as the camera moves (ripples need `intensity` above 0: wet ground under no rain is still); and, by `puddles` and `puddleScale`, covers part of the flat ground with standing water that is darker and takes denser, clearer ripples. `ssr` takes the same two numbers and treats those pools as mirrors — flat, far more reflective than dry ground, and sharp — so the pools the rain darkens are the pools that reflect. The clock is `u_time * timeScale + phase`, so a capture can pin it. The rain is a screen-space layer, not particles that collide with the world, and a puddle is flat ground whatever it lies on. Verified in the editor on both backends: streaks light a dark sky and move between two moments, wet ground reads darker, standing water darker still, and puddles change the reflection.diff --git a/desktop b/desktopindex 65e7cba4e..35230d91b 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 65e7cba4edcb125832383b3e665611ac458ec4f0+Subproject commit 35230d91bddb41467079e22a12375c982dd72778diff --git a/docs/astro/src/content/docs/graphics/weather.mdx b/docs/astro/src/content/docs/graphics/weather.mdxindex d53b51add..d0afd7d68 100644--- a/docs/astro/src/content/docs/graphics/weather.mdx+++ b/docs/astro/src/content/docs/graphics/weather.mdx@@ -35,6 +35,9 @@ A turn is eased, so it starts and ends gently, and a finished turn lands on its- **Rain.** The Rain effect is brought with the weather (when the scene has none) at the preset's strength, and Rain andScreen Space Reflections are given the wetness and puddles it leaves. Where the scene authored its own rain, theweather can only raise it.+- **Reflections.** A baked reflection probe shows the sky it was baked under, so a rainy street would mirror a sunny one.+ The ambient light carries `reflectionScale` and `reflectionSaturation` for exactly this: what baked probes show is+ multiplied by the first and drained of colour by the second, and the weather turns both down.- **Grade and exposure.** Colour Grade's saturation and contrast are scaled, and Auto Exposure's compensation raised.The effects are applied after the scene's volumes have blended, so a scene that fogs itself thinly stays thinner thandiff --git a/docs/astro/src/content/docs/zh-cn/graphics/weather.mdx b/docs/astro/src/content/docs/zh-cn/graphics/weather.mdxindex c418d73b7..45cb8c679 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/weather.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/weather.mdx@@ -29,6 +29,8 @@ description: 一个 Weather 组件,让场景处于晴、薄雾、阴天、雨或- **雾。** Height Fog 的密度、太阳辉光和它带的体积光被缩放,天空雾霾被提高,颜色向天气的颜色移动。- **雨。** 场景没有 Rain 效果时天气会带来一个,强度按预设;Rain 和屏幕空间反射还会得到天气留下的湿度和水坑。场景自己创作了雨,天气只能把它提高。+- **反射。** 烘焙的反射探针显示的是它烘焙时的天空,所以下雨的街道会映出晴天的街道。环境光带有 `reflectionScale` 和+ `reflectionSaturation` 就是为此:探针显示的内容乘以前者、按后者褪色,天气会把两者调低。- **调色与曝光。** Colour Grade 的饱和度和对比度被缩放,Auto Exposure 的补偿被提高。这些效果在场景的体积混合之后才施加,所以在同一场雨里,雾设得薄的场景仍然比雾设得厚的场景薄。diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.jsonindex 6d6a97fa4..5c212129d 100644--- a/docs/astro/src/data/components.generated.json+++ b/docs/astro/src/data/components.generated.json@@ -2121,6 +2121,22 @@"default": "false","doc": "Draw this environment as the sky behind the scene."},+ {+ "key": "reflectionScale",+ "type": "number",+ "default": "1",+ "doc": "Scale what baked reflection probes show (1 = as baked).",+ "range": "≥ 0",+ "advanced": true+ },+ {+ "key": "reflectionSaturation",+ "type": "number",+ "default": "1",+ "doc": "How much colour baked reflection probes keep (0 = grey).",+ "range": "0–1",+ "advanced": true+ },{"key": "enabled","type": "boolean",diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex d3e3c5626..9d93c430c 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 120 public · 152 beta · 1664 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"2f5ac38ffa80eb57"+"174c991a07d3d3ef"```## ANCHOR_AXES — const @experimental@@ -4858,6 +4858,8 @@ intensity: numbermeshShadows: booleanouterAngle: numberradius: number+reflectionSaturation: number+reflectionScale: numbershadowDistance: numbershadowExtent: numbershadowSoftness: numberdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex d5d173580..545182c34 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 120 public · 157 beta · 1683 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```-"2f5ac38ffa80eb57"+"174c991a07d3d3ef"```## ANCHOR_AXES — const @experimental@@ -4866,6 +4866,8 @@ intensity: numbermeshShadows: booleanouterAngle: numberradius: number+reflectionSaturation: number+reflectionScale: numbershadowDistance: numbershadowExtent: numbershadowSoftness: numberdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex f900bf921..751962817 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -4853,6 +4853,8 @@ intensity: numbermeshShadows: booleanouterAngle: numberradius: number+reflectionSaturation: number+reflectionScale: numbershadowDistance: numbershadowExtent: numbershadowSoftness: numberdiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex c2543b890..e01cb46e4 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -4853,6 +4853,8 @@ intensity: numbermeshShadows: booleanouterAngle: numberradius: number+reflectionSaturation: number+reflectionScale: numbershadowDistance: numbershadowExtent: numbershadowSoftness: numberdiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 5fbc79fbe..7760f8ca9 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -4860,6 +4860,8 @@ intensity: numbermeshShadows: booleanouterAngle: numberradius: number+reflectionSaturation: number+reflectionScale: numbershadowDistance: numbershadowExtent: numbershadowSoftness: numberdiff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.tsindex b58a4e895..12b66df7c 100644--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts@@ -818,6 +818,8 @@ export interface LightPtrData {environment: number;environmentRotation: number;drawEnvironment: boolean;+ reflectionScale: number;+ reflectionSaturation: number;enabled: boolean;}@@ -845,7 +847,9 @@ export function fillLight(out.environment = u32[(ptr + 84) >> 2];out.environmentRotation = f32[(ptr + 88) >> 2];out.drawEnvironment = u8[ptr + 92] !== 0;- out.enabled = u8[ptr + 93] !== 0;+ out.reflectionScale = f32[(ptr + 96) >> 2];+ out.reflectionSaturation = f32[(ptr + 100) >> 2];+ out.enabled = u8[ptr + 104] !== 0;}export function writeLight(@@ -872,7 +876,9 @@ export function writeLight(u32[(ptr + 84) >> 2] = data.environment;f32[(ptr + 88) >> 2] = data.environmentRotation;u8[ptr + 92] = data.drawEnvironment ? 1 : 0;- u8[ptr + 93] = data.enabled ? 1 : 0;+ f32[(ptr + 96) >> 2] = data.reflectionScale;+ f32[(ptr + 100) >> 2] = data.reflectionSaturation;+ u8[ptr + 104] = data.enabled ? 1 : 0;}export function createLightData(): LightPtrData {@@ -897,6 +903,8 @@ export function createLightData(): LightPtrData {environment: 0,environmentRotation: 0,drawEnvironment: false,+ reflectionScale: 0,+ reflectionSaturation: 0,enabled: false,};}diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.tsindex 8ec0354de..55cfa981d 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 = '2f5ac38ffa80eb57';+export const ABI_LAYOUT_HASH = '174c991a07d3d3ef';/*** One asset-valued field of a component: which field, and what kind of@@ -479,6 +479,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {environment: 0,environmentRotation: 0,drawEnvironment: false,+ reflectionScale: 1,+ reflectionSaturation: 1,enabled: true,},renderableField: 'enabled',@@ -506,6 +508,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {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] } },+ reflectionScale: { min: 0, tooltip: "Scale what baked reflection probes show (1 = as baked).", advanced: true, 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] } },},},LightProbeVolume: {@@ -1498,6 +1502,8 @@ export interface LightData {environment: number;environmentRotation: number;drawEnvironment: boolean;+ reflectionScale: number;+ reflectionSaturation: number;enabled: boolean;}diff --git a/sdk/src/postprocess/weatherSystem.ts b/sdk/src/postprocess/weatherSystem.tsindex 40bb9c0ee..80c71a1a4 100644--- a/sdk/src/postprocess/weatherSystem.ts+++ b/sdk/src/postprocess/weatherSystem.ts@@ -25,6 +25,8 @@ import {interface LightBase {intensity: number;color: { r: number; g: number; b: number; a: number };+ reflectionScale: number;+ reflectionSaturation: number;applied: number;}@@ -40,31 +42,45 @@ function restoreLights(world: World): void {for (const [entity, base] of bases) {if (world.has(entity, Light)) {const data = world.get(entity, Light) as LightData;- world.set(entity, Light, { ...data, intensity: base.intensity, color: { ...base.color } });+ world.set(entity, Light, {+ ...data, intensity: base.intensity, color: { ...base.color },+ reflectionScale: base.reflectionScale, reflectionSaturation: base.reflectionSaturation,+ });}}bases.clear();}-function applyLights(world: World, state: WeatherState): void {+function applyLights(world: World, state: WeatherState, drive: number): void {for (const entity of world.getEntitiesWithComponents([Light])) {const data = world.get(entity, Light) as LightData;if (data.type !== LIGHT_DIRECTIONAL && data.type !== LIGHT_AMBIENT) continue;let base = bases.get(entity);if (!base) {- base = { intensity: data.intensity, color: { ...data.color }, applied: Number.NaN };+ base = {+ intensity: data.intensity, color: { ...data.color },+ reflectionScale: data.reflectionScale ?? 1, reflectionSaturation: data.reflectionSaturation ?? 1,+ applied: Number.NaN,+ };bases.set(entity, base);}const sun = data.type === LIGHT_DIRECTIONAL;- const scale = sun ? state.sun : state.sky;+ const lights = (drive & WeatherDrive.Lights) !== 0;+ const reflections = (drive & WeatherDrive.Reflections) !== 0 && !sun;+ const scale = lights ? (sun ? state.sun : state.sky) : 1;// The key is what the light would be told: nothing is written for a frame that would say the same again.- const key = scale + (sun ? state.sunTint[0] * 7 + state.sunTint[1] * 13 + state.sunTint[2] * 29 : 0);+ const key = scale + (lights && sun ? state.sunTint[0] * 7 + state.sunTint[1] * 13 + state.sunTint[2] * 29 : 0)+ + (reflections ? state.reflection * 101 + state.reflectionSaturation * 211 : 0);if (base.applied === key) continue;base.applied = key;- const color = sun+ const color = lights && sun? { r: base.color.r * state.sunTint[0], g: base.color.g * state.sunTint[1], b: base.color.b * state.sunTint[2], a: base.color.a }: { ...base.color };- world.set(entity, Light, { ...data, intensity: base.intensity * scale, color });+ world.set(entity, Light, {+ ...data, intensity: base.intensity * scale, color,+ reflectionScale: reflections ? base.reflectionScale * state.reflection : base.reflectionScale,+ reflectionSaturation: reflections ? base.reflectionSaturation * state.reflectionSaturation : base.reflectionSaturation,+ });}}@@ -124,7 +140,7 @@ export const weatherSystem = defineSystem(const state = blendWeather(data.preset, data.target, data.progress);setCurrentWeather(state, data.drive);- if (playing && (data.drive & WeatherDrive.Lights)) applyLights(world, state);+ if (playing && (data.drive & (WeatherDrive.Lights | WeatherDrive.Reflections))) applyLights(world, state, data.drive);else if (bases.size > 0) restoreLights(world);},{ name: 'WeatherSystem' }diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.tsindex 72f140de9..6a8d8d63c 100644--- a/sdk/src/wasm/ptrLayouts.generated.ts+++ b/sdk/src/wasm/ptrLayouts.generated.ts@@ -247,7 +247,9 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'environment', type: 'u32', offset: 84 },{ name: 'environmentRotation', type: 'f32', offset: 88 },{ name: 'drawEnvironment', type: 'bool', offset: 92 },- { name: 'enabled', type: 'bool', offset: 93 },+ { name: 'reflectionScale', type: 'f32', offset: 96 },+ { name: 'reflectionSaturation', type: 'f32', offset: 100 },+ { name: 'enabled', type: 'bool', offset: 104 },],},LightProbeVolume: {diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.tsindex 802b2098d..d5834292a 100644--- a/sdk/src/wasm/wasm.generated.ts+++ b/sdk/src/wasm/wasm.generated.ts@@ -620,6 +620,8 @@ export interface Light {environment: number;environmentRotation: number;drawEnvironment: boolean;+ reflectionScale: number;+ reflectionSaturation: number;enabled: boolean;}diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snapindex 03e6241c5..7e8e3641b 100644--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap@@ -348,6 +348,29 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho},"tooltip": "Falloff reach in world units (Point / Spot).",},+ "reflectionSaturation": {+ "advanced": true,+ "max": 1,+ "min": 0,+ "shownWhen": {+ "field": "type",+ "values": [+ 2,+ ],+ },+ "tooltip": "How much colour baked reflection probes keep (0 = grey).",+ },+ "reflectionScale": {+ "advanced": true,+ "min": 0,+ "shownWhen": {+ "field": "type",+ "values": [+ 2,+ ],+ },+ "tooltip": "Scale what baked reflection probes show (1 = as baked).",+ },"shadowDistance": {"advanced": true,"min": 0,diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex c978ea309..f61a70766 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 a6d32400f48c59c2+ * @schema_hash ef5132d57ac30f0c*/-#define ES_EDITOR_API_SCHEMA_HASH "a6d32400f48c59c2"+#define ES_EDITOR_API_SCHEMA_HASH "ef5132d57ac30f0c"#include <emscripten/bind.h>#include <string>@@ -355,6 +355,8 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"environment","type":"asset","group":"Light"},{"key":"environmentRotation","type":"float","group":"Light"},{"key":"drawEnvironment","type":"bool","group":"Light"},+ {"key":"reflectionScale","type":"float","group":"Light"},+ {"key":"reflectionSaturation","type":"float","group":"Light"},{"key":"enabled","type":"bool","group":"Light"}])JSON";} else if (name == "LightProbeVolume") {@@ -1373,6 +1375,8 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::selse if (field == "shadowDistance") { c.shadowDistance = value; }else if (field == "shadowExtent") { c.shadowExtent = value; }else if (field == "environmentRotation") { c.environmentRotation = value; }+ else if (field == "reflectionScale") { c.reflectionScale = value; }+ else if (field == "reflectionSaturation") { c.reflectionSaturation = value; }else { return false; }return true;} else if (comp == "LightProbeVolume") {@@ -1902,6 +1906,8 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "shadowDistance") { return c.shadowDistance; }else if (field == "shadowExtent") { return c.shadowExtent; }else if (field == "environmentRotation") { return c.environmentRotation; }+ else if (field == "reflectionScale") { return c.reflectionScale; }+ else if (field == "reflectionSaturation") { return c.reflectionSaturation; }} else if (comp == "LightProbeVolume") {if (!reg.has<esengine::ecs::LightProbeVolume>(entity)) return 0.0f;const auto& c = reg.get<esengine::ecs::LightProbeVolume>(entity);diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex dc4daa0cf..98643d7f5 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -629,6 +629,8 @@ struct LightJS {u32 environment;f32 environmentRotation;bool drawEnvironment;+ f32 reflectionScale;+ f32 reflectionSaturation;bool enabled;};@@ -653,6 +655,8 @@ void lightApplyJS(esengine::ecs::Light& c, const LightJS& js) {c.environment = resource::EnvironmentHandle(js.environment);c.environmentRotation = js.environmentRotation;c.drawEnvironment = js.drawEnvironment;+ c.reflectionScale = js.reflectionScale;+ c.reflectionSaturation = js.reflectionSaturation;c.enabled = js.enabled;}@@ -684,6 +688,8 @@ LightJS lightToJS(const esengine::ecs::Light& c) {js.environment = c.environment.id();js.environmentRotation = c.environmentRotation;js.drawEnvironment = c.drawEnvironment;+ js.reflectionScale = c.reflectionScale;+ js.reflectionSaturation = c.reflectionSaturation;js.enabled = c.enabled;return js;}@@ -1822,6 +1828,8 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("environment", &LightJS::environment).field("environmentRotation", &LightJS::environmentRotation).field("drawEnvironment", &LightJS::drawEnvironment)+ .field("reflectionScale", &LightJS::reflectionScale)+ .field("reflectionSaturation", &LightJS::reflectionSaturation).field("enabled", &LightJS::enabled);value_object<LightProbeVolumeJS>("LightProbeVolume")@@ -3608,7 +3616,9 @@ static_assert(offsetof(esengine::ecs::Light, followEnvironmentSun) == 80, "ABI ostatic_assert(offsetof(esengine::ecs::Light, environment) == 84, "ABI offset drift: esengine::ecs::Light.environment (EHT expected 84)");static_assert(offsetof(esengine::ecs::Light, environmentRotation) == 88, "ABI offset drift: esengine::ecs::Light.environmentRotation (EHT expected 88)");static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 92, "ABI offset drift: esengine::ecs::Light.drawEnvironment (EHT expected 92)");-static_assert(offsetof(esengine::ecs::Light, enabled) == 93, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 93)");+static_assert(offsetof(esengine::ecs::Light, reflectionScale) == 96, "ABI offset drift: esengine::ecs::Light.reflectionScale (EHT expected 96)");+static_assert(offsetof(esengine::ecs::Light, reflectionSaturation) == 100, "ABI offset drift: esengine::ecs::Light.reflectionSaturation (EHT expected 100)");+static_assert(offsetof(esengine::ecs::Light, enabled) == 104, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 104)");static_assert(offsetof(esengine::ecs::LightProbeVolume, probes) == 0, "ABI offset drift: esengine::ecs::LightProbeVolume.probes (EHT expected 0)");static_assert(offsetof(esengine::ecs::LightProbeVolume, halfExtents) == 4, "ABI offset drift: esengine::ecs::LightProbeVolume.halfExtents (EHT expected 4)");static_assert(offsetof(esengine::ecs::LightProbeVolume, spacing) == 16, "ABI offset drift: esengine::ecs::LightProbeVolume.spacing (EHT expected 16)");@@ -3881,7 +3891,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "2f5ac38ffa80eb57";+static const char* kEsAbiLayoutHash = "174c991a07d3d3ef";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hppindex 95417cbe0..a02f2d8cb 100644--- a/src/esengine/ecs/components/Light.hpp+++ b/src/esengine/ecs/components/Light.hpp@@ -193,6 +193,20 @@ struct Light {tooltip="Draw this environment as the sky behind the scene.")bool drawEnvironment{false};+ /** @brief What baked reflection probes show, scaled. A probe was baked under one+ * sky, so it goes on showing that sky: a weather that darkens the scene+ * turns this down so a rainy street does not mirror a sunny one.+ * 1 = as baked. Read from the frame's Ambient light. */+ ES_PROPERTY(min=0, shown_when=type:Ambient, advanced,+ tooltip="Scale what baked reflection probes show (1 = as baked).")+ f32 reflectionScale{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,+ tooltip="How much colour baked reflection probes keep (0 = grey).")+ f32 reflectionSaturation{1.0f};+/** @brief Disabled lights are skipped during collection. */ES_PROPERTY()bool enabled{true};diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex 4ff577fe1..fd94ca4b4 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -1320,6 +1320,17 @@ void RenderFrame::collectLights(ecs::Registry& registry) {skyYaw = light.environmentRotation;}}+ // How the baked reflections are shown: the frame's environment light says, else the first ambient light does.+ {+ const ecs::Light* tone = nullptr;+ for (auto entity : view) {+ const auto& light = view.get(entity);+ if (!light.enabled || static_cast<ecs::LightType>(light.type) != ecs::LightType::Ambient) continue;+ if (entity == skyLight) { tone = &light; break; }+ if (!tone) tone = &light;+ }+ if (tone) context_.lights().setReflectionTone(tone->reflectionScale, tone->reflectionSaturation);+ }const bool sunCast = sunFollowed && sky && sky->hasSun;if (sunCast) {light_cap_.environmentSun = true;diff --git a/src/esengine/renderer/store/LightConstants.hpp b/src/esengine/renderer/store/LightConstants.hppindex 339e86357..5e8ef9fb2 100644--- a/src/esengine/renderer/store/LightConstants.hpp+++ b/src/esengine/renderer/store/LightConstants.hpp@@ -183,9 +183,10 @@ struct LightConstants {/// from a texture the light does not own — is tinted by the same number.glm::vec4 envTint{0.0f};/// x = how many COLUMNS the bound atlas holds, the environment's included, so- /// one texture serves the sky and every baked room; y/z/w unused. One is the- /// environment alone, which is what a scene with no bake has always been.- glm::vec4 reflParams{1.0f, 0.0f, 0.0f, 0.0f};+ /// one texture serves the sky and every baked room; y = how bright a baked+ /// column shows and z how much colour it keeps (1 = as baked); w unused. One+ /// column is the environment alone, which is what a scene with no bake has always been.+ glm::vec4 reflParams{1.0f, 1.0f, 1.0f, 0.0f};/// The world box column i answers inside: [2i] = min, [2i+1] = max. Column 0/// is the environment and has none — a sky is not somewhere. The shader/// PROJECTS onto a box, which is what slides a reflection across a wall.diff --git a/src/esengine/renderer/store/LightStore.hpp b/src/esengine/renderer/store/LightStore.hppindex dc3e86ab8..82cc89692 100644--- a/src/esengine/renderer/store/LightStore.hpp+++ b/src/esengine/renderer/store/LightStore.hpp@@ -114,13 +114,20 @@ public:*/void setReflections(const glm::vec4& params, const glm::vec4* boxes, u32 count) {data_.envParams = params;- data_.reflParams = glm::vec4(static_cast<f32>(count) + 1.0f, 0.0f, 0.0f, 0.0f);+ data_.reflParams.x = static_cast<f32>(count) + 1.0f;for (u32 i = 0; i < count * 2 && i < 2 * MAX_REFLECTION_PROBES; ++i) {data_.reflBox[i] = boxes[i];}dirty_ = true;}+ /// How baked reflection columns are shown this frame: their brightness and the colour they keep.+ void setReflectionTone(f32 scale, f32 saturation) {+ data_.reflParams.y = scale;+ data_.reflParams.z = saturation;+ dirty_ = true;+ }+/// Gives light @p slot a channel of the frame's 2D shadow mask, and says the mask/// exists. A slot nobody names keeps the -1 it was collected with, which is a light/// that lights without shadowing.diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 1fac5ef70..378cefee8 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -1566,7 +1566,12 @@ fn envRadiance(R : vec3f, roughness : f32, column : f32, P : vec3f) -> vec3f {// A baked column is the WHOLE radiance that reached its probe — the sky, the// ambient and every bounce. Adding the flat term or the sky's tint on top// would count the light the capture already saw a second time.- if (column >= 0.5) { return mix(a, b, lod - lo); }+ if (column >= 0.5) {+ let baked = mix(a, b, lod - lo);+ // What the bake saw, as the weather now says it looks: dimmer, and with less of its colour.+ let grey = dot(baked, vec3f(0.2126, 0.7152, 0.0722));+ return mix(vec3f(grey), baked, lc.u_reflParams.z) * lc.u_reflParams.y;+ }return lc.u_ambient.rgb + mix(a, b, lod - lo) * lc.u_envTint.rgb;}// Which definition of "where is the light" this surface is shaded with. One with a@@ -2471,7 +2476,12 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p// A baked column is the WHOLE radiance that reached its probe — the sky,// the ambient and every bounce. Adding the flat term or the sky's tint on// top would count the light the capture already saw a second time.- " if (column >= 0.5) return mix(a, b, lod - lo);\n"+ " if (column >= 0.5) {\n"+ " highp vec3 baked = mix(a, b, lod - lo);\n"+ // What the bake saw, as the weather now says it looks: dimmer, and with less of its colour.+ " highp float grey = dot(baked, vec3(0.2126, 0.7152, 0.0722));\n"+ " return mix(vec3(grey), baked, u_reflParams.z) * u_reflParams.y;\n"+ " }\n"" return u_ambient.rgb + mix(a, b, lod - lo) * u_envTint.rgb;\n""}\n"// Where a positional light is, from here, and how far. Real geometry measuresdiff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.hindex 7e8a1d7b2..26803f2ef 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 0x5b7515b290a65867ULL+#define ES_CONF_EXPECTED_CONTRACT_HASH 0xd10afae95e4a1476ULL/* And which BUILD the artifact beside this one is. */#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULLdiff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.cindex 9d0a1298b..2a5fdf295 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 belongsto the MACHINE, so it mixes in here rather than in the compiler and a32-bit artifact cannot load into a 64-bit host. */-#define ES_ABI_ENGINE_DIGEST 0x5b7515b290a65867ULL+#define ES_ABI_ENGINE_DIGEST 0xd10afae95e4a1476ULLES_EXPORT const uint64_t es_abi_hash =ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 67dbe6765..17223e38b 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -2495,6 +2495,8 @@ export const NOTED = {{"note":"Height Fog and Light Shafts follow the scene's own sun, and Height Fog can carry the sun's shadows as volumetric light."},"feat(runtime): a Weather component puts a scene under a preset, turns between presets and cycles through a sequence":{"note":"A Weather component puts a scene under clear, mist, overcast, rain or storm, turns between them and cycles by itself."},+ "feat(render): baked reflection probes follow the weather through the ambient light's reflection scale and saturation":+ {"note":"Reflection probes follow the weather: the ambient light scales what baked probes show and how much colour they keep."},"feat(render): reflections no longer guess a surface, plain meshes record themselves, and what the ray never finds is the sky":{"note":"Screen-space reflections leave a surface that recorded nothing alone, plain meshes now record a rough dielectric, and a puddle reflects the sky and what lies off screen."},};diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex 283791e10..ff161d9c2 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -368,6 +368,9 @@ export const SCENES = [{ id: "reflection-probe", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/reflection-probe.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_COUNTERS: "{\"render.reflection.probes\": 1}", ESTELLA_VERIFY_EXPECT: "[{\"x\": 0.25, \"y\": 0.5, \"rgb\": [255, 0, 0], \"tol\": 30}, {\"x\": 0.75, \"y\": 0.5, \"rgb\": [0, 228, 0], \"tol\": 30}, {\"x\": 0.5, \"y\": 0.5, \"rgb\": [0, 0, 0], \"tol\": 20}]" } },// The same scene with the probe switched off: both mirrors take the sky again,// which is the claim that a probe REPLACES an answer rather than adding one.+ // The same probe, shown at half strength: a weather that darkens the scene turns the baked reflection down with it,+ // so the red the probe mirrors is a darker red, and the sky outside it is untouched.+ { id: "reflection-probe-dim", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/reflection-probe.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_SET_FIELD: "{\"entity\": 1, \"component\": \"Light\", \"key\": \"reflectionScale\", \"value\": 0.25, \"steps\": 2}", ESTELLA_VERIFY_EXPECT: "[{\"x\": 0.25, \"y\": 0.5, \"rgb\": [64, 0, 0], \"tol\": 20}, {\"x\": 0.75, \"y\": 0.5, \"rgb\": [0, 228, 0], \"tol\": 30}]" } },{ id: "reflection-probe-off", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/reflection-probe.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_SET_FIELD: "{\"entity\": 2, \"component\": \"ReflectionProbe\", \"key\": \"enabled\", \"value\": false, \"steps\": 2}", ESTELLA_VERIFY_EXPECT: "[{\"x\": 0.25, \"y\": 0.5, \"rgb\": [0, 228, 0], \"tol\": 30}, {\"x\": 0.75, \"y\": 0.5, \"rgb\": [0, 228, 0], \"tol\": 30}]" } },// A BAKED room and a mirror ball in it: red on its left, green on its right.// A baked atlas has mixed channels at low alpha, which is what texture-alpha