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 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
yhh2627adec985e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 46af16453..5e8c98dd2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,7 @@ published separately; it ships inside the editor.### Fixed+- **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.- **The sea past the rings lies at the sea's level.** The apron that carries an ocean from its mesh to the horizon took its inner edge's height from whatever water lay under it. With a river on high ground under that edge (a river along a cliff top, seen from across the island), a strip of sea eighty kilometres long rose to the river's height and stood on the horizon as a block with straight sides, moving as the camera did. The apron is now laid at the ocean's level.diff --git a/docs/astro/src/content/docs/graphics/water.mdx b/docs/astro/src/content/docs/graphics/water.mdxindex 0aba3e5dd..7a520bd28 100644--- a/docs/astro/src/content/docs/graphics/water.mdx+++ b/docs/astro/src/content/docs/graphics/water.mdx@@ -171,8 +171,8 @@ level at `speed` and pulled down by gravity, and each sheet ends where it meetsOnly the entity's turn about the vertical aims it: keep it upright and unscaled. With no material on the `MeshRenderer` it takes the stock**Waterfall** shader: glass at the lip that tears into strands and then veils, its pattern riding down with the water. Its params are the-water's colour at the lip (`u_water`) and the white it breaks into (`u_foam`), how many strands lie across a sheet (`u_strands`) and how-fast they run (`u_run`), how much of the sheet is gone at its foot (`u_veil`) and how far down it is torn that much (`u_tearBy`),+water'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 how+many 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 waterthere has been falling, the colour's red the share of the fall done, its green a number of the sheet's own.diff --git a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx b/docs/astro/src/content/docs/zh-cn/graphics/water.mdxindex 56fe4f408..c57617445 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/water.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/water.mdx@@ -114,8 +114,8 @@ description: 若干 WaterBody 组件说明海洋、湖泊或河流在哪里,一| `rows`、`across` | 水帘沿下落方向的行数和横向的格数。 |只有实体绕竖直轴的转向起作用:保持它直立、不缩放。`MeshRenderer` 上没有材质时用内置的 **Waterfall** 着色器:崖口处像玻璃,往下撕成水丝-再成水雾,花纹随水一起下落。参数有崖口处水的颜色(`u_water`)和碎开后的白(`u_foam`)、一片水帘上横向有多少条水丝(`u_strands`)-及其流速(`u_run`)、底部少掉多少(`u_veil`)和落到多深撕成那样(`u_tearBy`)、`u_opacity` 和 `u_roughness`。自己写材质时可以读网格+再成水雾,花纹随水一起下落。参数有崖口处水的颜色(`u_water`)和碎开后的白(`u_foam`)、半片水帘上横向有多少条水丝(`u_strands`)+和一条水丝在下落的一秒内变化多少次(`u_run`,越小水丝越长)、底部少掉多少(`u_veil`)和落到多深撕成那样(`u_tearBy`)、`u_opacity` 和 `u_roughness`。自己写材质时可以读网格带的数据:`uv.x` 是横向位置,`uv.y` 是那里的水已经下落的秒数,颜色的红是下落完成的比例,绿是每片水帘自己的编号。瀑布只画水帘本身。要放在瀑布某处的东西,做成带 **`WaterfallAnchor`** 的子实体:瀑布会把这个子实体保持在水流路径的中线上,diff --git a/sdk/src/water/waterfallShader.ts b/sdk/src/water/waterfallShader.tsindex ccde215df..e8d83948d 100644--- a/sdk/src/water/waterfallShader.ts+++ b/sdk/src/water/waterfallShader.ts@@ -16,11 +16,12 @@ const WATERFALL = `#pragma shader "Waterfall"// The water at the lip, before it breaks, and the white it breaks into.#pragma param u_water color default(0.30,0.55,0.52,1)#pragma param u_foam color default(0.90,0.94,0.98,1)-// How many strands lie across the sheet, and how fast their pattern runs (1 is with the water).-#pragma param u_strands float default(60) range(4,400) ui(slider)-#pragma param u_run float default(0.55) range(0,4) ui(slider)+// How many strands lie across half the sheet, and how many times in a second of its fall a strand changes: fewer is longer strands.+// The pattern always rides down with the water.+#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.42) range(0,1) ui(slider)+#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_opacity float default(1) range(0,1) ui(slider)#pragma param u_roughness float default(0.6) range(0.02,1) ui(slider)@@ -63,7 +64,7 @@ void main() {if (dot(N, V) < 0.0) N = -N;float side = v_texCoord.x * 2.0 - 1.0, k = clamp(v_color.r, 0.0, 1.0), own = v_color.g;float across = (side + own) * u_strands;- float along = (v_texCoord.y - u_time.x) * u_run * 28.0;+ float along = (v_texCoord.y - u_time.x) * u_run;float strands = fallNoise(vec2(across, along)) * 0.55 + fallNoise(vec2(across * 2.5 + 9.0, along * 2.1)) * 0.45;float clumps = fallNoise(vec2(across / 3.0 + 3.0, along * 0.45));// A glassy lip that tears into strands, then into veils.@@ -118,7 +119,7 @@ struct FragOut {let side = v.v_texCoord.x * 2.0 - 1.0;let k = clamp(v.v_color.r, 0.0, 1.0);let across = (side + v.v_color.g) * mc.u_strands;- let along = (v.v_texCoord.y - tc.u_time.x) * mc.u_run * 28.0;+ let along = (v.v_texCoord.y - tc.u_time.x) * mc.u_run;let strands = fallNoise(vec2f(across, along)) * 0.55 + fallNoise(vec2f(across * 2.5 + 9.0, along * 2.1)) * 0.45;let clumps = fallNoise(vec2f(across / 3.0 + 3.0, along * 0.45));let body = mix(1.0, 0.74, smoothstep(0.05, 0.7, k));diff --git a/sdk/tests/waterfall.test.ts b/sdk/tests/waterfall.test.tsindex 1082b2693..49374f9b3 100644--- a/sdk/tests/waterfall.test.ts+++ b/sdk/tests/waterfall.test.ts@@ -102,6 +102,10 @@ describe('the Waterfall component and its shader', () => {const source = WATERFALL_SHADER_TEMPLATE.source;expect(source).toContain('(v_texCoord.y - u_time.x) * u_run');expect(source).toContain('(v.v_texCoord.y - tc.u_time.x) * mc.u_run');+ // A strand is long: about four lie across half a sheet and one lasts about a second of the fall, not a speckle of sixty by fifteen.+ 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');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 e9fe1d4a6..a34d44e96 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4580,6 +4580,8 @@ export const NOTED = {{"note": "The tonemap has the fitted ACES curve too."},"feat(terrain): a cliff's beds can wander - a layer read from the side lies by height, so its beds ran dead straight along a whole wall; Terrain Layers' u_strataWarp moves them up and down by slow noise u_strataSpan wide, and 0, the default, leaves them straight":{"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(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":