Community图像github.com

threejs-sky-backdrop

在 three.js 用程式做天空與窗外遠景,不需要 HDRI 或圖檔。天空的同一份參數同時用在三個地方:烘焙光照用的解析式天空、看得到的天空球(雲層、高空薄雲、地平線霧帶、太陽),以及不烘焙時用的太陽光、半球光與環境貼圖。內含四種預設(清晨、白天、陰天、黃昏)和一個量測工具,確認看到的天空和照亮場景的天空亮度一致。遠景部分包括:只建從室內窗戶看得到的東西(窗洞可見性與 LOD)、隨距離變淡的大氣霧化、遠處逐漸變粗的草地網格、碎石小路、樹籬、鄰居房子(陶瓦屋頂、窗戶、煙囪、天窗)、封住地平線的遠方樹牆,並可以搭配 threejs-procedural-vegetation 種樹。當使用者說「天空」「sky shader」「雲」「程式生成天空」「不用 HDRI」「窗外景色」「遠景」「背景房子」「地平線」「大氣透視」「霧化」「窗外的樹」「天空和光照對不上」「清晨/黃昏/陰天的天空」「只建看得到的東西」時使用。

threejs-sky-backdrop 是什么?

threejs-sky-backdrop is a Claude Code agent skill that 在 three.js 用程式做天空與窗外遠景,不需要 HDRI 或圖檔。天空的同一份參數同時用在三個地方:烘焙光照用的解析式天空、看得到的天空球(雲層、高空薄雲、地平線霧帶、太陽),以及不烘焙時用的太陽光、半球光與環境貼圖。內含四種預設(清晨、白天、陰天、黃昏)和一個量測工具,確認看到的天空和照亮場景的天空亮度一致。遠景部分包括:只建從室內窗戶看得到的東西(窗洞可見性與 LOD)、隨距離變淡的大氣霧化、遠處逐漸變粗的草地網格、碎石小路、樹籬、鄰居房子(陶瓦屋頂、窗戶、煙囪、天窗)、封住地平線的遠方樹牆,並可以搭配 threejs-procedural-vegetation 種樹。當使用者說「天空」「sky shader」「雲」「程式生成天空」「不用 HDRI」「窗外景色」「遠景」「背景房子」「地平線」「大氣透視」「霧化」「窗外的樹」「天空和光照對不上」「清晨/黃昏/陰天的天空」「只建看得到的東西」時使用。.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ammosu/claude-threejs-photoreal/tree/HEAD/skills/threejs-sky-backdrop

Installed? Explore more 图像 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Sky and Backdrop

Source: room-at-dawn (MIT), from src/scene/sky.js, src/scene/parts/exterior.js.

Core idea: Describe the sky only once.

  • The baker uses an analytical sky: a gradient from horizon to zenith, plus a glow around the sun direction.
  • The visible sky dome adds clouds on top of the same gradient, but preserves the same average brightness as the gradient: sky between clouds is darker than average, cloud edges brighter, cloud centers roughly equal.
  • This way the sky seen through the window matches the light falling into the room. measureDome verifies this.

Files

PathContent
scripts/sky.jsSKIES (dawn, day, overcast, golden), skyRadiance (same formula as the threejs-baked-gi worker), bakeCfg, skyDome, SKY_U (uTime), skyLights, skyEnvironment, measureDome
scripts/backdrop.jswindowVisibility (window hole visibility with LOD), hazePatch (atmospheric haze, preserves existing shader patches), grassTexture, roofTexture, windowTexture, crownTexture, Soup, houses, lawn, gravelPath, hedge, crownWall
example/Second-floor room (floor 5.5 m above garden) looking out at: lawn, path, hedge, three houses, trees, distant tree wall
example/preview*.jpgFour skies from inside the room; in front of window, looking up; outside overview
references/sky.mdEach layer of the sky shader, default parameters, how to adjust, integration with baking
references/backdrop.mdVisibility culling, haze, each backdrop element, performance data, known issues, porting to other engines

The example trees use threejs-procedural-vegetation (relative path ../../threejs-procedural-vegetation/).

Running the Example

cd <skill folder>/.. && python3 -m http.server 5426 --bind 127.0.0.1
# http://127.0.0.1:5426/threejs-sky-backdrop/example/

