跳到正文
Skillpedia
网站与界面(前端)7.2k · #13325

3d-underwater-god-rays

它能做什么

这个技能指导智能体让阳光在 3D 场景的水下可见,包括光柱以及落在鱼身上移动的光线。适合在 Three.js 中构建水下或海景体验的开发者。

适用场景

  • ✓镜头位于水下,光线需要从水面向下穿透的时候。
  • ✓你希望鱼或物体被移动的光束照亮的时候。
  • ✓水下场景需要波动光线和焦散图案的时候。

技能链接

https://github.com/MengTo/Skills/blob/main/agent-skills/3d/3d-underwater-god-rays/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MengTo/Skills/blob/main/agent-skills/3d/3d-underwater-god-rays/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我的鱼缸场景添加水下光柱,让光束在水中移动。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会沿着每条视线在半分辨率下采样一个漂移的涌动图案,使光柱汇聚到太阳并随水流移动。同样的光线也会作用于游动穿过光束的鱼。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

3D Underwater God Rays

Use this when the camera is under the water and the light comes down through it. Reach for a sibling instead in these cases:

  • Sun shafts in air, cut by trees and rooflines: use 3d-sky-rays. Its screen-space radial blur of an occlusion mask is the right tool there. It cannot parallax or carry ripples, so under water keep it only as a low companion for fish shadows (Blue Hour runs it at 0.25).
  • The ocean surface seen from above, with a horizon: use 3d-ultra-realistic-water.
  • Authored shaft planes through one window in a lit interior: use 3d-wood-lighting-scorecard.

Source: extracted from Blue Hour, the living-ocean wallpaper of a Three.js iPhone Duo study. A school of 2,200 Blender sardines turns behind a glass device. The light had to read as sun through water across the whole 38 s camera dolly and on the device's own screen.

Verified stack: Three.js r170, WebGL2, GLSL ShaderMaterials, one HalfFloat render target, and a hand-written ACES pass. No post-processing library.

The mechanism

Sample one drifting swell field across the sun direction, and integrate it along every view ray. Each point in the water is lit by the swell value at its position measured perpendicular to the sun. The shafts are therefore parallel columns in the world. They converge on the sun the way rails converge on a vanishing point, and they slide past the fish when the camera moves. Paint the same shafts in screen space and they stay locked to the lens.

Reuse the working effect

Copy assets/underwater-light.mjs. You pass in your own THREE, and the module does not import a second copy. The demo runs this same module inside Blue Hour's renderer. demo/build.mjs rebuilds it from the Blue Hour sources.

import { createUnderwaterLight, LIGHT_GLSL, WATER_GLSL } from './underwater-light.mjs';

// One uniforms object shared by the water, fish and particle materials.
const uniforms = {
  uSunDirection: { value: new THREE.Vector3(.25, .40, -1).normalize() },   // toward the sun
  uTime: { value: 0 },
  uCameraPosition: { value: camera.position },
  uCameraWorld: { value: camera.matrixWorld },
  uInverseProjection: { value: camera.projectionMatrixInverse },
};
const light = createUnderwaterLight(THREE, { uniforms });   // before creating the materials below
light.setSize(innerWidth * dpr, innerHeight * dpr);          // drawing-buffer pixels, again on resize

// Water: a full-screen quad. Declare uSunDirection, uCameraPosition, uTime,
// uShafts and uShaftTexel, then add ${LIGHT_GLSL}${WATER_GLSL} and in main():
//   vec3 sunRay = ray;
//   color += surfaceUnderside(ray, sunRay);     // also bends sunRay through the ripples
//   ...draw your sun with sunRay...
//   color += underwaterShafts(vUv, ray);
// Fish: declare uSunDirection, then add ${LIGHT_GLSL} and multiply the sun key
// by underwaterDapple(worldPosition, uTime).

// Every frame, in this order:
uniforms.uTime.value = time;
camera.updateMatrixWorld();
light.render(renderer);          // the march, into its own half-resolution target
// then the water, the fish, and one tone map at the end

The numbers that shipped

layer constants
Swell 4 sines along (.86, .51), (−.42, .91), (.13, −.99), (−.97, −.24) at ×1, 1.23, 0.87, 1.41; drift 0.29, 0.24, 0.19, 0.15 rad/s; domain warp 0.62
Across the sun scale 1.3, so the main period is about 4.8 world units against a frame about 22 units wide at the school
Shaft focus smoothstep(−0.05, 1, swell)², faded by exp(−0.012 · distance to the surface along the sun)
Caustic web the swell again at ×2.6 and 1.35× speed, `(1 −
March 26 steps, t = 4 + 50·f², weight exp(−0.06t)·(0.08 + f), divided by the weight sum; a stable per-pixel jitter (interleaved gradient noise) instead of temporal noise
Sun blend total = mix(total, 0.16, μ^28), where μ = ray·sun
Phase 0.7 + 1.1μ^5 + 0.9μ^40; rays below the horizon × mix(0.45, 1, smoothstep(−0.45, 0.35, ray.y))
Gain (0.16, 0.40, 0.47) × 3.6, linear HDR, tone-mapped once at the end
Buffer 0.5 × the drawing buffer, HalfFloat, single-sampled (the march is soft, so MSAA buys nothing), upsampled with a 4-tap tent at ½ texel
Surface underside plane at y = 12; network `(1 −
常见问题

这是空气中的光柱效果吗?

不是。技能指向另一个相关技能,用于空气中的阳光光柱。

这个效果是以什么分辨率计算的?

技能以半分辨率计算该效果。

光线会影响其他物体吗?

会。同样的光线也会作用于穿过光束游动的鱼。

详情

作者的原始描述

Add volumetric underwater god rays to a Three.js scene, marching one drifting swell field along every view ray at half resolution so the light shafts converge on the sun, parallax with the camera and carry rippling caustic streaks, with a shimmering surface underside, a sun that wobbles through the ripples, and the same light dappling fish as they swim through the beams. Use for underwater scenes, oceans seen from below, aquariums, reefs, kelp forests, diving and shipwreck scenes, schools of fish, sunbeams or light shafts through water, caustics, "rays of light shining through the ocean", or w

repo: MengTo/Skills

热度

GitHub 星标
7.2k
排名
#13325
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能