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(water): a waterfall's foot is torn to veils, and light goes through it - three blended sheets added up to a board at the foot, where the fall the shader was made from shows the most of its three: the stock Waterfall tears more of the foot away (u_veil 0.75, u_tearBy 1), and u_translucency lights the sheet from whichever side the sun is on
yhhd3b3527dab07
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 80e1af365..5087b728e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -39,6 +39,7 @@ published separately; it ships inside the editor.### Fixed+- **A waterfall's foot is torn to veils, and light goes through it.** A `Waterfall`'s sheets are blended one over another, so three of them added up to a white board in the lower half of the fall. The stock shader now tears more of the foot away (`u_veil` 0.75, by the foot itself, `u_tearBy` 1): beside the fall it was made from, the foot is 10 levels of 255 over and the middle 14, where the foot was 55 over. And a sheet was lit as an opaque wall facing one way; `u_translucency` (1 by default) lets the light through, as the Model shader's does. `u_veil` 0.47, `u_tearBy` 0.85 and `u_translucency` 0 are the sheet as it was.- **A waterfall falls in strands, not in speckle.** The stock Waterfall shader's pattern was sixteen times too fine each way: sixty cells across half a sheet and fifteen to a second of the fall, so a sheet read as a solid white board peppered with dark flecks. About four strands now lie across half a sheet (`u_strands` 3.75) and one lasts about a second of the fall (`u_run` 0.97, now the count itself and no longer a share of 28), and a little more of the foot is torn away (`u_veil` 0.47). `u_strands` 60, `u_run` 15.4 and `u_veil` 0.42 are the old sheet.- **A far plant grows across the ground, not taller.** A mesh plant kept in one of `Foliage`'s far versions was grown the same every way to cover the ground of those left out. Cover is a matter of width: a flower that stood for ten stood ten times as high as well, and a meadow seen from a hill was a field of dark poles. A kept plant now grows across the ground only and is as tall as it was. `farGrowUp` (0) is the share of the growth its height takes: 1 is the growth every way that it was before.- **A detail the pages cannot hold no longer cracks the ground.** A terrain's heights are kept in an atlas of 900 pages, a page a node. A `detail` high enough to want more nodes than that (about 4 on 1.5 m cells: 1153 from inside a fjord) had part of its ground drawn by coarser pages standing in for the ones that had no room, which do not meet their finer neighbours' edges: slivers of sky showed through steep ground, and the pages were fought over frame after frame, so the ground never finished loading. The ground is now drawn at the share of its detail's range that fits the pages there are, and a warning says so once.diff --git a/docs/astro/src/content/docs/graphics/water.mdx b/docs/astro/src/content/docs/graphics/water.mdxindex 7a520bd28..3b1556724 100644--- a/docs/astro/src/content/docs/graphics/water.mdx+++ b/docs/astro/src/content/docs/graphics/water.mdx@@ -173,7 +173,8 @@ Only the entity's turn about the vertical aims it: keep it upright and unscaled.**Waterfall** shader: glass at the lip that tears into strands and then veils, its pattern riding down with the water. Its params are thewater's colour at the lip (`u_water`) and the white it breaks into (`u_foam`), how many strands lie across half a sheet (`u_strands`) and howmany times in a second of its fall a strand changes (`u_run`: fewer is longer strands), how much of the sheet is gone at its foot (`u_veil`) and how far down it is torn that much (`u_tearBy`),-`u_opacity` and `u_roughness`. A material of your own reads what the mesh carries: `uv.x` across the sheet, `uv.y` the seconds the water+`u_opacity`, `u_roughness`, and how much of the light goes through the sheet (`u_translucency`: a veil of water is lit from whichever side+the sun is on, where 0 lights it as an opaque surface). A material of your own reads what the mesh carries: `uv.x` across the sheet, `uv.y` the seconds the waterthere has been falling, the colour's red the share of the fall done, its green a number of the sheet's own.The fall is the sheet alone. What belongs at a place on it is a child entity with a **`WaterfallAnchor`**: the fall keeps that child ondiff --git a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx b/docs/astro/src/content/docs/zh-cn/graphics/water.mdxindex c57617445..a845666ca 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/water.mdx@@ -115,7 +115,7 @@ description: 若干 WaterBody 组件说明海洋、湖泊或河流在哪里,一只有实体绕竖直轴的转向起作用:保持它直立、不缩放。`MeshRenderer` 上没有材质时用内置的 **Waterfall** 着色器:崖口处像玻璃,往下撕成水丝再成水雾,花纹随水一起下落。参数有崖口处水的颜色(`u_water`)和碎开后的白(`u_foam`)、半片水帘上横向有多少条水丝(`u_strands`)-和一条水丝在下落的一秒内变化多少次(`u_run`,越小水丝越长)、底部少掉多少(`u_veil`)和落到多深撕成那样(`u_tearBy`)、`u_opacity` 和 `u_roughness`。自己写材质时可以读网格+和一条水丝在下落的一秒内变化多少次(`u_run`,越小水丝越长)、底部少掉多少(`u_veil`)和落到多深撕成那样(`u_tearBy`)、`u_opacity`、`u_roughness`,以及有多少光穿过水帘(`u_translucency`:水帘不论太阳在哪一侧都被照亮,设为 0 则按不透明表面受光)。自己写材质时可以读网格带的数据:`uv.x` 是横向位置,`uv.y` 是那里的水已经下落的秒数,颜色的红是下落完成的比例,绿是每片水帘自己的编号。瀑布只画水帘本身。要放在瀑布某处的东西,做成带 **`WaterfallAnchor`** 的子实体:瀑布会把这个子实体保持在水流路径的中线上,diff --git a/sdk/src/water/waterfallShader.ts b/sdk/src/water/waterfallShader.tsindex e8d83948d..1a37cf331 100644--- a/sdk/src/water/waterfallShader.ts+++ b/sdk/src/water/waterfallShader.ts@@ -21,10 +21,13 @@ const WATERFALL = `#pragma shader "Waterfall"#pragma param u_strands float default(3.75) range(0.5,400) ui(slider)#pragma param u_run float default(0.97) range(0,40) ui(slider)// How much of the sheet is gone at its foot (0 a whole sheet to the bottom, 1 nothing left of it), and how far down it is torn that much.-#pragma param u_veil float default(0.47) range(0,1) ui(slider)-#pragma param u_tearBy float default(0.85) range(0.05,1) ui(slider)+#pragma param u_veil float default(0.75) range(0,1) ui(slider)+#pragma param u_tearBy float default(1) range(0.05,1) ui(slider)#pragma param u_opacity float default(1) range(0,1) ui(slider)#pragma param u_roughness float default(0.6) range(0.02,1) ui(slider)+// How much of the light goes through the sheet: a veil of water is lit from whichever side the sun is on, not as a wall facing it.+// 0 lights it as an opaque surface.+#pragma param u_translucency float default(1) range(0,1) ui(slider)#pragma fragmentprecision highp float;@@ -77,6 +80,10 @@ void main() {if (alpha < 0.02) discard;vec3 albedo = mix(u_water.rgb, u_foam.rgb, smoothstep(0.0, 0.10, k) * (0.6 + 0.4 * strands));SurfaceExt ext = surfaceExtNone(N);+ if (u_translucency > 0.0) {+ ext.scatter = vec4(albedo, u_translucency * 0.5);+ ext.trans = vec4(u_translucency, 0.0, 0.0, 0.0);+ }vec3 lit = applyLightingSurface(albedo, N, P, V, 0.0, u_roughness, 0.5, 1.0, ext);fragColor = vec4(lit, alpha);#ifdef ES_GBUFFER@@ -130,7 +137,11 @@ struct FragOut {alpha = clamp(alpha * mc.u_opacity, 0.0, 1.0);if (alpha < 0.02) { discard; }let albedo = mix(mc.u_water.rgb, mc.u_foam.rgb, smoothstep(0.0, 0.10, k) * (0.6 + 0.4 * strands));- let ext = surfaceExtNone(N);+ var ext = surfaceExtNone(N);+ if (mc.u_translucency > 0.0) {+ ext.scatter = vec4f(albedo, mc.u_translucency * 0.5);+ ext.trans = vec4f(mc.u_translucency, 0.0, 0.0, 0.0);+ }let lit = applyLightingSurface(albedo, N, P, V, 0.0, mc.u_roughness, 0.5, 1.0, ext);#ifdef ES_GBUFFERvar frag : FragOut;diff --git a/sdk/tests/waterfall.test.ts b/sdk/tests/waterfall.test.tsindex 49374f9b3..38e8549f2 100644--- a/sdk/tests/waterfall.test.ts+++ b/sdk/tests/waterfall.test.ts@@ -106,6 +106,10 @@ describe('the Waterfall component and its shader', () => {expect(source).toContain('#pragma param u_strands float default(3.75)');expect(source).toContain('#pragma param u_run float default(0.97)');expect(source).not.toContain('u_run * 28.0');+ // Light goes through the sheet by default, in both languages, through the lit model's own scatter and transmission.+ expect(source).toContain('#pragma param u_translucency float default(1)');+ expect(source).toContain('ext.trans = vec4(u_translucency, 0.0, 0.0, 0.0);');+ expect(source).toContain('ext.trans = vec4f(mc.u_translucency, 0.0, 0.0, 0.0);');for (const p of ['u_water', 'u_foam', 'u_strands', 'u_run', 'u_veil', 'u_tearBy', 'u_opacity', 'u_roughness']) expect(source).toContain(`#pragma param ${p} `);});});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex fd0aed2b9..3f95a7b49 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4584,6 +4584,8 @@ export const NOTED = {{"note": "A cliff's beds can wander."},"fix(water): a waterfall falls in strands, not in speckle - the stock Waterfall shader's pattern was sixteen times too fine each way, so a sheet was a solid white board peppered with dark flecks; about four strands now lie across half a sheet and one lasts about a second of the fall, and u_strands 60 with u_run 15.4 is the old pattern":{"note": "A waterfall falls in strands, not in speckle."},+ "fix(water): a waterfall's foot is torn to veils, and light goes through it - three blended sheets added up to a board at the foot, where the fall the shader was made from shows the most of its three: the stock Waterfall tears more of the foot away (u_veil 0.75, u_tearBy 1), and u_translucency lights the sheet from whichever side the sun is on":+ {"note": "A waterfall's foot is torn to veils, and light goes through it."},"fix(terrain): a detail the pages cannot hold no longer cracks the ground - a tree that wanted more nodes than the atlas has pages was drawn in part by coarser pages standing in, which do not meet their finer neighbours' edges, and the pages were fought over every frame; the ground is now drawn at the share of its detail's range that fits, and says so once":{"note": "A detail the pages cannot hold no longer cracks the ground."},"fix(foliage): a far plant grows across the ground, not taller - a mesh plant kept in a far version was grown the same every way to cover the ground of those left out, so a flower that stood for ten stood ten times as high and a far meadow was a field of poles; it now grows across the ground only, and Foliage.farGrowUp gives its height a share of the growth back":