(<skill folder> is the Base directory shown when loading this skill; when installed as a plugin, it's under ~/.claude/plugins/cache/)

  • ?sky=dawn|day|overcast|golden: Sky preset.
  • ?cam=window|wide|up|out: View from room / in front of window / looking up / outside overview.
  • ?cull=0: Disable visibility culling for comparison.
  • ?t=5: Freeze time, clouds don't move.

window.__sky contains timing, triangle count, leaf count, and the ratio of the sky dome to the analytical sky.

Usage

import { SKIES, skyDome, bakeCfg, skyLights, skyEnvironment, measureDome, SKY_U } from './scripts/sky.js';
const S = SKIES.dawn;
scene.add(skyDome(S));                                       // Baked interior: display 0.3 (default); outdoors: skyDome(S, { display: 1 })
const cfg = { ...bakeCfg(S), portal, room };                 // Pass to threejs-baked-gi's runBake
// Unbaked scene:
const { sun, hemi } = skyLights(S); scene.add(hemi); if (sun) scene.add(sun, sun.target);
scene.environment = skyEnvironment(renderer, S);
console.log(measureDome(renderer, S));                       // ratio 0.85–1.15
renderer.setAnimationLoop((ms) => { SKY_U.uTime.value = ms / 1000; ... });

Must Follow

  1. Describe the sky only once: Baking, sky dome, and lights all come from the same preset. If you change the sky color, rebake.
  2. Run measureDome after adjusting clouds. It renders the sky dome into a float cube map, computes the upper hemisphere average weighted by cos, and compares it to the analytical sky.
    • Ratio must be between 0.85–1.15, otherwise the sky outside won't match the light coming in.
    • Adding { pure: true } renders only the gradient; the result must be exactly 1.000, confirming the measurement itself is correct.
  3. Cloud colors are absolute brightness, in the same unit as the sky, not a multiplier. I tried scaling them with the gradient, but the dawn ratio dropped to 0.73, so I reverted to the original project's approach.
  4. In a baked interior, draw the sky dome darker (display around 0.3). Exposure is set for the interior; drawing the sky at full brightness washes it out to white, losing color—this is unrelated to lighting intensity.
  5. Only build what is visible. windowVisibility looks from multiple eye positions inside the room, through window openings with thickness.
    • Invisible leaves: return 0 from the vegetation skill's lodAt, leaving only a few large cards so that baking still produces shadows.
    • Leaves only visible at an angle: return 1, sparser.
  6. Apply hazePatch to the backdrop. Beyond 10 m, colors fade toward the horizon; otherwise distant houses and trees look as deep and saturated as close objects, like stickers.

Benchmarks (RTX 4090, Chrome headless, 1280×800)

ItemValue
Sky dome ÷ analytical skydawn 0.934, day 1.080, overcast 1.034, golden 1.034; pure mode 1.000
Backdrop (lawn, path, hedge, houses, tree wall)31–34 ms
Trees (4 main, 8 mid, 26 distant)Generation 0.14–0.16 s, mesh construction 0.31 s
Visibility cullingLeaves 117,808 → 97,589 (−17%), triangles 425k → 383k. Savings mainly from trees flush against the outer wall and on both sides of the windows
Sky environment map plus two measurements~0.09 s

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

threejs-photoreal-interior

用 three.js 從零做一個照片級的室內場景,完全用程式生成、不需要模型檔、貼圖或 HDRI 的總綱與起手式。內容包括:整體流程(尺寸與座標 → 外殼與窗 → 主角物件 → 材質 → 小物 → 烘焙光照 → 後製 → 驗證 → 電影輸出)、各步驟該用哪個 skill、跨 skill 整合的規則(決定性、細分、材質要經過 GI 補丁且保留原本的 shader 補丁、反照率、太陽直射與烘焙分工、陰影漏光)、一個指令就能建立可執行的新專案(房間、窗、木地板、牆面、桌椅、掛在椅背的毛巾、書架、杯子、水壺、現場烘焙、後製),以及驗收清單和實測數字。當使用者說「做一個寫實的房間/室內」「three.js 照片級場景」「程式生成整個場景」「不用模型做室內」「room-at-dawn 那種」「從哪裡開始做寫實 3D 場景」「開一個新的寫實場景專案」「把這些 skill 串起來」「寫實室內場景流程」時使用;做其中單一環節時,直接用對應的子 skill。

threejs-procedural-cloth

用程式「設計」出照片級的靜態布料(不做物理模擬):沒鋪好的棉被、毯子、桌巾、垂下床緣或桌緣的布、翻起一角的被子、布上放東西,以及掛在桿子上的窗簾(吊環夾出的折、往下鬆開與散開、綁起下擺、車線與雙層縫邊、亞麻平織)。方法是平面高度場(團塊+有方向的長折+削峰+逐條畫上的皺褶)→ 包到支撐物上 → 高的折往一側倒 → 翻角 → 依 3D 曲面攤平 UV → 細皺紋 normal map+凹處變暗,含可重用程式庫、分階段範例、驗證數據,以及搬到 Godot/Unreal 的做法。當使用者說「程式生成布料」「棉被/床單/毯子/桌巾建模」「布料皺褶」「布垂下床邊」「被子翻一角」「布料不要用模擬」「cloth without simulation」「procedural cloth」「布上的花紋被拉長」「布料看起來像塑膠/像山」「窗簾建模」「程式生成窗簾」「窗簾皺褶」「curtain」「布簾」時使用。

threejs-procedural-textures

在 three.js 用程式即時生成照片級材質貼圖(不用任何圖檔):可無縫重複的雜訊、以公釐為單位的高度場轉 normal map、粗糙度與 AO 打包、Canvas2D 轉貼圖、平均反照率(給光照烘焙用)、接縫檢查。內含現成的材質:滾筒漆木屑壁紙加上大尺度的灰泥與漆色變化、烤漆橘皮紋、手摸過的粗糙度、積灰、橡木地板(交錯接縫、每片紋理不同、節疤、四邊微倒角)、通用木紋、對拼橡木貼皮、平織、鬆餅格、毛巾布、羅紋、針織、毛氈、棉繩、使用痕跡(灰塵、油脂、指紋、碎屑、棉絮、頭髮、杯印、細刮痕,同時畫進顏色與粗糙度)、斑點釉、粉體塗裝刮傷、書封圖集與對應 UV 的書本幾何、書頁邊、地形圖海報、照片、假文字。當使用者說「程式生成貼圖」「procedural texture」「不用圖檔的材質」「normal map 怎麼產生」「木地板/木紋貼圖」「牆面看起來太假」「布料材質」「針織/毛巾布 normal map」「使用痕跡」「刮痕/指紋/灰塵」「粗糙度貼圖」「書封/書背」「假文字」「貼圖有接縫」「Canvas 畫貼圖」時使用。

相关技能