webgl-raymarched-hero
它能做什么
在网页上呈现一个闪亮、动态的 3D 场景。它使用一种叫“光线步进”(raymarching)的技术来绘制有机形状,这些形状会不断移动和变化,而且不需要传统的 3D 模型或贴图。
适用场景
- ✓当你需要为页面首屏(hero 区域)打造醒目、现代的 3D 视觉效果时。
- ✓当你想展示平滑变形的 3D 形状,比如融合在一起的“水滴团”时。
- ✓当你想在不使用复杂 3D 模型和贴图的情况下,做出独特的视觉效果时。
技能链接
https://github.com/nexu-io/open-design/blob/main/plugins/_official/examples/webgl-raymarched-hero/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我创建一个 3D 视觉效果,里面有缓慢环绕运动的“变形球”(metaballs)。”
每周 5 个新技能,1 分钟读完。
工作原理
程序会绘制一个覆盖全屏的三角形,然后借助一段特殊的代码(片元着色器,fragment shader)计算每个像素的颜色。它会模拟光线在 3D 空间中传播的路径,从而生成形状和阴影。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Raymarched Hero Skill
Produce a single self-contained index.html that renders a real-time 3D scene entirely in a fragment shader via sphere tracing, full-screen, with a clean typographic overlay on top.
Why this is a powered artifact
OpenDesign detects getContext('webgl2') and renders this file in powered preview — a cross-origin-isolated iframe with allow-same-origin. The full GPU pipeline is available; you do not need to work around the opaque sandbox.
Resource map
webgl-raymarched-hero/
├── SKILL.md ← you're reading this
└── example.html ← a working SDF metaball raymarcher (READ FIRST)
Workflow
Step 0 — Read the reference
Read example.html end to end. Note the shape: one fullscreen triangle; a map(p) signed-distance function that smooth-unions (smin) several moving spheres; normals by finite differences; a softShadow march; and a camera built from ro/ta with a slow orbit. Shading = diffuse × soft shadow + fresnel rim + a tight specular.
Step 1 — Choose the SDF
Keep the marcher cheap so it holds 60fps:
- Metaballs (default): a few spheres blended with
smin— organic, always readable. - Rounded primitives: box/torus/capsule SDFs with domain repetition for a structured hero.
- Displaced surface: a sphere plus a low-amplitude noise displacement for a molten look.
Step 2 — Build index.html
- One file, zero external requests. Fullscreen triangle + fragment raymarch.
- Bound the march: cap iterations (~90), early-out on hit (
d < 0.001) and on far distance; clamp DPR to ~1.5 — raymarching is per-pixel heavy. - Light it: diffuse, a soft/penumbra shadow, a fresnel rim (
pow(1 - dot(n,-rd), 3)), and one specular lobe. Gentle gamma at the end. - Compile shaders with error logging so a typo fails loudly, not silently black.
Step 3 — Overlay + brand
- Map the accent colors to the active DESIGN.md when one is present; otherwise a restrained dark palette with one vivid accent (the reference tints the surface toward lime
#63fe13and rims it in teal). - Headline ≤ 13ch plus one supporting line. Keep the 3D form as the hero.
Step 4 — Self-review (P0)
- Renders continuously at ~60fps; the FPS badge updates.
- Surface has real depth cues: shadow, rim, and a moving specular.
- No banding artifacts at the silhouette; normals are stable.
- Resizes crisply on window resize (no stretching / blur).
- Degrades to a message (not a blank page) if
webgl2is unavailable.
常见问题
什么是“变形球”(metaballs)?
它们是一种 3D 形状,看起来像“水团”或“水滴”,当彼此靠近时,会像有机体一样融合在一起。
什么是“光线步进”(raymarching)?
这是一种模拟光线路径来绘制 3D 场景的计算机图形技术。可以把它想象成“发射”一束束光线,看它们打到哪里,以此决定该画什么。
为什么它不使用 3D 模型或贴图?
这种技术通过代码中的数学计算直接生成形状,因此无需外部的模型文件和贴图文件,就能做出独特的视觉效果和流畅的动画。
详情
作者的原始描述
A real-time raymarched 3D hero — soft-shadowed morphing metaballs with a fresnel rim light, sphere-traced per pixel in a fragment shader with a slow camera orbit. No meshes, no textures. Rendered as a single self-contained `index.html`. Use when the brief asks for a "raymarch", "signed distance field", "SDF", "3D hero", "metaballs", "blobs", or a shader-based 3D scene. OpenDesign serves this in po
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #1063
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …