A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(render): a 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
yhh5ad274d2e98e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex af61215db..1bb6d2a7d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,6 +33,7 @@ published separately; it ships inside the editor.### Fixed+- **A cloud's shadow dims the sun, not the sky.** Sky Atmosphere's **Cloud Shadows** and a custom sky's `groundShadow` multiplied every surface in the frame by the shadow, after it was lit: ambient light, reflections, other lights and emission were dimmed with the sun, and an unlit or emissive object went dark under a cloud. Measured against a reference island lit the same way, its ground came out 25 to 35 levels darker than the reference, and lit by the sky alone it was black. Now the sky draws a cloud shadow map before the scene, into one tile of the sun's shadow atlas (16 km round the camera, `u_cloudShadowExtentKm`), and the first directional light is dimmed by it where each surface is shaded, as Unreal's atmosphere sun reads its clouds' shadow map; nothing else is. The cloud shadow criteria now light their floor by a sun and add a floor nothing lights, which must keep its colour under the clouds; they and 56 shadow and sun criteria pass on WebGL2 and WebGPU. With the atlas full (High quality's four cascades fill it) the sun gives up its farthest cascade to the map. The map holds the light left at the camera's own height, exact below the cloud layer and an estimate inside it.- **A package that ships texture recipes draws them.** An export carried its `.esimage` files and drew its ground and its walls with no texture, saying only in the console that nothing there draws recipes. The call that installs the drawer had ended up in a part of the built SDK that was not marked as having an effect, and the bundler dropped it; and a playable ad, whose entry is the whole SDK, never imported the drawer at all. Both are put right, and a check now bundles a game that imports it and looks for it.- **A cleared asset field no longer stops a game.** An empty string in an asset field of an engine component (a material cleared to nothing) was taken for a path to load, came back from the load still a string, was written back as one and asked for again, without end: a field of plants put it on every cell it grew, and the packaged game stopped answering half a minute in. An empty string is no asset now, and a path nothing resolves keeps its placeholder.- **A Jolt hinge or slider whose motor is switched on in play keeps its limit.** Made with its motor off, a joint in the Jolt world took the solver's own motor settings when the motor was turned on later, which push without bound, so a door with a `maxMotorTorque` of 10 opened as if it had none, where the PhysX world held it to 10. Both now hold every motor to its limit from the start: switched on with a limit of nothing, a door turns nothing in either.diff --git a/docs/astro/src/content/docs/graphics/post-processing.mdx b/docs/astro/src/content/docs/graphics/post-processing.mdxindex 7f96f0962..7cecbcb31 100644--- a/docs/astro/src/content/docs/graphics/post-processing.mdx+++ b/docs/astro/src/content/docs/graphics/post-processing.mdx@@ -111,12 +111,19 @@ Turn **Keep Background** up and the scene is cleared to the camera's colour agai### Cloud shadows-Turn **Cloud Shadows** above 0 and the sun's ray from each surface is marched up through the cloud layer the sky draws, against the-same density, so the ground is darker and patchier under a cloud and lit where the sky is open. The sun's own light is what is-kept off; ambient light is not shadowed. Casting shadows also pins the clouds to the world instead of carrying them along with the-camera, so walking under a cloud and out of it works. The sky is in kilometres and the scene in its own units: **World Units per km**-says how many of the scene's units make one, and left alone it follows the project's Units per Metre (100 000 in a centimetre project, 1000 in a metre one). At 0 (the default) the effect is exactly as it was. The shadow falls on surfaces only; the-clouds are still drawn where there is sky.+Turn **Cloud Shadows** above 0 and the sky draws a cloud shadow map before the scene: for a square round the camera, 16 km each way,+what of the sun is left after its ray climbs through the cloud layer, against the same density the sky draws. The first directional+light reads it where each surface is shaded, as Unreal's atmosphere sun reads its clouds' shadow map: the ground is darker and patchier+under a cloud and lit where the sky is open. Only the sun's light is kept off. The sky's own light (ambient and reflections), other+lights and what a surface gives off are not dimmed, so a shaded field keeps its sky colour and an unlit or emissive object is as bright+under a cloud as out of it. Casting shadows also pins the clouds to the world instead of carrying them along with the camera, so+walking under a cloud and out of it works. The sky is in kilometres and the scene in its own units: **World Units per km** says how many+of the scene's units make one, and left alone it follows the project's Units per Metre (100 000 in a centimetre project, 1000 in a metre+one). At 0 (the default) the effect is exactly as it was.++The map is one tile of the sun's shadow atlas. With the atlas full (the High quality level's four cascades fill it) the sun gives up its+farthest cascade to it. Its value is the light left at the camera's own height on each ray, which is exact under the cloud layer and+an estimate for a camera inside it. Beyond 16 km, and where no sky casts clouds, the sun is not dimmed.### Split toning and lifted blacks@@ -560,9 +567,10 @@ radiance. Params are uniforms (`mc.` in WGSL), the time is `u_time.x`, and `textA sky with clouds can shade the ground under them. Set `groundShadow: true` and write a second function beside thefirst, `float skyShadow(vec3 world, vec3 sun)` (WGSL `fn skyShadow(world : vec3f, sun : vec3f) -> f32`): what is left-of the light at a world position, 1 for all of it. Every surface in the frame is multiplied by it, as Sky-Atmosphere's **Cloud Shadows** does with its own clouds, so it dims the whole of a surface's light and not the-sun's alone; keep its floor well above 0.+of the sun's light at a world position, 1 for all of it. The engine draws it into the sun's cloud shadow map before the scene,+as Sky Atmosphere's **Cloud Shadows** does with its own clouds, and the first directional light is dimmed by it where each+surface is shaded; the sky's own light and what a surface gives off are not. A floor of 0 is a shadow as dark as the sky's+light leaves it. `u_cloudShadowExtentKm` (16 km by default) is how far the map reaches round the camera.| Method | Description ||---|---|diff --git a/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx b/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdxindex 083a9ae4a..3be369646 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx@@ -99,7 +99,9 @@ Estella 通过 ping-pong 帧缓冲运行全屏后处理。加一个 `PostProcess### 云影-把**云影**调到 0 以上,从每个表面朝太阳发出的光线会穿过天空绘制的云层逐步前进,用的是同一份密度,所以云下的地面更暗、更斑驳,天空开阔处则被照亮。被挡掉的是太阳直射光;环境光不受影响。开启云影也会把云固定在世界里而不是跟着相机走,所以人可以走进云影再走出来。天空以千米为单位,场景用自己的单位:**每千米世界单位**说明场景里多少个单位是一千米。为 0(默认值)时效果与之前完全一样。阴影只落在表面上;云仍然只画在有天空的地方。+把**云影**调到 0 以上,天空会在画场景之前先画一张云影图:以相机为中心、每边 16 千米的范围内,太阳光线穿过云层(用天空绘制云时的同一份密度)后还剩多少。第一盏平行光在给每个表面着色时读取它,和 Unreal 大气里的太阳读取云层的云影图一样:云下的地面更暗、更斑驳,天空开阔处则被照亮。被挡掉的只有太阳光。天空自身的光(环境光和反射)、其他灯光以及表面自发的光都不受影响,所以阴影里的草地保留天空的颜色,不受光或自发光的物体在云下和云外一样亮。开启云影也会把云固定在世界里而不是跟着相机走,所以人可以走进云影再走出来。天空以千米为单位,场景用自己的单位:**每千米世界单位**说明场景里多少个单位是一千米,不设时跟随项目的每米单位数(厘米项目为 100 000,米项目为 1000)。为 0(默认值)时效果与之前完全一样。++云影图占太阳阴影图集里的一块。图集满时(高画质的四级级联正好占满)太阳会让出最远的一级级联。图里存的是每条光线在相机所在高度处剩下的光,相机在云层以下时是精确值,相机在云层之中时是近似值。16 千米以外、以及没有投射云影的天空时,太阳不被压暗。### 分离色调与抬高的黑位@@ -432,8 +434,9 @@ defineSkyEffect({有云的天空可以给云下的地面投影。设 `groundShadow: true`,并在第一个函数旁边再写一个`float skyShadow(vec3 world, vec3 sun)`(WGSL 为 `fn skyShadow(world : vec3f, sun : vec3f) -> f32`):某个世界位置上-还剩多少光,1 为全部。画面里的每个表面都乘上它,和 Sky Atmosphere 的 **Cloud Shadows** 对自己的云做的一样,-所以它压暗的是表面的全部光照,不只是太阳的;下限要明显高于 0。+太阳光还剩多少,1 为全部。引擎在画场景之前把它画进太阳的云影图,和 Sky Atmosphere 的 **Cloud Shadows** 对自己的云做的一样,+第一盏平行光在给每个表面着色时被它压暗;天空自身的光和表面自发的光不受影响。下限为 0 时,阴影的暗度就是只剩天空光时的亮度。+`u_cloudShadowExtentKm`(默认 16 千米)是云影图以相机为中心覆盖的范围。| 方法 | 说明 ||---|---|diff --git a/fixtures/scenes/oracle-cloud-shadow-clear-ortho.esscene b/fixtures/scenes/oracle-cloud-shadow-clear-ortho.essceneindex 47d03741d..69de9c470 100644--- a/fixtures/scenes/oracle-cloud-shadow-clear-ortho.esscene+++ b/fixtures/scenes/oracle-cloud-shadow-clear-ortho.esscene@@ -70,7 +70,7 @@"b": 0.8,"a": 1},- "lit": false,+ "lit": true,"opaque": true,"cullBackfaces": true,"enabled": true@@ -80,6 +80,44 @@},{"id": 2,+ "name": "Sun",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "rotation": {+ "w": 0.8830222215594891,+ "x": -0.3213938048432697,+ "y": 0.3213938048432697,+ "z": 0.11697777844051097+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 1,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1+ }+ }+ ]+ },+ {+ "id": 3,"name": "Look","parent": null,"children": [],diff --git a/fixtures/scenes/oracle-cloud-shadow-clear-perspective.esscene b/fixtures/scenes/oracle-cloud-shadow-clear-perspective.essceneindex 954816cb6..4d7bb06e3 100644--- a/fixtures/scenes/oracle-cloud-shadow-clear-perspective.esscene+++ b/fixtures/scenes/oracle-cloud-shadow-clear-perspective.esscene@@ -71,7 +71,7 @@"b": 0.8,"a": 1},- "lit": false,+ "lit": true,"opaque": true,"cullBackfaces": true,"enabled": true@@ -81,6 +81,44 @@},{"id": 2,+ "name": "Sun",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "rotation": {+ "w": 0.8830222215594891,+ "x": -0.3213938048432697,+ "y": 0.3213938048432697,+ "z": 0.11697777844051097+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 1,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1+ }+ }+ ]+ },+ {+ "id": 3,"name": "Look","parent": null,"children": [],diff --git a/fixtures/scenes/oracle-cloud-shadow-under-ortho.esscene b/fixtures/scenes/oracle-cloud-shadow-under-ortho.essceneindex 0cce2c50d..a48e32681 100644--- a/fixtures/scenes/oracle-cloud-shadow-under-ortho.esscene+++ b/fixtures/scenes/oracle-cloud-shadow-under-ortho.esscene@@ -70,7 +70,7 @@"b": 0.8,"a": 1},- "lit": false,+ "lit": true,"opaque": true,"cullBackfaces": true,"enabled": true@@ -80,6 +80,44 @@},{"id": 2,+ "name": "Sun",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "rotation": {+ "w": 0.8830222215594891,+ "x": -0.3213938048432697,+ "y": 0.3213938048432697,+ "z": 0.11697777844051097+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 1,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1+ }+ }+ ]+ },+ {+ "id": 3,"name": "Look","parent": null,"children": [],diff --git a/fixtures/scenes/oracle-cloud-shadow-under-perspective.esscene b/fixtures/scenes/oracle-cloud-shadow-under-perspective.essceneindex 1e7b3ca5d..8f287e020 100644--- a/fixtures/scenes/oracle-cloud-shadow-under-perspective.esscene+++ b/fixtures/scenes/oracle-cloud-shadow-under-perspective.esscene@@ -71,7 +71,7 @@"b": 0.8,"a": 1},- "lit": false,+ "lit": true,"opaque": true,"cullBackfaces": true,"enabled": true@@ -81,6 +81,44 @@},{"id": 2,+ "name": "Sun",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "rotation": {+ "w": 0.8830222215594891,+ "x": -0.3213938048432697,+ "y": 0.3213938048432697,+ "z": 0.11697777844051097+ }+ }+ },+ {+ "type": "Light",+ "data": {+ "type": 1,+ "color": {+ "r": 1,+ "g": 1,+ "b": 1,+ "a": 1+ },+ "intensity": 1+ }+ }+ ]+ },+ {+ "id": 3,"name": "Look","parent": null,"children": [],diff --git a/fixtures/scenes/oracle-cloud-shadow-unlit-ortho.esscene b/fixtures/scenes/oracle-cloud-shadow-unlit-ortho.esscenenew file mode 100644index 000000000..5c38d265c--- /dev/null+++ b/fixtures/scenes/oracle-cloud-shadow-unlit-ortho.esscene@@ -0,0 +1,125 @@+{+ "version": 4,+ "name": "oracle-cloud-shadow-unlit-ortho",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 400,+ "z": 0+ },+ "rotation": {+ "x": -0.7071067811865476,+ "y": 0,+ "z": 0,+ "w": 0.7071067811865476+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 1,+ "orthoSize": 100,+ "nearPlane": 1,+ "farPlane": 2000,+ "isActive": true,+ "priority": 0+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Floor",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "scale": {+ "x": 1.8,+ "y": 0.1,+ "z": 1.8+ }+ }+ },+ {+ "type": "MeshRenderer",+ "data": {+ "mesh": "builtin:cube",+ "color": {+ "r": 0.8,+ "g": 0.8,+ "b": 0.8,+ "a": 1+ },+ "lit": false,+ "opaque": true,+ "cullBackfaces": true,+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "Look",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "PostProcessVolume",+ "data": {+ "isGlobal": true,+ "priority": 0,+ "weight": 1,+ "effects": [+ {+ "type": "skyAtmosphere",+ "enabled": true,+ "uniforms": {+ "u_clouds": 1,+ "u_overcast": 1,+ "u_cloudShadow": 1,+ "u_unitsPerKm": 1000,+ "u_sunElevation": 40,+ "u_sunAzimuth": 40,+ "u_altitude": 2.2,+ "u_windSpeed": 0+ }+ }+ ]+ }+ }+ ]+ }+ ]+}diff --git a/fixtures/scenes/oracle-cloud-shadow-unlit-perspective.esscene b/fixtures/scenes/oracle-cloud-shadow-unlit-perspective.esscenenew file mode 100644index 000000000..6ad2a195f--- /dev/null+++ b/fixtures/scenes/oracle-cloud-shadow-unlit-perspective.esscene@@ -0,0 +1,126 @@+{+ "version": 4,+ "name": "oracle-cloud-shadow-unlit-perspective",+ "entities": [+ {+ "id": 0,+ "name": "Camera",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 400,+ "z": 0+ },+ "rotation": {+ "x": -0.7071067811865476,+ "y": 0,+ "z": 0,+ "w": 0.7071067811865476+ }+ }+ },+ {+ "type": "Camera",+ "data": {+ "projectionType": 0,+ "orthoSize": 100,+ "nearPlane": 1,+ "farPlane": 2000,+ "isActive": true,+ "priority": 0,+ "fov": 40+ }+ }+ ]+ },+ {+ "id": 1,+ "name": "Floor",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "scale": {+ "x": 1.8,+ "y": 0.1,+ "z": 1.8+ }+ }+ },+ {+ "type": "MeshRenderer",+ "data": {+ "mesh": "builtin:cube",+ "color": {+ "r": 0.8,+ "g": 0.8,+ "b": 0.8,+ "a": 1+ },+ "lit": false,+ "opaque": true,+ "cullBackfaces": true,+ "enabled": true+ }+ }+ ]+ },+ {+ "id": 2,+ "name": "Look",+ "parent": null,+ "children": [],+ "visible": true,+ "components": [+ {+ "type": "Transform",+ "data": {+ "position": {+ "x": 0,+ "y": 0,+ "z": 0+ }+ }+ },+ {+ "type": "PostProcessVolume",+ "data": {+ "isGlobal": true,+ "priority": 0,+ "weight": 1,+ "effects": [+ {+ "type": "skyAtmosphere",+ "enabled": true,+ "uniforms": {+ "u_clouds": 1,+ "u_overcast": 1,+ "u_cloudShadow": 1,+ "u_unitsPerKm": 1000,+ "u_sunElevation": 40,+ "u_sunAzimuth": 40,+ "u_altitude": 2.2,+ "u_windSpeed": 0+ }+ }+ ]+ }+ }+ ]+ }+ ]+}diff --git a/sdk/src/postprocess/cloudShadowParams.ts b/sdk/src/postprocess/cloudShadowParams.tsnew file mode 100644index 000000000..98e7e786e--- /dev/null+++ b/sdk/src/postprocess/cloudShadowParams.ts@@ -0,0 +1,22 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file cloudShadowParams.ts+ * @brief The params by which a sky draws the sun's cloud shadow map, as Unreal's atmosphere sun reads its clouds' shadow.+ *+ * @details A sky that declares them is asked by the engine, before the scene, for what of the sun is left under its clouds across a+ * square round the camera (`u_cloudShadowPass` 1, where the square's tile lies in the target, and the matrix from the square+ * back to the world); the sun's light is then+ * dimmed by it where each surface is shaded. The sky's own light and a surface's emission are not, as they are not under a+ * real cloud. `u_castCloudShadows` says the sky casts any; `u_cloudShadowExtentKm` how far the square reaches each way.+ */+export const CLOUD_SHADOW_PARAMS: readonly string[] = [+ '#pragma param u_castCloudShadows float default(1) range(0,1)',+ '#pragma param u_cloudShadowExtentKm float default(16) range(1,200)',+ '#pragma param u_cloudShadowPass float default(0) range(0,1)',+ '#pragma param u_cloudShadowRect color default(0,0,1,1)',+ '#pragma param u_cloudShadowInv0 color default(1,0,0,0)',+ '#pragma param u_cloudShadowInv1 color default(0,1,0,0)',+ '#pragma param u_cloudShadowInv2 color default(0,0,1,0)',+ '#pragma param u_cloudShadowInv3 color default(0,0,0,1)',+];diff --git a/sdk/src/postprocess/customSky.ts b/sdk/src/postprocess/customSky.tsindex f645409a8..665e660f3 100644--- a/sdk/src/postprocess/customSky.ts+++ b/sdk/src/postprocess/customSky.ts@@ -17,13 +17,15 @@* effect's: in GLSL by name, in WGSL as `mc.<name>`; the time is `u_time.x` / `tc.u_time.x`.** A sky with clouds can shade the ground under them, as Sky Atmosphere's do: with `groundShadow` the author writes a- * second function, `skyShadow(world, sun)`, how much of the scene's light is left at a world position (1 is all of- * it), and every surface the pass finds is multiplied by it.+ * second function, `skyShadow(world, sun)`, how much of the sun's light is left at a world position (1 is all of it).+ * The engine draws it into the sun's cloud shadow map before the scene (see `CLOUD_SHADOW_PARAMS`), and the sun's light+ * is dimmed by it where each surface is shaded: the sky's own light and a surface's emission are not.*/import type { ShaderHandle } from '../render/material';import { Material } from '../render/material';import { registerEffect, type EffectColorDef, type EffectUniformDef } from './effects';+import { CLOUD_SHADOW_PARAMS } from './cloudShadowParams';import type { BuiltinTexture } from './effects';export interface SkyEffectSource {@@ -42,7 +44,7 @@ export interface SkyEffectSource {wgsl: string;/*** The sky shades the ground: the sources also hold `float skyShadow(vec3 world, vec3 sun)` and- * `fn skyShadow(world : vec3f, sun : vec3f) -> f32`, what is left of a surface's light at a world position, 0 to 1.+ * `fn skyShadow(world : vec3f, sun : vec3f) -> f32`, what is left of the sun's light at a world position, 0 to 1.*/groundShadow?: boolean;}@@ -75,6 +77,7 @@ export function skyEffectSource(src: SkyEffectSource): string {'#pragma param u_intensity float default(1) range(0,8)','#pragma param u_lightScene float default(0) range(0,1)','#pragma param u_skyCapture float default(0) range(0,1)',+ ...(src.groundShadow ? CLOUD_SHADOW_PARAMS : []),// A marker the engine reads (see Sky Atmosphere): the scene is cleared to nothing, so its alpha is its coverage.'#pragma param u_sceneCoverage float default(1) range(0,1)',...(src.uniforms ?? []).map(pragmaLine),@@ -114,7 +117,16 @@ void main() {findSun(lightDir, lightColor, tiles);vec3 sun = lightDir.w > 0.5 ? lightDir.xyz : vec3(0.0, 1.0, 0.0);vec3 sunColor = lightColor.rgb * lightColor.a;- if (u_skyCapture > 0.5) {+${src.groundShadow ? ` if (u_cloudShadowPass > 0.5) {+ // A texel of the sun's cloud shadow map: a point on the ray through it, back in the world, and what of the sun is left there.+ // The pass covers the target, and this texel is found in the tile by the coordinates the sun's lookup reads it by.+ vec2 inTile = (v_texCoord - u_cloudShadowRect.xy) / u_cloudShadowRect.z;+ if (any(lessThan(inTile, vec2(0.0))) || any(greaterThan(inTile, vec2(1.0)))) discard;+ vec4 at = mat4(u_cloudShadowInv0, u_cloudShadowInv1, u_cloudShadowInv2, u_cloudShadowInv3) * vec4(inTile * 2.0 - 1.0, 0.5, 1.0);+ fragColor = vec4(1.0, 1.0, 1.0, clamp(skyShadow(at.xyz / at.w + u_renderOrigin.xyz, sun), 0.0, 1.0));+ return;+ }+` : ''} if (u_skyCapture > 0.5) {vec3 c = clamp(skyRadiance(esSkyPanoramaDir(v_texCoord), sun, sunColor, 1.0) * u_intensity, vec3(0.0), vec3(${CUSTOM_SKY_RANGE.toFixed(1)}));float m = clamp(max(max(c.r, c.g), max(c.b, 1e-6)) / ${CUSTOM_SKY_RANGE.toFixed(1)}, 1.0 / 255.0, 1.0);m = ceil(m * 255.0) / 255.0;@@ -124,7 +136,7 @@ void main() {vec4 src = texture(u_sceneTexture, v_texCoord);ivec2 size = textureSize(u_sceneDepth, 0);float depth = texelFetch(u_sceneDepth, clamp(ivec2(v_texCoord * vec2(size)), ivec2(0), size - ivec2(1)), 0).r;- if (depth < 1.0 && src.a > 0.999) { fragColor = ${src.groundShadow ? 'vec4(src.rgb * clamp(skyShadow(worldFromDepth(v_texCoord, depth) + u_renderOrigin.xyz, sun), 0.0, 1.0), src.a)' : 'src'}; return; }+ if (depth < 1.0 && src.a > 0.999) { fragColor = src; return; }vec3 entry = worldFromDepth(v_texCoord, 0.0);vec3 dir = normalize(worldFromDepth(v_texCoord, 1.0) - entry);vec3 col = skyRadiance(dir, sun, sunColor, 0.0) * u_intensity;@@ -147,7 +159,14 @@ fn esSkyPanoramaDir(uv : vec2f) -> vec3f {var sun = vec3f(0.0, 1.0, 0.0);if (found.dir.w > 0.5) { sun = found.dir.xyz; }let sunColor = found.color.rgb * found.color.a;- if (mc.u_skyCapture > 0.5) {+${src.groundShadow ? ` if (mc.u_cloudShadowPass > 0.5) {+ let inTile = (v.v_texCoord - mc.u_cloudShadowRect.xy) / mc.u_cloudShadowRect.z;+ if (any(inTile < vec2f(0.0)) || any(inTile > vec2f(1.0))) { discard; }+ let inv = mat4x4f(mc.u_cloudShadowInv0, mc.u_cloudShadowInv1, mc.u_cloudShadowInv2, mc.u_cloudShadowInv3);+ let at = inv * vec4f(inTile * 2.0 - 1.0, 0.5, 1.0);+ return vec4f(1.0, 1.0, 1.0, clamp(skyShadow(at.xyz / at.w + frame.renderOrigin.xyz, sun), 0.0, 1.0));+ }+` : ''} if (mc.u_skyCapture > 0.5) {let c = clamp(skyRadiance(esSkyPanoramaDir(v.v_texCoord), sun, sunColor, 1.0) * mc.u_intensity, vec3f(0.0), vec3f(${CUSTOM_SKY_RANGE.toFixed(1)}));var m = clamp(max(max(c.r, c.g), max(c.b, 1e-6)) / ${CUSTOM_SKY_RANGE.toFixed(1)}, 1.0 / 255.0, 1.0);m = ceil(m * 255.0) / 255.0;@@ -156,7 +175,7 @@ fn esSkyPanoramaDir(uv : vec2f) -> vec3f {let src = textureSampleLevel(t1, s1, v.v_texCoord, 0.0);let size = vec2i(textureDimensions(t7, 0));let depth = textureLoad(t7, clamp(vec2i(v.v_texCoord * vec2f(size)), vec2i(0), size - vec2i(1)), 0);- if (depth < 1.0 && src.a > 0.999) { return ${src.groundShadow ? 'vec4f(src.rgb * clamp(skyShadow(worldFromDepth(v.v_texCoord, depth) + frame.renderOrigin.xyz, sun), 0.0, 1.0), src.a)' : 'src'}; }+ if (depth < 1.0 && src.a > 0.999) { return src; }let entry = worldFromDepth(v.v_texCoord, 0.0);let dir = normalize(worldFromDepth(v.v_texCoord, 1.0) - entry);let col = skyRadiance(dir, sun, sunColor, 0.0) * mc.u_intensity;diff --git a/sdk/src/postprocess/sources/atmosphere.ts b/sdk/src/postprocess/sources/atmosphere.tsindex 91af75603..fe90eeabc 100644--- a/sdk/src/postprocess/sources/atmosphere.ts+++ b/sdk/src/postprocess/sources/atmosphere.ts@@ -7,6 +7,7 @@import type { ShaderHandle } from '../../render/material';import { Material } from '../../render/material';import { registerEffectSources } from '../effectSources';+import { CLOUD_SHADOW_PARAMS } from '../cloudShadowParams';import { rain2dEffects } from './rain2d';import { fog2dEffects } from './fog2d';import { SSAO_GLSL, SSAO_WGSL, PUDDLE_GLSL, PUDDLE_WGSL, BASIN_GLSL, BASIN_WGSL, GBUFFER_GLSL, GBUFFER_WGSL } from './shared';@@ -353,6 +354,7 @@ export const atmosphereEffects = {#pragma param u_sunElevation float default(35) range(-90,90)#pragma param u_cloudShadow float default(0) range(0,1)#pragma param u_unitsPerKm float default(1000) range(1,100000)+${CLOUD_SHADOW_PARAMS.join(String.fromCharCode(10))}#pragma param u_cloudMask texture default(black)#pragma param u_cloudMaskTile float default(0) range(0,100)#pragma param u_cloudMask2 texture default(black)@@ -517,34 +519,6 @@ bool upsampledClouds(out vec3 L, out float T) {return true;}-/// The cloud shadow on a surface, read from the half-size pass: the surface texels among the four the pixel falls between, each weighted-/// by how near its point in the world is to this pixel's, so a texel across a silhouette does not lend its shadow. False when none is near.-bool upsampledShadow(vec3 P, vec3 entry, out float lit) {- ivec2 dsize = textureSize(u_sceneDepth, 0);- ivec2 hsize = textureSize(u_texture, 0);- vec2 hf = v_texCoord * vec2(hsize) - 0.5;- ivec2 base = ivec2(floor(hf));- vec2 fr = hf - vec2(base);- float tol = max(0.08 * length(P - entry), 1e-4);- float sum = 0.0;- float wsum = 0.0;- for (int j = 0; j < 4; ++j) {- ivec2 o = ivec2(j & 1, j >> 1);- ivec2 t = clamp(base + o, ivec2(0), hsize - ivec2(1));- vec4 h = texelFetch(u_texture, t, 0);- if (h.a >= 0.0) continue;- vec2 uv = uvOfTexel(t, hsize);- vec3 Pj = worldFromDepth(uv, depthAt(screenTexel(uv, dsize), dsize));- float bw = (o.x == 1 ? fr.x : 1.0 - fr.x) * (o.y == 1 ? fr.y : 1.0 - fr.y);- float w = bw * max(1.0 - length(Pj - P) / tol, 0.0);- sum += h.r * w;- wsum += w;- }- if (wsum < UP_MIN_WEIGHT) return false;- lit = sum / wsum;- return true;-}-void main() {vec4 src = texture(u_sceneTexture, v_texCoord);ivec2 size = textureSize(u_sceneDepth, 0);@@ -553,7 +527,8 @@ void main() {// alpha is how much the sky shows through it, and that includes a pixel whose depth says surface because one sample of it is.bool covered = u_panorama <= 0.001;bool geometry = covered ? (depth < 1.0 && src.a > 0.999) : depth < 1.0;- if (geometry && u_cloudShadow <= 0.001) { fragColor = src; return; }+ // A surface is as the scene drew it: its cloud shadow is on the sun's light, which the sun's map dimmed where it was shaded.+ if (geometry && u_cloudShadowPass < 0.5) { fragColor = src; return; }vec3 entry = rayStart(v_texCoord);vec3 dir = normalize(worldFromDepth(v_texCoord, 1.0) - entry);@@ -581,12 +556,14 @@ void main() {vec3 entryWorld = entry + u_renderOrigin.xyz;vec3 anchor = shadowed ? vec3(entryWorld.x, 0.0, entryWorld.z) / max(u_unitsPerKm, 1e-3) : vec3(0.0);vec3 windDrift = vec3(u_cloudDriftX, 0.0, u_cloudDriftZ) + anchor;- if (geometry) {- float lit;- if (!upsampledShadow(worldFromDepth(v_texCoord, depth), entry, lit)) {- lit = cloudShadowAt(worldFromDepth(v_texCoord, depth) + u_renderOrigin.xyz, entryWorld, sun, max(u_clouds, overcast * 0.95), overcast, windDrift - anchor);- }- fragColor = vec4(src.rgb * lit, src.a);+ if (u_cloudShadowPass > 0.5) {+ // A texel of the sun's cloud shadow map: a point on the ray through it, back in the world, and what of the sun is left there.+ // The pass covers the target, and this texel is found in the tile by the coordinates the sun's lookup reads it by.+ vec2 inTile = (v_texCoord - u_cloudShadowRect.xy) / u_cloudShadowRect.z;+ if (any(lessThan(inTile, vec2(0.0))) || any(greaterThan(inTile, vec2(1.0)))) discard;+ vec4 at = mat4(u_cloudShadowInv0, u_cloudShadowInv1, u_cloudShadowInv2, u_cloudShadowInv3) * vec4(inTile * 2.0 - 1.0, 0.5, 1.0);+ float lit = cloudShadowAt(at.xyz / at.w + u_renderOrigin.xyz, rayStart(vec2(0.5)) + u_renderOrigin.xyz, sun, max(u_clouds, overcast * 0.95), overcast, vec3(u_cloudDriftX, 0.0, u_cloudDriftZ));+ fragColor = vec4(1.0, 1.0, 1.0, clamp(lit, 0.0, 1.0));return;}@@ -792,49 +769,13 @@ fn upsampledClouds(uv : vec2f) -> CloudRead {return out;}-struct ShadowRead { ok : bool, lit : f32 };--/// The cloud shadow on a surface, read from the half-size pass: the surface texels among the four the pixel falls between, each weighted by how-/// near its point in the world is to this pixel's, so a texel across a silhouette does not lend its shadow. Not ok when none is near.-fn upsampledShadow(uv : vec2f, P : vec3f, entry : vec3f) -> ShadowRead {- var out : ShadowRead;- out.ok = false;- let dsize = vec2i(textureDimensions(t7, 0));- let hsize = vec2i(textureDimensions(t0, 0));- let hf = uv * vec2f(hsize) - 0.5;- let base = vec2i(floor(hf));- let fr = hf - vec2f(base);- let tol = max(0.08 * length(P - entry), 1e-4);- var sum = 0.0;- var wsum = 0.0;- for (var j : i32 = 0; j < 4; j = j + 1) {- let o = vec2i(j & 1, j >> 1);- let t = clamp(base + o, vec2i(0), hsize - vec2i(1));- let h = textureLoad(t0, t, 0);- if (h.a >= 0.0) { continue; }- let tuv = uvOfTexel(t, hsize);- let Pj = worldFromDepth(tuv, depthAt(screenTexel(tuv, dsize), dsize));- var bx = 1.0 - fr.x;- if (o.x == 1) { bx = fr.x; }- var by = 1.0 - fr.y;- if (o.y == 1) { by = fr.y; }- let w = bx * by * max(1.0 - length(Pj - P) / tol, 0.0);- sum = sum + h.r * w;- wsum = wsum + w;- }- if (wsum < UP_MIN_WEIGHT) { return out; }- out.ok = true;- out.lit = sum / wsum;- return out;-}-@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {let src = textureSampleLevel(t1, s1, v.v_texCoord, 0.0);let size = vec2i(textureDimensions(t7, 0));let depth = textureLoad(t7, clamp(vec2i(v.v_texCoord * vec2f(size)), vec2i(0), size - vec2i(1)), 0);let covered = mc.u_panorama <= 0.001;let geometry = (covered && depth < 1.0 && src.a > 0.999) || (!covered && depth < 1.0);- if (geometry && mc.u_cloudShadow <= 0.001) { return src; }+ if (geometry && mc.u_cloudShadowPass < 0.5) { return src; }let entry = rayStart(v.v_texCoord);var dir = normalize(worldFromDepth(v.v_texCoord, 1.0) - entry);@@ -859,11 +800,13 @@ fn upsampledShadow(uv : vec2f, P : vec3f, entry : vec3f) -> ShadowRead {var anchor = vec3f(0.0);if (mc.u_cloudShadow > 0.001) { anchor = vec3f(entryWorld.x, 0.0, entryWorld.z) / max(mc.u_unitsPerKm, 1e-3); }let windDrift = vec3f(mc.u_cloudDriftX, 0.0, mc.u_cloudDriftZ) + anchor;- if (geometry) {- var lit = 1.0;- let up = upsampledShadow(v.v_texCoord, worldFromDepth(v.v_texCoord, depth), entry);- if (up.ok) { lit = up.lit; } else { lit = cloudShadowAt(worldFromDepth(v.v_texCoord, depth) + frame.renderOrigin.xyz, entryWorld, sun, max(mc.u_clouds, overcast * 0.95), overcast, windDrift - anchor, v.pos.xy); }- return vec4f(src.rgb * lit, src.a);+ if (mc.u_cloudShadowPass > 0.5) {+ let inTile = (v.v_texCoord - mc.u_cloudShadowRect.xy) / mc.u_cloudShadowRect.z;+ if (any(inTile < vec2f(0.0)) || any(inTile > vec2f(1.0))) { discard; }+ let inv = mat4x4f(mc.u_cloudShadowInv0, mc.u_cloudShadowInv1, mc.u_cloudShadowInv2, mc.u_cloudShadowInv3);+ let at = inv * vec4f(inTile * 2.0 - 1.0, 0.5, 1.0);+ let lit = cloudShadowAt(at.xyz / at.w + frame.renderOrigin.xyz, rayStart(vec2f(0.5)) + frame.renderOrigin.xyz, sun, max(mc.u_clouds, overcast * 0.95), overcast, vec3f(mc.u_cloudDriftX, 0.0, mc.u_cloudDriftZ), v.pos.xy);+ return vec4f(1.0, 1.0, 1.0, clamp(lit, 0.0, 1.0));}let sdir = normalize(vec3f(dir.x, max(dir.y, 0.015), dir.z));@@ -1107,7 +1050,7 @@ void main() {bool geometry = covered ? (depth < 1.0 && src.a > 0.999) : depth < 1.0;// A texel stands for the pixels under it. A sky texel holds the cloud layer in front of it, colour * T + L, with T (never negative) in// the alpha; a surface texel holds the cloud shadow it lies in, its light in the red and minus that in the alpha.- if (geometry && u_cloudShadow <= 0.001) { fragColor = vec4(1.0, 0.0, 0.0, -1.0); return; }+ if (geometry) { fragColor = vec4(1.0, 0.0, 0.0, -1.0); return; }vec3 entry = rayStart(v_texCoord);vec3 dir = normalize(worldFromDepth(v_texCoord, 1.0) - entry);@@ -1135,11 +1078,6 @@ void main() {vec3 entryWorld = entry + u_renderOrigin.xyz;vec3 anchor = shadowed ? vec3(entryWorld.x, 0.0, entryWorld.z) / max(u_unitsPerKm, 1e-3) : vec3(0.0);vec3 windDrift = vec3(u_cloudDriftX, 0.0, u_cloudDriftZ) + anchor;- if (geometry) {- float lit = cloudShadowAt(worldFromDepth(v_texCoord, depth) + u_renderOrigin.xyz, entryWorld, sun, max(u_clouds, overcast * 0.95), overcast, windDrift - anchor);- fragColor = vec4(lit, 0.0, 0.0, -lit);- return;- }// The dome. Below the horizon there is no sky: the ray is flattened onto it so a camera that looks down sees the haze there.vec3 sdir = normalize(vec3(dir.x, max(dir.y, 0.015), dir.z));@@ -1283,10 +1221,6 @@ ${CLOUD_WGSL}var anchor = vec3f(0.0);if (mc.u_cloudShadow > 0.001) { anchor = vec3f(entryWorld.x, 0.0, entryWorld.z) / max(mc.u_unitsPerKm, 1e-3); }let windDrift = vec3f(mc.u_cloudDriftX, 0.0, mc.u_cloudDriftZ) + anchor;- if (geometry) {- let lit = cloudShadowAt(worldFromDepth(v.v_texCoord, depth) + frame.renderOrigin.xyz, entryWorld, sun, max(mc.u_clouds, overcast * 0.95), overcast, windDrift - anchor, v.pos.xy);- return vec4f(lit, 0.0, 0.0, -lit);- }let sdir = normalize(vec3f(dir.x, max(dir.y, 0.015), dir.z));let sc = scatter(sdir, sun, mc.u_altitude, haze);diff --git a/sdk/tests/custom-sky.test.ts b/sdk/tests/custom-sky.test.tsindex 07f318d11..58b123812 100644--- a/sdk/tests/custom-sky.test.ts+++ b/sdk/tests/custom-sky.test.ts@@ -27,15 +27,23 @@ describe('custom sky', () => {expect(src.match(/skyRadiance\(/g)!.length).toBeGreaterThanOrEqual(6);});- it('multiplies the surfaces it finds by the shadow the sky gives, at their world place, only when the sky has one', () => {+ it('draws the cloud shadow map of the sun from the shadow the sky gives, and leaves the surfaces as the scene lit them', () => {const sky = { type: 't', label: 'T', glsl: '', wgsl: '' };- expect(skyEffectSource(sky)).not.toContain('skyShadow');+ const without = skyEffectSource(sky);+ expect(without).not.toContain('skyShadow');+ expect(without).not.toContain('u_cloudShadowPass');const src = skyEffectSource({ ...sky, groundShadow: true });- expect(src).toContain('src.rgb * clamp(skyShadow(worldFromDepth(v_texCoord, depth) + u_renderOrigin.xyz, sun), 0.0, 1.0)');- expect(src).toContain('src.rgb * clamp(skyShadow(worldFromDepth(v.v_texCoord, depth) + frame.renderOrigin.xyz, sun), 0.0, 1.0)');- // The sun is found before the surface is left, in both languages.- expect(src.indexOf('findSun(lightDir')).toBeLessThan(src.indexOf('skyShadow('));- expect(src.indexOf('let found = findSun()')).toBeLessThan(src.lastIndexOf('skyShadow('));+ // Declares what the engine finds a caster by, and draws the map's texel in the alpha, in both languages.+ for (const param of ['u_castCloudShadows', 'u_cloudShadowExtentKm', 'u_cloudShadowPass', 'u_cloudShadowRect', 'u_cloudShadowInv3']) {+ expect(src).toContain(`#pragma param ${param} `);+ }+ expect(src).toContain('fragColor = vec4(1.0, 1.0, 1.0, clamp(skyShadow(at.xyz / at.w + u_renderOrigin.xyz, sun), 0.0, 1.0));');+ expect(src).toContain('return vec4f(1.0, 1.0, 1.0, clamp(skyShadow(at.xyz / at.w + frame.renderOrigin.xyz, sun), 0.0, 1.0));');+ // A surface is not multiplied by it any more: the sun's light was dimmed where the surface was shaded.+ expect(src).not.toContain('src.rgb * clamp(skyShadow(');+ // The sun is found before the map is drawn, in both languages.+ expect(src.indexOf('findSun(lightDir')).toBeLessThan(src.indexOf('skyShadow(at'));+ expect(src.indexOf('let found = findSun()')).toBeLessThan(src.lastIndexOf('skyShadow(at'));});it('registers an effect that can light the scene', () => {diff --git a/src/esengine/renderer/frame/PostProcessPipeline.cpp b/src/esengine/renderer/frame/PostProcessPipeline.cppindex 203822223..0c3329ad0 100644--- a/src/esengine/renderer/frame/PostProcessPipeline.cpp+++ b/src/esengine/renderer/frame/PostProcessPipeline.cpp@@ -209,6 +209,7 @@ void PostProcessPipeline::shutdown() {for (auto& pass : passes_) releasePassResources(pass);for (auto& pass : screenPasses_) releasePassResources(pass);releasePassResources(sky_capture_.copy);+ releasePassResources(cloud_shadow_copy_);sky_capture_.target.reset();sky_capture_.state = SkyCapture::State::Idle;for (auto& [source, program] : compute_cache_) device_.deleteCompute(program);@@ -723,6 +724,52 @@ void PostProcessPipeline::declareSkyCapture(const PostProcessPass& pass, rg::Resgraph_->addPass(std::move(node));}+const PostProcessPass* PostProcessPipeline::cloudShadowCaster(f32& extentKm, f32& unitsPerKm) const {+ for (const PostProcessPass& pass : passes_) {+ if (!pass.enabled) continue;+ const MaterialUniformLayout* layout = context_.materials().layoutFor(pass.shader);+ if (!layout || !layout->find("u_cloudShadowPass")) continue;+ // What the pass was set to, else what its shader declares.+ const auto value = [&](const char* name, f32 fallback) {+ if (auto it = pass.floatUniforms.find(name); it != pass.floatUniforms.end()) return it->second;+ if (const MaterialParamSlot* slot = layout->find(name)) return slot->defaults[0];+ return fallback;+ };+ if (value("u_castCloudShadows", 0.0f) < 0.5f) continue;+ if (layout->find("u_cloudShadow") && value("u_cloudShadow", 0.0f) <= 0.001f) continue;+ extentKm = std::max(value("u_cloudShadowExtentKm", 16.0f), 0.1f);+ unitsPerKm = layout->find("u_unitsPerKm") ? std::max(value("u_unitsPerKm", 0.0f), 0.0f) : 0.0f;+ return &pass;+ }+ return nullptr;+}++void PostProcessPipeline::drawCloudShadow(const glm::mat4& inverse, const glm::vec4& rect, const rg::PassContext& ctx) {+ f32 extentKm = 0.0f, unitsPerKm = 0.0f;+ const PostProcessPass* caster = cloudShadowCaster(extentKm, unitsPerKm);+ if (!caster) return;+ // The pass's shader and settings, its own parameter buffer kept, as the sky capture's copy is.+ const BufferHandle ubo = cloud_shadow_copy_.paramUbo;+ cloud_shadow_copy_ = *caster;+ cloud_shadow_copy_.paramUbo = ubo;+ cloud_shadow_copy_.name = caster->name + "_cloudShadow";+ cloud_shadow_copy_.temporal = false;+ cloud_shadow_copy_.feedback = false;+ cloud_shadow_copy_.earlierInputs.clear();+ cloud_shadow_copy_.floatUniforms["u_cloudShadowPass"] = 1.0f;+ for (int c = 0; c < 4; ++c) {+ cloud_shadow_copy_.vec4Uniforms["u_cloudShadowInv" + std::to_string(c)] = glm::vec4(inverse[c]);+ }+ cloud_shadow_copy_.vec4Uniforms["u_cloudShadowRect"] = rect;+ cloud_shadow_copy_.paramDirty = true;+ drawing_cloud_shadow_ = true;+ // Nothing of a scene on the input units either: the pass reads none, and the last bound may be a target of this frame's.+ device_.bindTexture(0, TextureHandle::Invalid);+ device_.bindTexture(1, TextureHandle::Invalid);+ renderPass(cloud_shadow_copy_, ctx);+ drawing_cloud_shadow_ = false;+}+void PostProcessPipeline::releasePassResources(PostProcessPass& pass) {if (pass.paramUbo != BufferHandle::Invalid) {device_.deleteBuffer(pass.paramUbo);@@ -961,7 +1008,12 @@ void PostProcessPipeline::renderPass(PostProcessPass& pass, const rg::PassContex// The block the scene was lit with, bound again: the passes between have no claim on its slot, but a// chain is not the place to find out. And the atlas on the unit the Lit shaders read it from.context_.lights().uploadAndBind();- if (shadow_texture_ != 0) device->bindTexture(SHADOW_MAP_TEXTURE_UNIT, TextureHandle{shadow_texture_});+ // Not while the atlas is the target being drawn: a texture read and written in one pass is no answer on GL and an error on WebGPU.+ if (drawing_cloud_shadow_) {+ device->bindTexture(SHADOW_MAP_TEXTURE_UNIT, context_.materials().builtinDefault(MaterialDefaultTexture::White));+ } else if (shadow_texture_ != 0) {+ device->bindTexture(SHADOW_MAP_TEXTURE_UNIT, TextureHandle{shadow_texture_});+ }}if (layout && layout->find("u_envParams")) {const LightConstants& lights = context_.lights().data();@@ -1031,10 +1083,11 @@ void PostProcessPipeline::renderPass(PostProcessPass& pass, const rg::PassContex// A target with no depth binds nothing, and an effect over a scene that// wrote none then finds no edge — the right answer for a flat one.- device->bindTexture(kSceneDepthUnit, graph_ ? graph_->depthTextureOf(sceneResource_)- : TextureHandle::Invalid);+ // Not while a cloud shadow is drawn before the scene: the id kept from the frame before can name the atlas being drawn into.+ const bool scene = graph_ && !drawing_cloud_shadow_;+ device->bindTexture(kSceneDepthUnit, scene ? graph_->depthTextureOf(sceneResource_) : TextureHandle::Invalid);// And the surface record, on the unit below it, on the same terms: nothing where the frame drew none.- device->bindTexture(kGBufferUnit, graph_ && scene_gbuffer_ ? graph_->gbufferTextureOf(sceneResource_)+ device->bindTexture(kGBufferUnit, scene && scene_gbuffer_ ? graph_->gbufferTextureOf(sceneResource_): TextureHandle::Invalid);// Texture params (LUTs, masks) bind at their reflected material units;@@ -1052,7 +1105,7 @@ void PostProcessPipeline::renderPass(PostProcessPass& pass, const rg::PassContexgpu = velocity_fbo_->getColorAttachment();}// The scene's albedo, beside its surface record: what bounce light an effect adds is coloured by.- if (slot.name == "u_sceneAlbedo" && graph_ && scene_gbuffer_) {+ if (slot.name == "u_sceneAlbedo" && graph_ && scene_gbuffer_ && !drawing_cloud_shadow_) {const TextureHandle albedo = graph_->albedoTextureOf(sceneResource_);if (albedo != TextureHandle::Invalid) gpu = albedo;}diff --git a/src/esengine/renderer/frame/PostProcessPipeline.hpp b/src/esengine/renderer/frame/PostProcessPipeline.hppindex a705bcf15..a3b234bbd 100644--- a/src/esengine/renderer/frame/PostProcessPipeline.hpp+++ b/src/esengine/renderer/frame/PostProcessPipeline.hpp@@ -615,6 +615,22 @@ public:/** @brief The captured pixels, RGBA8, rows bottom-up as every readback lands. Valid after poll answered 1. */const std::vector<u8>& skyCapturePixels() const { return sky_capture_.pixels; }+ /**+ * @brief The sky that casts the sun's cloud shadow this frame, how far its map reaches each way in kilometres, and how many world+ * units its kilometre is (its own `u_unitsPerKm` where it says, as Sky Atmosphere does; 0 where it leaves it to the project).+ * @details A pass whose shader declares `u_cloudShadowPass` (sdk postprocess/cloudShadowParams.ts) and has `u_castCloudShadows`+ * on, and, where it has a strength (Sky Atmosphere's `u_cloudShadow`), above nothing. Null when no enabled pass does.+ */+ const PostProcessPass* cloudShadowCaster(f32& extentKm, f32& unitsPerKm) const;+ /**+ * @brief Draws the caster's cloud shadow into the tile at @p rect of the bound target: what of the sun is left in the alpha, white above.+ * @details @p rect is the tile as the sun reads it (origin and side, in the target's texture coordinates), and @p inverse takes the+ * tile's corners (clip x and y, -1 to 1) back to the world. The pass covers the target and finds the tile by the same+ * coordinates the lookup uses, so the two agree on either backend whatever its viewport convention. Called from a graph pass+ * that writes the shadow atlas before the scene, so the atlas is not bound for reading while it is drawn.+ */+ void drawCloudShadow(const glm::mat4& inverse, const glm::vec4& rect, const rg::PassContext& ctx);+private:PostProcessPass* findPass(const std::string& name);/// The capture's node: the copy of @p pass drawn into the capture target. Declared in the chain so it runs with the@@ -764,6 +780,10 @@ private:std::vector<u8> pixels;};SkyCapture sky_capture_;+ /// The caster's pass as drawCloudShadow draws it: the same shader and settings, with the map's own params and parameter buffer.+ PostProcessPass cloud_shadow_copy_;+ /// While drawCloudShadow draws into the atlas: renderPass binds a white texture where it would bind the atlas.+ bool drawing_cloud_shadow_ = false;resource::ShaderHandle rgbmShader_;bool cover_active_ = false;glm::mat4 cover_matrix_{1.0f};diff --git a/src/esengine/renderer/frame/RenderFrame.cpp b/src/esengine/renderer/frame/RenderFrame.cppindex dc78e4746..a431e4759 100644--- a/src/esengine/renderer/frame/RenderFrame.cpp+++ b/src/esengine/renderer/frame/RenderFrame.cpp@@ -1673,6 +1673,7 @@ void RenderFrame::collectLights(ecs::Registry& registry) {LightStore& lights = context_.lights();lights.clear();shadow_casters_.clear();+ cloud_sun_slot_ = -1;light_cap_.clear();environment_texture_id_ = 0;sky_texture_id_ = 0;@@ -1891,6 +1892,15 @@ void RenderFrame::collectLights(ecs::Registry& registry) {caster.slot = slot;shadow_casters_.push_back(caster);}+ // The sun a sky's clouds shade is the first directional light, as the sky's own findSun takes it.+ const glm::vec4& pd = collected[slot].gpu.posDir;+ if (cloud_sun_slot_ < 0 && pd.z > 0.5f && pd.z < 1.5f) {+ const glm::vec3 aim(pd.x, pd.y, pd.w);+ if (glm::length(aim) > 1e-6f) {+ cloud_sun_slot_ = static_cast<i32>(slot);+ cloud_sun_aim_ = glm::normalize(aim);+ }+ }lights.addLight(collected[slot].gpu);}for (const CollectedLight& light : tiled) {@@ -2174,6 +2184,7 @@ void RenderFrame::buildShadowPlan(ecs::Registry& registry) {shadow_texture_id_ = 0;shadow_resource_ = rg::kNoResource;shadow_views_.clear();+ cloud_tile_ = -1;// Zeroed first, and the atlas given back: a tile that outlived its map would// shadow the scene against geometry from a frame that no longer exists.shadow_atlas_.reset();@@ -2184,7 +2195,16 @@ void RenderFrame::buildShadowPlan(ecs::Registry& registry) {ES_PROFILE_COUNTER("render.shadow.atlasBudget", shadow_atlas_size_);ES_PROFILE_COUNTER("render.shadow.atlasSize", 0);context_.lights().setShadowTiles(nullptr, nullptr, 0, glm::vec4(0.0f));- if (!in_frame_ || shadow_casters_.empty() || !device_.isDeviceUsable()) return;+ if (!in_frame_ || !device_.isDeviceUsable()) return;+ // How far the sun's cloud shadow map reaches each way, in world units: 0 where no sky casts one, or there is no sun to dim.+ f32 cloudExtent = 0.0f;+ if (cloud_sun_slot_ >= 0 && post_process_ && post_process_->isEngaged()) {+ f32 km = 0.0f, unitsPerKm = 0.0f;+ if (post_process_->cloudShadowCaster(km, unitsPerKm)) {+ cloudExtent = km * (unitsPerKm > 0.0f ? unitsPerKm : 1000.0f * world_units_per_meter_);+ }+ }+ if (shadow_casters_.empty() && cloudExtent <= 0.0f) return;const glm::mat4 invVP = glm::inverse(view_projection_);// Clip's z axis back in world: w != 0 is an eye point, w == 0 says the projection@@ -2262,6 +2282,12 @@ void RenderFrame::buildShadowPlan(ecs::Registry& registry) {if (at >= 0) plan[i] = {static_cast<u32>(at), grant.granted};shadow_plan_.grants.push_back(grant);}+ // The sun's cloud shadow, before its cascades: one tile for the whole of what the camera sees under the clouds, where a cascade+ // is the nearest stretch of it. With the atlas full a sun then gives up its farthest cascade, as it does for a light that stands somewhere.+ if (cloudExtent > 0.0f) {+ AtlasRefusal why = AtlasRefusal::None;+ cloud_tile_ = shadow_atlas_.allocate(1, 1, why);+ }for (usize i = 0; i < shadow_casters_.size(); ++i) {const ShadowCaster& caster = shadow_casters_[i];if (caster.shape != ShadowShape::Box) continue;@@ -2293,6 +2319,32 @@ void RenderFrame::buildShadowPlan(ecs::Registry& registry) {glm::mat4 matrices[MAX_SHADOW_TILES];glm::vec4 tiles[MAX_SHADOW_TILES];bool anyTile = false;+ if (cloud_tile_ >= 0) {+ // Along the sun's rays, round the camera, snapped to the map's own texels so the shadows do not crawl as the camera moves.+ // Every point on one ray is under the same cloud, so where along it the map stands does not matter: only x and y are read.+ const ShadowTile& tile = shadow_atlas_.tile(static_cast<u32>(cloud_tile_));+ const glm::vec3 toLight = -cloud_sun_aim_;+ const glm::vec3 up = shadowUp(toLight);+ const glm::mat4 lightRot = glm::lookAt(glm::vec3(0.0f), -toLight, up);+ const glm::mat4 lightRotInv = glm::inverse(lightRot);+ const glm::vec3 seen = perspective ? glm::vec3(eye) / eye.w : (corners[0] + corners[7]) * 0.5f;+ const f32 texel = (cloudExtent * 2.0f) / static_cast<f32>(tile.size);+ glm::vec3 inLight = glm::vec3(lightRot * glm::vec4(seen, 1.0f));+ inLight.x = std::floor(inLight.x / texel) * texel;+ inLight.y = std::floor(inLight.y / texel) * texel;+ const glm::vec3 centre = glm::vec3(lightRotInv * glm::vec4(inLight, 1.0f));+ const glm::mat4 lightView = glm::lookAt(centre + toLight * cloudExtent, centre, up);+ glm::mat4 lightProj(1.0f);+ lightProj[0][0] = 1.0f / cloudExtent;+ lightProj[1][1] = 1.0f / cloudExtent;+ lightProj[2][2] = -0.5f / cloudExtent;+ lightProj[3][2] = 0.0f;+ cloud_matrix_ = lightProj * lightView;+ matrices[cloud_tile_] = cloud_matrix_;+ tiles[cloud_tile_] = shadow_atlas_.unitRect(static_cast<u32>(cloud_tile_), atlasSize);+ context_.lights().setLightCloudTile(static_cast<u32>(cloud_sun_slot_), static_cast<u32>(cloud_tile_));+ anyTile = true;+ }for (usize ci = 0; ci < shadow_casters_.size(); ++ci) {const ShadowCaster& caster = shadow_casters_[ci];@@ -2493,6 +2545,17 @@ void RenderFrame::declareShadowPass(ecs::Registry& registry) {shadow.clearColor[3] = 1.0f;shadow.execute = [this, ®istry](const rg::PassContext&) { executeShadowPass(registry); };graph_.addPass(std::move(shadow));+ if (cloud_tile_ < 0 || !post_process_) return;+ // The sky draws what of the sun its clouds leave into the sun's tile, before the scene reads it: white above, that in the alpha.+ rg::PassDesc cloud;+ cloud.name = "cloud-shadow";+ cloud.write = shadow_resource_;+ cloud.keep = true;+ cloud.discardDepth = true;+ const glm::vec4 rect = shadow_atlas_.unitRect(static_cast<u32>(cloud_tile_), shadow_atlas_.occupiedSize());+ const glm::mat4 inverse = glm::inverse(cloud_matrix_);+ cloud.execute = [this, rect, inverse](const rg::PassContext& ctx) { post_process_->drawCloudShadow(inverse, rect, ctx); };+ graph_.addPass(std::move(cloud));}void RenderFrame::ensureShadowFrameUbos(u32 count) {diff --git a/src/esengine/renderer/frame/RenderFrame.hpp b/src/esengine/renderer/frame/RenderFrame.hppindex 0fc9b40bd..e5fef107a 100644--- a/src/esengine/renderer/frame/RenderFrame.hpp+++ b/src/esengine/renderer/frame/RenderFrame.hpp@@ -1014,6 +1014,14 @@ private:/// Every light that asked for a map this frame, in UBO slot order. Written by/// collectLights, read by buildShadowPlan; empty = nobody asked.std::vector<ShadowCaster> shadow_casters_;+ /// The directional light the sky's clouds shade (the first in slot order, which is the one a sky takes for its sun): its slot+ /// and the way its rays travel, as collectLights found it; slot -1 when the frame has none.+ i32 cloud_sun_slot_ = -1;+ glm::vec3 cloud_sun_aim_{0.0f, -1.0f, 0.0f};+ /// The atlas tile the sky draws the sun's cloud shadow into this frame, or -1, and the matrix it is drawn and read through:+ /// along the sun's rays, round the camera, as Unreal's cloud shadow map is.+ i32 cloud_tile_ = -1;+ glm::mat4 cloud_matrix_{1.0f};/// The frame's render targets, borrowed by shape and given back when the/// frame is done with them — shared with the post chains, which is what lets/// the atlas be a loan rather than a framebuffer held for the whole run.diff --git a/src/esengine/renderer/store/LightConstants.hpp b/src/esengine/renderer/store/LightConstants.hppindex 9d5ee05f0..72b60f93b 100644--- a/src/esengine/renderer/store/LightConstants.hpp+++ b/src/esengine/renderer/store/LightConstants.hpp@@ -110,8 +110,9 @@ struct GpuLight {glm::vec4 posDir{0.0f};/// rgb = colour, a = intensity.glm::vec4 color{0.0f};- /// Spot only, zero otherwise: xy = the cone axis in the plane, z = cos(inner half- /// angle), w = cos(outer half angle).+ /// Spot: xy = the cone axis in the plane, z = cos(inner half angle), w = cos(outer half angle).+ /// Directional: x = the atlas tile its cloud shadow is read from, plus one (0 = none; see+ /// RenderFrame's cloud shadow tile); the rest zero. Zero for a point light.glm::vec4 spot{0.0f};/// x = penumbra softness (the source's half-extent in world units; 0 = hard); y = a/// directional light's shadow march distance (0 = it casts none); z = a positionaldiff --git a/src/esengine/renderer/store/LightStore.hpp b/src/esengine/renderer/store/LightStore.hppindex 003bda883..81ca6eec4 100644--- a/src/esengine/renderer/store/LightStore.hpp+++ b/src/esengine/renderer/store/LightStore.hpp@@ -158,6 +158,13 @@ public:/// Names the atlas tiles light @p slot casts into. What lets a fragment read the/// right map once more than one light has rendered one; a slot nobody names keeps/// the zeroed count, which is a light with no map.+ /** @brief Says the directional light in @p slot reads the sky's cloud shadow from atlas tile @p tile (GpuLight::spot.x). */+ void setLightCloudTile(u32 slot, u32 tile) {+ if (slot >= count_) return;+ data_.lights[slot].spot.x = static_cast<f32>(tile + 1);+ dirty_ = true;+ }+void setLightShadowTiles(u32 slot, u32 first, u32 tiles) {if (slot >= count_) return;// The two the atlas decides, and nothing else: z is the light's own source size,diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 93c338e0e..8f2126ff6 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -1592,6 +1592,27 @@ const kSpiral32 = array<vec2f, 32>(// disc grains instead of banding. It bounds// the search too — a blocker outside it cannot widen an edge that cannot be drawn wider.const kShadowDisc = 24.0;+// What of the sun a sky's clouds leave at a world point. See the GLSL twin.+fn cloudShadow3D(worldPos : vec3f, t : i32) -> f32 {+#ifndef ES_RECEIVE_SHADOW+ return 1.0;+#else+ let uv = (lc.u_shadowMatrix[t] * vec4f(worldPos, 1.0)).xy * 0.5 + 0.5;+ if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) { return 1.0; }+ let rect = lc.u_shadowTile[t];+ let texel = lc.u_shadowParams.y;+ let p = (rect.xy + uv * rect.z) / texel - 0.5;+ let f = fract(p);+ let at = (floor(p) + 0.5) * texel;+ let lo = rect.xy + texel * 0.5;+ let hi = rect.xy + rect.z - texel * 0.5;+ let a = textureSampleLevel(t2, s2, clamp(at, lo, hi), 0.0).a;+ let b = textureSampleLevel(t2, s2, clamp(at + vec2f(texel, 0.0), lo, hi), 0.0).a;+ let c = textureSampleLevel(t2, s2, clamp(at + vec2f(0.0, texel), lo, hi), 0.0).a;+ let d = textureSampleLevel(t2, s2, clamp(at + vec2f(texel), lo, hi), 0.0).a;+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);+#endif+}fn shadowFactor3D(worldPos : vec3f, N : vec3f, L : vec3f, source : vec2f,first : i32, count : i32) -> f32 {#ifndef ES_RECEIVE_SHADOW@@ -2349,6 +2370,7 @@ fn shadeLight(pd : vec4f, col : vec4f, sp : vec4f, sh : vec4f, sm : vec4f, fo :if (dot(pd.xy, pd.xy) > 1e-8) { toLight = normalize(-pd.xy); }castShadow = sh.y > 0.0 && dot(toLight, toLight) > 0.5;aim = worldPos.xy + toLight * sh.y;+ if (sp.x > 0.5) { atten = atten * cloudShadow3D(worldPos, i32(sp.x) - 1); }} else {let toL = lightVector(pd, sh, worldPos);let dist = lightDistance(toL);@@ -3177,6 +3199,28 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" vec2(0.8499090, 0.4466874),\n"" vec2(-0.9440344, 0.2488453),\n"" vec2(0.5365950, -0.8345303));\n"+ // What of the sun a sky's clouds leave at a world point, from the tile the sky drew it into before the scene (RenderFrame's cloud+ // shadow tile): its alpha, between texels, as the map is coarse and its texels are nearest-sampled. Outside the square, all of it.+ "highp float cloudShadow3D(in highp vec3 worldPos, in int t) {\n"+ "#ifndef ES_RECEIVE_SHADOW\n"+ " return 1.0;\n"+ "#else\n"+ " highp vec2 uv = (u_shadowMatrix[t] * vec4(worldPos, 1.0)).xy * 0.5 + 0.5;\n"+ " if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) return 1.0;\n"+ " highp vec4 rect = u_shadowTile[t];\n"+ " highp float texel = u_shadowParams.y;\n"+ " highp vec2 p = (rect.xy + uv * rect.z) / texel - 0.5;\n"+ " highp vec2 f = fract(p);\n"+ " highp vec2 at = (floor(p) + 0.5) * texel;\n"+ " highp vec2 lo = rect.xy + texel * 0.5;\n"+ " highp vec2 hi = rect.xy + rect.z - texel * 0.5;\n"+ " highp float a = textureLod(u_shadowMap, clamp(at, lo, hi), 0.0).a;\n"+ " highp float b = textureLod(u_shadowMap, clamp(at + vec2(texel, 0.0), lo, hi), 0.0).a;\n"+ " highp float c = textureLod(u_shadowMap, clamp(at + vec2(0.0, texel), lo, hi), 0.0).a;\n"+ " highp float d = textureLod(u_shadowMap, clamp(at + vec2(texel), lo, hi), 0.0).a;\n"+ " return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n"+ "#endif\n"+ "}\n"// Visibility of a world point from the light that rendered the map. Depth is// written and compared through the SAME matrix and expression, so the two// backends' clip-z conventions cancel. 2x2 taps: one is a staircase.@@ -4005,6 +4049,8 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& p" highp vec2 toLight = (dot(pd.xy, pd.xy) > 1e-8) ? normalize(-pd.xy) : vec2(0.0);\n"" castShadow = sh.y > 0.0 && dot(toLight, toLight) > 0.5;\n"" target = worldPos.xy + toLight * sh.y;\n"+ // The sky's cloud shadow on the sun, where a sky casts one: x is its tile plus one (a directional light has no cone).+ " if (sp.x > 0.5) atten *= cloudShadow3D(worldPos, int(sp.x) - 1);\n"" } else {\n"" highp vec3 toL = lightVector(pd, sh, worldPos);\n"" highp float dist = lightDistance(toL);\n"diff --git a/tools/oracle/sky.mjs b/tools/oracle/sky.mjsindex 87559a509..7333b7989 100644--- a/tools/oracle/sky.mjs+++ b/tools/oracle/sky.mjs@@ -136,31 +136,33 @@ function skyDome({ id, elevation, azimuth, pitch, yaw, haze = 1, intensity = 0.5/**- * Cloud shadows on a floor. The shader places the cloud layer by the camera's altitude (`u_altitude`, km) and the floor's drop below- * the eye, so where the slab stands against the floor is arithmetic: floor altitude = u_altitude - drop / u_unitsPerKm. A slab wholly- * BELOW the floor casts nothing on it (lit = 1 exactly), and a dense one above it (overcast, so the coverage is all but total) leaves- * `1 - 0.8` of the light: the shader's strongest shadow. Noise decides where the gaps are, so the shadowed floor is checked loosely.- * The same two cases run under an orthographic camera and a perspective one: the answer is the floor's, not the projection's.+ * Cloud shadows on a floor. The slab stands by `u_altitude` (km) and the floor's drop below the eye: floor altitude = u_altitude - drop /+ * u_unitsPerKm. Below the floor it casts nothing; a dense one above (overcast) leaves a fifth of the SUN's light, loosely (noise makes gaps).+ * A floor nothing lights (its own colour, as an emissive surface) keeps that colour under it. Each case runs under both kinds of camera.*/-function cloudShadow({ id, ortho, altitude, shadowed }) {- const HEIGHT = 400, FLOOR_TOP = 5, UNITS_PER_KM = 1000;+function cloudShadow({ id, ortho, altitude, shadowed, lit = true }) {+ const HEIGHT = 400, FLOOR_TOP = 5, UNITS_PER_KM = 1000, ALBEDO = 0.8;+ const aim = sunAim(40, 40);const doc = scene(id, () => [camera(ortho ? {} : { projectionType: 0, fov: 40, nearPlane: 1, farPlane: 2000 }),- mesh('Floor', 'cube', [0, 0, 0], [1.8, 0.1, 1.8], [0.8, 0.8, 0.8], { lit: false }),+ mesh('Floor', 'cube', [0, 0, 0], [1.8, 0.1, 1.8], [ALBEDO, ALBEDO, ALBEDO], { lit }),+ ...(lit ? [sun(aim, 1)] : []),volume([{ type: 'skyAtmosphere', enabled: true, uniforms: { u_clouds: 1, u_overcast: 1, u_cloudShadow: 1, u_unitsPerKm: UNITS_PER_KM, u_sunElevation: 40, u_sunAzimuth: 40, u_altitude: altitude, u_windSpeed: 0 } }]),]);const floorAltitude = altitude - (HEIGHT - FLOOR_TOP) / UNITS_PER_KM;const grid = [-60, -20, 20, 60];- const half = ortho ? null : (HEIGHT - FLOOR_TOP) * Math.tan((40 * Math.PI) / 360);+ const open = lit ? ALBEDO * Math.max(0, aim.toLight[1]) : ALBEDO;const expect = [];for (const x of grid) {for (const z of grid) {const p = ortho ? probe(x, z) : probeFrom(x, z, HEIGHT - FLOOR_TOP, 40);- // Unshadowed: the floor's own colour. Shadowed: 20% of it, give or take the gaps in the clouds.- expect.push({ x: p.x, y: p.y, rgb: encodeLinear8(shadowed ? [0.16, 0.16, 0.16] : [0.8, 0.8, 0.8]), tol: shadowed ? 40 : 3 });+ // Unshadowed, or not lit by the sun: what the floor is with no cloud. Shadowed and sunlit: 20% of that, give or take the gaps.+ const v = shadowed && lit ? open * 0.2 : open;+ expect.push({ x: p.x, y: p.y, rgb: encodeLinear8([v, v, v]), tol: shadowed && lit ? 40 : 3 });}}- return { id, doc, colorSpace: 'linear', expect, floorAltitude, about: `Cloud shadow, ${ortho ? 'orthographic' : 'perspective'} camera, slab ${shadowed ? 'above' : 'below'} the floor` };+ return { id, doc, colorSpace: 'linear', expect, floorAltitude,+ about: `Cloud shadow on the sun, ${ortho ? 'orthographic' : 'perspective'} camera, slab ${shadowed ? 'above' : 'below'} the floor${lit ? '' : ', a floor the sun does not light'}` };}@@ -214,6 +216,9 @@ export const SKY_SCENES = [cloudShadow({ id: 'oracle-cloud-shadow-clear-perspective', ortho: false, altitude: 5, shadowed: false }),cloudShadow({ id: 'oracle-cloud-shadow-under-ortho', ortho: true, altitude: 2.2, shadowed: true }),cloudShadow({ id: 'oracle-cloud-shadow-under-perspective', ortho: false, altitude: 2.2, shadowed: true }),+ // Under the same slab, a floor nothing lights: a cloud dims the sun, not what a surface gives off.+ cloudShadow({ id: 'oracle-cloud-shadow-unlit-ortho', ortho: true, altitude: 2.2, shadowed: true, lit: false }),+ cloudShadow({ id: 'oracle-cloud-shadow-unlit-perspective', ortho: false, altitude: 2.2, shadowed: true, lit: false }),// The sun is 50 degrees up toward yaw 20; the camera looks 40 up toward it, so the lobe is on screen 10 degrees above the middle.customSky({ id: 'oracle-custom-sky-perspective', ortho: false, pitch: 40, yaw: 20, sunPitch: 50, sunYaw: 200 }),customSky({ id: 'oracle-custom-sky-ortho', ortho: true, pitch: 40, yaw: 20, sunPitch: 50, sunYaw: 200 }),diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex e361fb56c..d7af27a22 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4716,6 +4716,8 @@ export const NOTED = {{"note": "Baking a water region no longer holds the frame."},"perf(streaming): a layer of chunks with nothing left to make is not walked - every cell in reach was keyed, measured and asked each frame, 9 ms for six fields of plants with the camera standing; the walk is kept while its sources stand and skipped once every chunk is made":{"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."},"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":