Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(water): water casts no shadow, a lake holds a river that runs into it, and the surf's slope fades on the ridge between shores

yhhb678be6a2add
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aff9af1f1..9a6116c81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@ published separately; it ships inside the editor.
### Fixed
+- **A river runs into a lake cleanly, and water casts no shadow.** A river whose spline ran on into a lake drew a bright seam across the lake's bed: the surface was drawn into the sun's shadow map, darkening everything under it but where the river's heights changed its shape. Water no longer stands in the light's way (`MeshRenderer.castShadows`, new and on by default, says whether a mesh does), a lake now holds the water over a river that runs into it, and the surf's slope fades out on the ridge between two shores instead of flipping on a line.
- **Rain and storms on water.** Rain no longer drops dips into the zone's ripples (which twitched and left blotches of foam under a storm): drops ring out on the surface in the Water shader, as fine rings that spread and die, the more the harder it rains, with no foam. The wind's ripples are six short waves around its heading instead of drifting noise, so a lake no longer shows cells of light and dark. A weather raises waves as far as the water is open to the wind (the sea whole, a lake by its width, a river hardly at all), and surf is swell from open water, so a lake's shore laps in a storm instead of breaking like the sea's; what floats rides the same water.
- **Shadows follow what the camera draws.** A mesh the camera's level of detail culls (grass past its draw distance) no longer casts a shadow, and one drawn coarse casts coarse; seen from high up, a field of grass no longer laid an unseen square of shadow on the ground. The terrain's vertices slide between levels by the eye the ground was chosen for in every pass, so a shadow's ground is the ground that is seen, under an orthographic camera too.
- **Ridged ground without end has no steps.** Infinite noise ground that was both ridged and worn broke into terraces with sheer walls where a ridge's fold turned; the crest is now rounded over a few hundredths, so the ground is continuous.
diff --git a/docs/astro/src/content/docs/graphics/water.mdx b/docs/astro/src/content/docs/graphics/water.mdx
index 1c0de6c7a..9c03a17a2 100644
--- a/docs/astro/src/content/docs/graphics/water.mdx
+++ b/docs/astro/src/content/docs/graphics/water.mdx
@@ -111,7 +111,9 @@ An ocean takes its shore from the terrain the same way: inside the zone it is cu
of depth. It is the open sea, which lies past the zone's edge: low ground is sea only where low ground joins it to that edge, so a hollow below the sea's level
walled off by higher ground stays dry (or holds a lake of its own, at its own level). Past the zone it is everywhere at its level with its waves whole.
-Where bodies overlap, a lake or a river holds the water over the ocean, and which body a place belongs to does not depend on the order the bodies were added.
+Where bodies overlap, a lake holds the water over a river (a river that runs into a lake is the lake there, at the lake's level, its current fading
+into the still water) and both over the ocean; which body a place belongs to does not depend on the order the bodies were added. The surface casts no
+shadow: the sun lights what is under it, through the caustics.
### Basins and drainage
diff --git a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx b/docs/astro/src/content/docs/zh-cn/graphics/water.mdx
index ec2e46e52..a635953ef 100644
--- a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx
+++ b/docs/astro/src/content/docs/zh-cn/graphics/water.mdx
@@ -74,7 +74,7 @@ description: 若干 WaterBody 组件说明海洋、湖泊或河流在哪里,一
海洋也同样从地形取岸线:在区域内,地面高出海平面的地方被裁掉,波浪在 `shoreWidth` 的水深内变平静。它是区域边缘之外的开阔海:低地只有通过低地连到那条边缘时才是海,所以被更高地面围住、低于海平面的洼地保持干燥(或者装着自己水位的湖)。在区域外,海洋处处在它的水位上,波浪完整。
-水体重叠时,湖泊或河流优先于海洋占有那里的水;一个地方属于哪个水体,与水体加入的顺序无关。
+水体重叠时,湖泊优先于河流(汇入湖泊的河在湖里就是湖,取湖的水位,水流在静水中逐渐消失),两者都优先于海洋;一个地方属于哪个水体,与水体加入的顺序无关。水面不投射阴影:阳光穿过水面照亮水下,由焦散表现。
### 盆地与汇流
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index e411fdb95..a2809e8f4 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -2617,6 +2617,12 @@
"default": "false",
"doc": "Receive 2D lights: Light entities light this mesh (flat normal). A custom material overrides this."
},
+ {
+ "key": "castShadows",
+ "type": "boolean",
+ "default": "true",
+ "doc": "Cast shadows: whether this mesh blocks the light. Water and other surfaces light passes through say no."
+ },
{
"key": "parallax",
"type": "Vec2",
@@ -5265,7 +5271,7 @@
"key": "provider",
"type": "string",
"default": "\"estella:noise\"",
- "doc": "The generator ground without end is made by: estella:noise, or one the game registers. The same provider, world, seed and version are the same ground on every machine."
+ "doc": "The generator the ground is made by, without end or (with no heightmap) in an area: estella:noise, or one the game registers. The same provider, world, seed and version are the same ground on every machine, and two areas side by side join."
},
{
"key": "world",
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index a2773f775..2072466b6 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -5,7 +5,7 @@ Symbols: 115 public · 159 beta · 1830 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"7403dd8de628613e"
+"7cf803aca319cd32"
```
## ANCHOR_AXES — const @experimental
@@ -5681,6 +5681,7 @@ static prototype: MeshRendererAPI
## MeshRendererData — interface @experimental
```
+castShadows: boolean
color: Color
cullBackfaces: boolean
enabled: boolean
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 7afdece97..87baa0230 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -5,7 +5,7 @@ Symbols: 115 public · 164 beta · 1849 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"7403dd8de628613e"
+"7cf803aca319cd32"
```
## ANCHOR_AXES — const @experimental
@@ -5694,6 +5694,7 @@ static prototype: MeshRendererAPI
## MeshRendererData — interface @experimental
```
+castShadows: boolean
color: Color
cullBackfaces: boolean
enabled: boolean
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index d15b73f39..dba18518b 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -5676,6 +5676,7 @@ static prototype: MeshRendererAPI
## MeshRendererData — interface @experimental
```
+castShadows: boolean
color: Color
cullBackfaces: boolean
enabled: boolean
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 3f8531305..0c38b8292 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -5676,6 +5676,7 @@ static prototype: MeshRendererAPI
## MeshRendererData — interface @experimental
```
+castShadows: boolean
color: Color
cullBackfaces: boolean
enabled: boolean
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 947ce0310..bda408a5c 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -5683,6 +5683,7 @@ static prototype: MeshRendererAPI
## MeshRendererData — interface @experimental
```
+castShadows: boolean
color: Color
cullBackfaces: boolean
enabled: boolean
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index ec53733f5..70a252372 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -1029,6 +1029,7 @@ export interface MeshRendererPtrData {
opaque: boolean;
cullBackfaces: boolean;
lit: boolean;
+ castShadows: boolean;
parallax: Vec2;
material: number;
enabled: boolean;
@@ -1046,6 +1047,7 @@ export function fillMeshRenderer(
out.opaque = u8[ptr + 28] !== 0;
out.cullBackfaces = u8[ptr + 29] !== 0;
out.lit = u8[ptr + 30] !== 0;
+ out.castShadows = u8[ptr + 31] !== 0;
const parallax_ = out.parallax; parallax_.x = f32[(ptr + 32) >> 2]; parallax_.y = f32[((ptr + 32) >> 2) + 1];
out.material = u32[(ptr + 40) >> 2];
out.enabled = u8[ptr + 44] !== 0;
@@ -1063,6 +1065,7 @@ export function writeMeshRenderer(
u8[ptr + 28] = data.opaque ? 1 : 0;
u8[ptr + 29] = data.cullBackfaces ? 1 : 0;
u8[ptr + 30] = data.lit ? 1 : 0;
+ u8[ptr + 31] = data.castShadows ? 1 : 0;
f32[(ptr + 32) >> 2] = data.parallax.x; f32[((ptr + 32) >> 2) + 1] = data.parallax.y;
u32[(ptr + 40) >> 2] = data.material;
u8[ptr + 44] = data.enabled ? 1 : 0;
@@ -1078,6 +1081,7 @@ export function createMeshRendererData(): MeshRendererPtrData {
opaque: false,
cullBackfaces: false,
lit: false,
+ castShadows: false,
parallax: { x: 0, y: 0 },
material: 0,
enabled: false,
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index 667f72dce..839a52ed4 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 = '7403dd8de628613e';
+export const ABI_LAYOUT_HASH = '7cf803aca319cd32';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -589,6 +589,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
opaque: false,
cullBackfaces: false,
lit: false,
+ castShadows: true,
parallax: { x: 1, y: 1 },
material: 0,
enabled: true,
@@ -606,6 +607,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
opaque: { tooltip: "Opaque: no blending; writes and tests depth, so meshes occlude each other." },
cullBackfaces: { tooltip: "Cull back faces: triangles facing away from the camera are skipped." },
lit: { tooltip: "Receive 2D lights: Light entities light this mesh (flat normal). A custom material overrides this." },
+ castShadows: { tooltip: "Cast shadows: whether this mesh blocks the light. Water and other surfaces light passes through say no." },
parallax: { tooltip: "Parallax scroll factor (1 = with world, <1 = slower, 0 = locked to camera).", advanced: true },
material: { advanced: true },
},
@@ -1597,6 +1599,7 @@ export interface MeshRendererData {
opaque: boolean;
cullBackfaces: boolean;
lit: boolean;
+ castShadows: boolean;
parallax: Vec2;
material: number;
enabled: boolean;
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index 5c6052fd1..5bd56d734 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -290,6 +290,7 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ name: 'opaque', type: 'bool', offset: 28 },
{ name: 'cullBackfaces', type: 'bool', offset: 29 },
{ name: 'lit', type: 'bool', offset: 30 },
+ { name: 'castShadows', type: 'bool', offset: 31 },
{ name: 'parallax', type: 'vec2', offset: 32 },
{ name: 'material', type: 'u32', offset: 40 },
{ name: 'enabled', type: 'bool', offset: 44 },
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 483aac083..b01a93e7a 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -664,6 +664,7 @@ export interface MeshRenderer {
opaque: boolean;
cullBackfaces: boolean;
lit: boolean;
+ castShadows: boolean;
parallax: Vec2;
material: number;
enabled: boolean;
diff --git a/sdk/src/water/waterPlugin.ts b/sdk/src/water/waterPlugin.ts
index e5f4a1abd..d91cbcdb8 100644
--- a/sdk/src/water/waterPlugin.ts
+++ b/sdk/src/water/waterPlugin.ts
@@ -551,7 +551,8 @@ export class WaterPlugin implements Plugin {
const entity = app.world.spawn('Water');
app.world.insert(entity, Transform, { position: { x: 0, y: 0, z: 0 } });
app.world.insert(entity, MeshRenderer, {
- mesh, material: instance, lit: true, opaque: false, cullBackfaces: false, color: { r: 1, g: 1, b: 1, a: 1 },
+ // Light goes through water: the sun lights what is under it, through the caustics, and no shadow of the surface.
+ mesh, material: instance, lit: true, opaque: false, cullBackfaces: false, castShadows: false, color: { r: 1, g: 1, b: 1, a: 1 },
} as Partial<MeshRendererData>);
s.entity = entity;
} catch (e) {
diff --git a/sdk/src/water/waterShader.ts b/sdk/src/water/waterShader.ts
index 1309ac5a8..e7ce4ad31 100644
--- a/sdk/src/water/waterShader.ts
+++ b/sdk/src/water/waterShader.ts
@@ -514,6 +514,9 @@ void main() {
float surfStep = max(u_zoneSize.x / float(textureSize(u_zoneField, 0).x), 1e-3);
vec2 toSea = vec2(waterZoneField(wp + vec2(surfStep, 0.0)).x - waterZoneField(wp - vec2(surfStep, 0.0)).x,
waterZoneField(wp + vec2(0.0, surfStep)).x - waterZoneField(wp - vec2(0.0, surfStep)).x) / (2.0 * surfStep);
+ // A distance to the shore climbs one unit a unit everywhere but on the ridge between two shores, where it turns back: there the way to
+ // the shore is no one way, and the surf's slope fades out rather than flipping on a line.
+ toSea *= smoothstep(0.55, 0.9, length(toSea));
vec2 surf = waterSurf(shoreDist, surfH, time);
float surfRise = (waterSurf(shoreDist + surfStep * 0.5, surfH, time).x - waterSurf(shoreDist - surfStep * 0.5, surfH, time).x) / surfStep;
// The ripples at this pixel: their height on four sides gives the slope they add, and the foam is what they left (reads taken before any branch).
@@ -931,8 +934,9 @@ fn waterSurface(p : vec2f, time : f32, dist : f32, amp : f32, calm : f32) -> vec
var surfH = 0.0;
if (zoneOn) { surfH = mc.u_surfHeight * mc.u_waveHeight * zone.z * zone.w * still; }
let surfStep = max(mc.u_zoneSize.x / f32(textureDimensions(u_zoneField, 0).x), 1e-3);
- let toSea = vec2f(waterZoneField(wp + vec2f(surfStep, 0.0)).x - waterZoneField(wp - vec2f(surfStep, 0.0)).x,
- waterZoneField(wp + vec2f(0.0, surfStep)).x - waterZoneField(wp - vec2f(0.0, surfStep)).x) / (2.0 * surfStep);
+ let toSeaRaw = vec2f(waterZoneField(wp + vec2f(surfStep, 0.0)).x - waterZoneField(wp - vec2f(surfStep, 0.0)).x,
+ waterZoneField(wp + vec2f(0.0, surfStep)).x - waterZoneField(wp - vec2f(0.0, surfStep)).x) / (2.0 * surfStep);
+ let toSea = toSeaRaw * smoothstep(0.55, 0.9, length(toSeaRaw));
let surf = waterSurf(shoreDist, surfH, time);
let surfRise = (waterSurf(shoreDist + surfStep * 0.5, surfH, time).x - waterSurf(shoreDist - surfStep * 0.5, surfH, time).x) / surfStep;
// The ripples at this pixel: their height on four sides gives the slope they add, and the foam is what they left (taken in uniform control flow).
diff --git a/sdk/src/water/zone.ts b/sdk/src/water/zone.ts
index 1a71dd2b8..0ecc6575b 100644
--- a/sdk/src/water/zone.ts
+++ b/sdk/src/water/zone.ts
@@ -184,7 +184,7 @@ export class WaterField {
/**
* Bakes `bodies` over `grid`. Each texel takes every body's say (its height, its distance to its own shore, its waves and current) and
* weighs them by how far inside each it is, over a texel and a half, so where two bodies meet the values run from one to the other.
- * The lakes and rivers come first; the ocean has what they leave. A texel no body holds keeps the height of the nearest water, so the
+ * The lakes come first, then the rivers have what they leave (a river runs into a lake and is the lake there), and the ocean what both leave. A texel no body holds keeps the height of the nearest water, so the
* surface's vertices there (which the shore cuts away) do not pull the water's edge down to nothing.
*/
static bake(grid: ZoneGrid, bodies: readonly ZoneBody[], ground?: ZoneGround): WaterField {
@@ -201,7 +201,8 @@ export class WaterField {
const field = new WaterField(grid, ocean);
const texel = Math.max(grid.sizeX / Math.max(grid.nx - 1, 1), grid.sizeZ / Math.max(grid.nz - 1, 1));
const blend = texel * 1.5;
- const bounded = bodies.filter((b) => b.kind !== 'ocean') as (ZoneLake | ZoneRiver)[];
+ // Lakes before rivers: a river that runs into a lake is the lake's there, as both are the ocean's betters.
+ const bounded = [...bodies.filter((b) => b.kind === 'lake'), ...bodies.filter((b) => b.kind === 'river')] as (ZoneLake | ZoneRiver)[];
const boxes = bounded.map((b) => boundsOf(b));
const grounds = new Float64Array(grid.nx * grid.nz).fill(Number.NaN);
for (let j = 0; j < grid.nz; j++) {
@@ -220,14 +221,16 @@ export class WaterField {
const x = grid.minX + (i / Math.max(grid.nx - 1, 1)) * grid.sizeX;
const z = grid.minZ + (j / Math.max(grid.nz - 1, 1)) * grid.sizeZ;
const g = Number.isNaN(grounds[k]!) ? null : grounds[k]!;
- let w = 0, h = 0, a = 0, c = 0, sw = 0, ex = 0, fx = 0, fz = 0, best = -Infinity, owner = -1, ownerW = 0, held = 0;
+ let w = 0, h = 0, a = 0, c = 0, sw = 0, ex = 0, fx = 0, fz = 0, best = -Infinity, owner = -1, ownerW = 0, held = 0, lakeHeld = 0;
for (let b = 0; b < bounded.length; b++) {
const box = boxes[b]!;
if (x < box[0] - blend || x > box[2] + blend || z < box[1] - blend || z > box[3] + blend) continue;
const say = sayOf(bounded[b]!, x, z, g);
if (!say) continue;
best = Math.max(best, say.shore);
- const weight = smooth(-blend, blend, say.shore);
+ const inside = smooth(-blend, blend, say.shore);
+ const weight = bounded[b]!.kind === 'river' ? inside * (1 - lakeHeld) : inside;
+ if (bounded[b]!.kind === 'lake') lakeHeld = Math.max(lakeHeld, inside);
if (weight <= 0) continue;
held = Math.max(held, weight);
w += weight; h += say.height * weight; a += say.amp * weight; c += say.calm * weight; sw += bounded[b]!.waveHeight * weight; fx += say.fx * weight; fz += say.fz * weight;
diff --git a/sdk/tests/water-bodies.test.ts b/sdk/tests/water-bodies.test.ts
index ee482c7ed..c5514de92 100644
--- a/sdk/tests/water-bodies.test.ts
+++ b/sdk/tests/water-bodies.test.ts
@@ -74,6 +74,21 @@ describe('a lake', () => {
});
});
+describe('a river that runs into a lake', () => {
+ it('is the lake\'s water inside the lake, at the lake\'s level, and its own outside it', () => {
+ const stations = [];
+ for (let x = -90; x <= 10; x += 1) stations.push({ x, z: 0, y: -3, half: 3, dx: 1, dz: 0, speed: 2 });
+ const river = { kind: 'river' as const, key: 2, waveHeight: 0.2, shoreWidth: 1, stations };
+ const field = WaterField.bake(grid, [river, lakeAt(20, 0, 30, 0)]);
+ // Well inside the lake, on the river's course: no trench where the river's lower surface would be.
+ expect(field.sample(20, 0)!.key).toBe(1);
+ expect(field.sample(20, 0)!.height).toBeCloseTo(0, 3);
+ expect(Math.hypot(field.sample(20, 0)!.flowX, field.sample(20, 0)!.flowZ)).toBeLessThan(1e-3);
+ expect(field.sample(-60, 0)!.key).toBe(2);
+ expect(field.sample(-60, 0)!.height).toBeCloseTo(-3, 3);
+ });
+});
+
describe('basins and drainage', () => {
it('finds each hollow, filled to where it runs over, and where that is', () => {
const map = findBasins(grid, island, { minDepth: 0.5 });
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 7ace135c7..430837071 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 3a4ef4999092f3eb
+ * @schema_hash 000c86a1b1333822
*/
-#define ES_EDITOR_API_SCHEMA_HASH "3a4ef4999092f3eb"
+#define ES_EDITOR_API_SCHEMA_HASH "000c86a1b1333822"
#include <emscripten/bind.h>
#include <string>
@@ -407,6 +407,7 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"opaque","type":"bool","group":"MeshRenderer"},
{"key":"cullBackfaces","type":"bool","group":"MeshRenderer"},
{"key":"lit","type":"bool","group":"MeshRenderer"},
+ {"key":"castShadows","type":"bool","group":"MeshRenderer"},
{"key":"parallax.x","type":"float","group":"MeshRenderer"},
{"key":"parallax.y","type":"float","group":"MeshRenderer"},
{"key":"material","type":"asset","group":"MeshRenderer"},
@@ -2980,6 +2981,7 @@ bool editor_setBool(Registry& reg, u32 e, const std::string& comp, const std::st
if (field == "opaque") { c.opaque = value; }
else if (field == "cullBackfaces") { c.cullBackfaces = value; }
else if (field == "lit") { c.lit = value; }
+ else if (field == "castShadows") { c.castShadows = value; }
else if (field == "enabled") { c.enabled = value; }
else { return false; }
return true;
@@ -3245,6 +3247,7 @@ bool editor_getBool(Registry& reg, u32 e, const std::string& comp, const std::st
if (field == "opaque") { return c.opaque; }
else if (field == "cullBackfaces") { return c.cullBackfaces; }
else if (field == "lit") { return c.lit; }
+ else if (field == "castShadows") { return c.castShadows; }
else if (field == "enabled") { return c.enabled; }
} else if (comp == "Occluder") {
if (!reg.has<esengine::ecs::Occluder>(entity)) return false;
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index b3f2d1c62..be290925f 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -797,6 +797,7 @@ struct MeshRendererJS {
bool opaque;
bool cullBackfaces;
bool lit;
+ bool castShadows;
glm::vec2 parallax;
u32 material;
bool enabled;
@@ -811,6 +812,7 @@ void meshrendererApplyJS(esengine::ecs::MeshRenderer& c, const MeshRendererJS& j
c.opaque = js.opaque;
c.cullBackfaces = js.cullBackfaces;
c.lit = js.lit;
+ c.castShadows = js.castShadows;
c.parallax = js.parallax;
c.material = js.material;
c.enabled = js.enabled;
@@ -832,6 +834,7 @@ MeshRendererJS meshrendererToJS(const esengine::ecs::MeshRenderer& c) {
js.opaque = c.opaque;
js.cullBackfaces = c.cullBackfaces;
js.lit = c.lit;
+ js.castShadows = c.castShadows;
js.parallax = c.parallax;
js.material = c.material;
js.enabled = c.enabled;
@@ -1957,6 +1960,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("opaque", &MeshRendererJS::opaque)
.field("cullBackfaces", &MeshRendererJS::cullBackfaces)
.field("lit", &MeshRendererJS::lit)
+ .field("castShadows", &MeshRendererJS::castShadows)
.field("parallax", &MeshRendererJS::parallax)
.field("material", &MeshRendererJS::material)
.field("enabled", &MeshRendererJS::enabled)
@@ -3810,6 +3814,7 @@ static_assert(offsetof(esengine::ecs::MeshRenderer, layer) == 24, "ABI offset dr
static_assert(offsetof(esengine::ecs::MeshRenderer, opaque) == 28, "ABI offset drift: esengine::ecs::MeshRenderer.opaque (EHT expected 28)");
static_assert(offsetof(esengine::ecs::MeshRenderer, cullBackfaces) == 29, "ABI offset drift: esengine::ecs::MeshRenderer.cullBackfaces (EHT expected 29)");
static_assert(offsetof(esengine::ecs::MeshRenderer, lit) == 30, "ABI offset drift: esengine::ecs::MeshRenderer.lit (EHT expected 30)");
+static_assert(offsetof(esengine::ecs::MeshRenderer, castShadows) == 31, "ABI offset drift: esengine::ecs::MeshRenderer.castShadows (EHT expected 31)");
static_assert(offsetof(esengine::ecs::MeshRenderer, parallax) == 32, "ABI offset drift: esengine::ecs::MeshRenderer.parallax (EHT expected 32)");
static_assert(offsetof(esengine::ecs::MeshRenderer, material) == 40, "ABI offset drift: esengine::ecs::MeshRenderer.material (EHT expected 40)");
static_assert(offsetof(esengine::ecs::MeshRenderer, enabled) == 44, "ABI offset drift: esengine::ecs::MeshRenderer.enabled (EHT expected 44)");
@@ -4079,7 +4084,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "7403dd8de628613e";
+static const char* kEsAbiLayoutHash = "7cf803aca319cd32";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/ecs/components/MeshRenderer.hpp b/src/esengine/ecs/components/MeshRenderer.hpp
index 7ac7901ab..5442a7118 100644
--- a/src/esengine/ecs/components/MeshRenderer.hpp
+++ b/src/esengine/ecs/components/MeshRenderer.hpp
@@ -77,6 +77,11 @@ struct MeshRenderer {
ES_PROPERTY(tooltip="Receive 2D lights: Light entities light this mesh (flat normal). A custom material overrides this.")
bool lit{false};
+ /** @brief Whether it stands in the light's way: drawn into the shadow maps (and what shelters from rain). A surface light
+ * passes through, like water, says no. */
+ ES_PROPERTY(tooltip="Cast shadows: whether this mesh blocks the light. Water and other surfaces light passes through say no.")
+ bool castShadows{true};
+
/** @brief Parallax scroll factor per axis. 1 = moves with the world (default, no
* parallax); <1 = scrolls slower than the camera (appears farther, e.g. a
* background); 0 = locked to the camera (e.g. a sky). The renderer offsets
diff --git a/src/esengine/renderer/plugins/MeshPlugin.cpp b/src/esengine/renderer/plugins/MeshPlugin.cpp
index 2d4826143..1091a1c2a 100644
--- a/src/esengine/renderer/plugins/MeshPlugin.cpp
+++ b/src/esengine/renderer/plugins/MeshPlugin.cpp
@@ -619,6 +619,8 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {
// below, which bakes world space into vertices for the BATCH shader — a
// shader that writes colour, not the depth this pass is here to collect.
if (depthPass && !resident) continue;
+ // What light passes through (water) stands in no light's way.
+ if (shadowDepth && !mesh.castShadows) continue;
// Only a surface that draws opaque and unblended has a motion worth writing: what is blended over
// something has two, and the picture can follow one.
if (motion && !mesh.opaque) continue;
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 77ca611d8..867c00e92 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -2786,4 +2786,6 @@ export const NOTED = {
{"note":"An area without a heightmap is a window on its provider's ground."},
"fix(water): rain rings out on the surface instead of denting the ripples, wind ripples are waves not noise, and storms raise sheltered water less":
{"note":"Rain and storms on water."},
+ "fix(water): water casts no shadow, a lake holds a river that runs into it, and the surf's slope fades on the ridge between shores":
+ {"note":"A river runs into a lake cleanly, and water casts no shadow."},
};