3d-ultra-realistic-water
它能做什么
这个技能指导智能体在 Three.js 中制作从近处浪花到远处地平线的逼真海面。适合构建海洋场景、船只或海边体验的开发者。
适用场景
- ✓你希望从船上或浪尖之上看起来真实的海面的时候。
- ✓3D 海洋需要阳光闪烁、泡沫和地平线的时候。
- ✓船只或漂浮物需要稳稳地位于波浪之上的时候。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/3d/3d-ultra-realistic-water/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的日落船只场景构建一片起伏的海洋,波峰上有阳光反光和泡沫。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用一个现成的波浪模块,逐像素对水面着色,淡化远处的波浪以避免闪烁,并添加反射和泡沫。该模块会适配项目自身的渲染器。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
3D Ultra-Realistic Water
Use this for an open sea seen by a moving camera, with a horizon and a sun. Reach for something else in these cases:
- Mirror-flat water seen from the waterline with no mesh: a full-screen analytic water plane is cheaper.
- Ripples that follow the cursor on a UI surface: use
shaders-cursor-ripples. - A small pool that reacts to touch: use a ping-pong height field.
Source: extracted from Pirate Ship Sunset, a single-file Three.js r169 scene in which a three-masted ship sails a rolling sea at sunset under an auto-cycling camera. The water had to stay convincing from 2 m above the waves out to a 12 km horizon.
The mechanism
Shade the sea per pixel from the analytic derivatives of a deep-water Gerstner sum, and fade each wave out once its wavelength falls below the pixel footprint. The per-pixel derivatives keep the glitter and foam sharp on a mesh whose triangles are 30 m wide at the horizon. The footprint fade stops the far sea from boiling into moiré.
Reuse the working effect
Copy assets/ocean.mjs. You pass in the project's own THREE, and the module does not import a second copy. Before you integrate it, read references/ocean.md, which covers the full constants, render order, buoyancy and post. The demo runs this same module inside the original scene. demo/build.mjs rebuilds it from the reference page.
import { createWaves, bakeOceanDetail, createOcean, createWake, createPlanarReflection } from './ocean.mjs';
const waves = createWaves({ direction: 1.22 }); // wind heading, radians
const ocean = createOcean(THREE, {
waves,
detailTexture: bakeOceanDetail(THREE, renderer), // baked once, 512²
skyCube, // cube rendered from YOUR sky shader
hazeGLSL: SKY_GLSL + 'vec3 oceanHaze(vec3 d){ return hazeColor(d); }',
hazeUniforms: skyUniforms, // may include uSunDir
wake: createWake(THREE, renderer, { shipLength: 34 }), // optional
hull: { halfWidths, zMin: -18, zMax: 18, bowZ }, // optional, ship-local metres
});
scene.add(ocean.mesh);
const reflection = createPlanarReflection(THREE, renderer, { layer: 1 });
ocean.setReflection(reflection);
// every frame, in this order
waves.update(dt); // CPU phases, before any height() query
ship.y = waves.height(ship.x, ship.z); // buoyancy uses the same spectrum
ocean.update({ time, camera, ship: { x, z, fx, fz } });
wake.update(x, z, fx, fz, speed * dt);
reflection.render(scene, camera); // before the main pass
renderer.render(scene, camera); // into a HalfFloat target, then bloom + ACES
The stack, with the numbers that shipped
| layer | what it does | constants |
|---|---|---|
| Spectrum | 8 Gerstner waves, deep-water dispersion ω = √(g·k) |
L 78 → 3.1 m (×0.63 per step), A 0.8 → 0.02 m, headings 0, +23, −17, +38, −31, +12, −49, +64° off the wind, Q 0.17 → 0.03 (Σ 0.77) |
| Grid | exponential rings centred under the camera | r = 11.92·(e^(0.033·i) − 1), 210 rings × 400 segments = 84,001 verts, 167,600 tris, reaches ~12.2 km; spacing 0.033·(r + 12) |
| Footprint fade | per wave, in both shaders | fade = 1 − smoothstep(0.18·L, 0.5·L, footprint); vertex footprint 1.2 × ring spacing, pixel footprint 2 × (fwidth(x) + fwidth(z)) |
| Normal | per pixel, normalize(cross(dP/dz, dP/dx)) |
Jacobian J = dPdx.x·dPdz.z − dPdx.z·dPdz.x drives crest foam |
| Micro detail | baked 512² tile: 48 sines with integer wave vectors, amplitude ∝ |k|^−1.35 | two octaves at 19 m and 7.3 m (the second rotated 90°), strength 0.4·e^(−d/500) + 0.08 |
| Reflection | Schlick with water F0 = 0.02; 256² sky cube re-rendered every 0.25 s; half-res planar pass for the ship and islands | planar UV nudged by N.xz · (0.06, 0.03) · clamp(30/d, 0.2, 1) |
| Body | deep colour plus sunlit subsurface through the wave crests | deep (0.006, 0.03, 0.048), scatter (0.035, 0.3, 0.27) linear; scatter × toward-sun² × crest height × (0.35 + 4·(1 − N.y)) |
| Glitter | HDR specular, left for the bloom to catch | pow(R·L, 90)·1.2 + pow(R·L, 12)·0.06 + pow(R·L, 1400)·40, sun colour (4.2, 2.3, 1.1); bloom threshold 1.6, knee 0.8 |
| Foam | thresholds a Worley lattice by a mask, so the foam stays lacy | crest smoothstep(0.6, 0.28, J); `foam = s |
常见问题
它能使用项目自己的 Three.js 吗?
可以。技能要求传入项目自己的 Three.js,以免加载第二份副本。
它能处理漂浮在波浪上的物体吗?
可以。技能包含浮力查询,使物体能够停在水面上。
有可以参考的演示吗?
有。技能包含一个演示,在原始场景中运行同一个模块。
详情
作者的原始描述
Build an ultra-realistic open ocean in Three.js with a deep-water Gerstner spectrum shaded per pixel from analytic derivatives, each wave faded at its own pixel footprint, plus Fresnel sky-cube and planar reflections, subsurface light through the crests, HDR sun glitter, Jacobian lace foam, a Kelvin wake, hull foam, buoyancy queries and aerial perspective into the sky's horizon haze. Use for seas, oceans, sunset or daylight water, sun glitter paths, ship or boat scenes, wakes, coastal flyovers and any 3D scene with a moving camera and a water horizon. Includes the approved water from Pirate Sh
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13324
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。