Skip to content

Professional Blender 5.2 workflows as Agent Skills for Claude Code, Codex, Gemini CLI, Copilot and Cursor: modeling, UVs, PBR, baking, rigging, animation, export and QA.

Release 1.1.0: time-of-day and weather skills

EL4CTEO71d031dab8bc
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 9061733..d380929 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -6,7 +6,7 @@
{
"name": "blender-agent-skills",
"source": "./",
- "description": "20 tested Blender skills: model, UV, texture, bake, rig, animate, optimize, export, render, QA"
+ "description": "22 tested Blender skills: model, UV, texture, bake, rig, animate, optimize, export, render, time of day, weather, QA"
}
]
}
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index eaebfec..768ef08 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "blender-agent-skills",
- "version": "0.1.0",
- "description": "Professional Blender 5.2 workflows for AI agents: modeling, retopo/UV, PBR, baking, rigging, animation, optimization, export (Roblox/Unity/Unreal/Godot/web), rendering, simulation, QA.",
+ "version": "1.1.0",
+ "description": "Professional Blender 5.2 workflows for AI agents: modeling, retopo/UV, PBR, baking, rigging, animation, optimization, export (Roblox/Unity/Unreal/Godot/web), rendering, time of day, weather, simulation, QA.",
"author": { "name": "EL4CTEO" },
"homepage": "https://github.com/EL4CTEO/blender-skills",
"repository": "https://github.com/EL4CTEO/blender-skills",
diff --git a/AGENTS.md b/AGENTS.md
index aea157d..79cf72a 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -26,6 +26,8 @@ This repo contains Agent Skills (`skills/<name>/SKILL.md`, agentskills.io format
| blender-rendering | Cycles/EEVEE, color management, batch |
| blender-lighting-lookdev | lights, HDRI, cameras, turntables |
| blender-simulation | rigid body, cloth (classic + 5.2 nodes), fluids |
+| blender-time-of-day | sky/sun/moon by time, night, fog, moods |
+| blender-weather-fx | rain, snow, wetness, puddles, lightning |
| blender-addon-development | extensions, operators, UI |
| blender-pipeline-automation | headless batch, conversion, CI |
| blender-asset-qa | review gate: z-fighting, floating parts, normals, UVs, weights |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5cb729..0cfafec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,9 @@
# Changelog
-## [Unreleased]
-- README banner and Blender-style icon.
+## [1.1.0] - 2026-10-16
+- New `blender-time-of-day`: sky + sun measured from Blender's sky model, night with moon/stars, fog from visibility, moods (cyberpunk, horror, underwater, desert).
+- New `blender-weather-fx`: looping rain/snow/dust/embers, wet surfaces, puddles with ripples, snow cover, lightning.
+- With vs without skills comparison page, README banner and icon.
## [0.1.0] - 2026-10-14
- 20 Blender 5.2 skills for AI agents (Claude Code, Codex, OpenCode, Gemini CLI, Copilot, Cursor).
diff --git a/README.md b/README.md
index e96d8ef..093ce81 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
Professional Blender workflows packaged as **Agent Skills** for AI coding agents: Claude Code, Codex, OpenCode, Gemini CLI, GitHub Copilot and Cursor.
-There are 20 skills covering the full 3D pipeline (modeling, UVs, PBR, baking, rigging, animation, optimization, export, rendering, simulation and QA), built for **Blender 5.2 LTS+**. Every script is tested in a real Blender.
+There are 22 skills covering the full 3D pipeline (modeling, UVs, PBR, baking, rigging, animation, optimization, export, rendering, time of day, weather, simulation and QA), built for **Blender 5.2 LTS+**. Every script is tested in a real Blender.
## Install
@@ -44,22 +44,31 @@ The default installs into `~/.claude/skills` and `~/.agents/skills`. `.agents/sk
| `blender-rendering` | Cycles and EEVEE, batch rendering |
| `blender-lighting-lookdev` | Studio lighting, HDRI, turntables |
| `blender-simulation` | Rigid bodies, cloth, fluids |
+| `blender-time-of-day` | Golden hour, night, fog and mood lighting |
+| `blender-weather-fx` | Rain, snow, wet streets, puddles, lightning |
| `blender-addon-development` | Blender extensions |
| `blender-pipeline-automation` | Batch jobs and file conversion |
| `blender-asset-qa` | Catches z-fighting, floating parts, bad normals and weights |
| `blender-workflow-recipes` | Complete asset playbooks |
+## With vs without skills
+
+Same model, same prompts, outputs with the skills vs without them: **[see the comparison](https://el4cteo.github.io/blender-skills/comparison/)**.
+
+<a href="https://el4cteo.github.io/blender-skills/comparison/"><img src="docs/comparison/media/preview.jpg" alt="Concrete wall: without skills (left) vs with skills (right)"></a>
+
## Try it
> "Make a game-ready crate for Unreal with baked normals and LODs."
> "Rig this character with Rigify and export it to Unity with a walk cycle."
> "Check this model for z-fighting and floating parts, then export it for Roblox."
+> "Make this street a rainy night with puddles and lightning."
## Development
```bash
python tools/validate_skills.py # spec + token budget checks
-python tools/run_tests.py # 43 headless Blender tests (BLENDER_EXE to override)
+python tools/run_tests.py # 50 headless Blender tests (BLENDER_EXE to override)
```
MIT License
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000..80785be
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1,2 @@
+exclude:
+ - reddit-post.md
diff --git a/docs/comparison/index.html b/docs/comparison/index.html
new file mode 100644
index 0000000..ce26af0
--- /dev/null
+++ b/docs/comparison/index.html
@@ -0,0 +1,159 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Skills vs No Skills</title>
+<meta name="description" content="Same model, same prompt: Blender results with and without Blender Agent Skills.">
+<style>
+ :root {
+ --bg: #111214; --panel: #1a1c1f; --line: #2b2e33; --text: #e8e9eb; --muted: #9a9ea6;
+ --no: #e0795f; --yes: #4fb3a6;
+ }
+ * { box-sizing: border-box; }
+ body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
+ main { max-width: 1180px; margin: 0 auto; padding: 48px 16px 80px; }
+ a { color: var(--yes); }
+ header h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 8px; letter-spacing: -0.01em; }
+ header p { color: var(--muted); margin: 0; max-width: 720px; }
+ .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
+ .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
+ section { margin-top: 64px; }
+ h2 { font-size: 24px; margin: 0 0 4px; }
+ h2 span { color: var(--muted); font-weight: 500; }
+ .prompts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 20px; }
+ .prompt { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
+ .prompt b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
+ .prompt.no b { color: var(--no); } .prompt.yes b { color: var(--yes); }
+ .prompt q { color: var(--text); quotes: none; }
+ .hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
+ h3 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 28px 0 10px; }
+
+ /* before/after slider */
+ .slider { position: relative; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: #000; user-select: none; touch-action: pan-y; cursor: ew-resize; }
+ .slider img { display: block; width: 100%; height: auto; pointer-events: none; }
+ .slider .top { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
+ .slider .bar { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 8px rgba(0,0,0,.6); }
+ .slider .bar::after { content: "\2194"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 16px; }
+ .tag { position: absolute; top: 10px; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; color: #111; pointer-events: none; }
+ .tag.no { left: 10px; background: var(--no); } .tag.yes { right: 10px; background: var(--yes); }
+ .slider input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
+
+ /* side by side */
+ .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
+ .pair figure { margin: 0; position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #000; }
+ .pair video, .pair img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
+ .pair.wide video { aspect-ratio: 16 / 9; }
+ .controls { display: flex; gap: 8px; margin-top: 10px; }
+ button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
+ button:hover { border-color: var(--muted); }
+
+ .notes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
+ .note { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
+ .note b { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
+ .note.no b { color: var(--no); } .note.yes b { color: var(--yes); }
+ .note ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
+ footer { margin-top: 72px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 20px; }
+
+ @media (max-width: 700px) {
+ main { padding-top: 32px; }
+ .prompts, .notes, .pair { grid-template-columns: 1fr; }
+ }
+</style>
+</head>
+<body>
+<main>
+ <header>
+ <h1>Skills vs No Skills</h1>
+ <p>Same model, same task, run twice: once with <a href="https://github.com/EL4CTEO/blender-skills">Blender Agent Skills</a>, once in an isolated environment without them. Every result is <b>one shot</b>: a single prompt, no follow-ups, no retries, nothing edited by hand.</p>
+ <div class="meta">
+ <span class="chip">Model: Opus 5.5 (medium)</span>
+ <span class="chip">Blender 5.2</span>
+ <span class="chip">One shot, no retries</span>
+ <span class="chip">3 tasks</span>
+ </div>
+ </header>
+
+ <!-- 1. Concrete -->
+ <section id="concrete">
+ <h2>1. 4K PBR concrete wall <span>/ texture + render</span></h2>
+ <div class="prompts">
+ <div class="prompt no"><b>Without skills</b><q>Create a 4k PBR concrete wall in Blender then render it, don't use any skills and don't sneak peek in other folders, isolated environment.</q></div>
+ <div class="prompt yes"><b>With skills</b><q>Create a 4k PBR concrete wall in Blender then render it, use any of the existing 20 Blender skills before proceeding.</q></div>
+ </div>
+ <h3>Hero render (3840 x 2160, downscaled)</h3>
+ <div class="slider"><img src="media/concrete-hero-skill.webp" alt="With skills"><img class="top" src="media/concrete-hero-noskill.webp" alt="Without skills"><div class="bar"></div><span class="tag no">Without</span><span class="tag yes">With skills</span><input type="range" min="0" max="100" value="50" aria-label="Compare"></div>
+ <h3>100% crop from the 4K render</h3>
+ <div class="slider"><img src="media/concrete-hero-skill-crop.webp" alt="With skills"><img class="top" src="media/concrete-hero-noskill-crop.webp" alt="Without skills"><div class="bar"></div><span class="tag no">Without</span><span class="tag yes">With skills</span><input type="range" min="0" max="100" value="50" aria-label="Compare"></div>
+ <h3>Detail camera</h3>
+ <div class="slider"><img src="media/concrete-detail-skill.webp" alt="With skills"><img class="top" src="media/concrete-detail-noskill.webp" alt="Without skills"><div class="bar"></div><span class="tag no">Without</span><span class="tag yes">With skills</span><input type="range" min="0" max="100" value="50" aria-label="Compare"></div>
+ <p class="hint">Drag to compare.</p>
+ <div class="notes">
+ <div class="note no"><b>Without skills produced</b><ul><li>BaseColor, Roughness, AO, Height, Normal (OpenGL + DirectX)</li><li>2 renders, 1 review sheet</li></ul></div>
+ <div class="note yes"><b>With skills produced</b><ul><li>Procedural source baked to BaseColor, Roughness, AO, Height, Normal</li><li>Packed ORM map (engine-ready)</li><li>Separate bake and scene scripts, 2 camera renders</li></ul></div>
+ </div>
+ </section>
+
+ <!-- 2. Blanket -->
+ <section id="blanket">
+ <h2>2. Blanket falling on a bed <span>/ cloth simulation + GIF</span></h2>
+ <div class="prompts">
+ <div class="prompt no"><b>Without skills</b><q>Create a Blender 3D scene animation of a blanket falling onto a bed mesh, realistic physics, export as GIF in the end, don't use any skills and don't sneak peek in other folders, isolated environment.</q></div>
+ <div class="prompt yes"><b>With skills</b><q>Create a Blender 3D scene animation of a blanket falling onto a bed mesh, realistic physics, export as GIF in the end, use any of the existing 20 Blender skills before proceeding.</q></div>
+ </div>
+ <div class="pair">
+ <figure><video src="media/blanket-noskill.mp4" poster="media/blanket-noskill-poster.webp" muted loop playsinline preload="auto"></video><span class="tag no">Without</span></figure>
+ <figure><video src="media/blanket-skill.mp4" poster="media/blanket-skill-poster.webp" muted loop playsinline preload="auto"></video><span class="tag yes">With skills</span></figure>
+ </div>
+ <div class="controls"><button class="play">Pause</button><button class="restart">Restart both</button></div>
+ <div class="notes">
+ <div class="note no"><b>Without skills produced</b><ul><li>96-frame GIF, 640 x 480</li><li>Plain blanket, bed without pillows</li></ul></div>
+ <div class="note yes"><b>With skills produced</b><ul><li>96-frame GIF, 560 x 420</li><li>Plaid fabric, pillows, baked cloth cache</li><li>QA review sheet of key frames</li></ul></div>
+ </div>
+ </section>
+
+ <!-- 3. Pistol -->
+ <section id="pistol">
+ <h2>3. PBR pistol <span>/ modeling + shot and reload animation</span></h2>
+ <div class="prompts">
+ <div class="prompt no"><b>Without skills</b><q>Create a realistic PBR pistol in Blender and animate it firing a shot and then reloading, render the animation and export as GIF in the end, don't use any skills and don't sneak peek in other folders, isolated environment.</q></div>
+ <div class="prompt yes"><b>With skills</b><q>Create a realistic PBR pistol in Blender and animate it firing a shot and then reloading, render the animation and export as GIF in the end, use any of the existing 20 Blender skills before proceeding.</q></div>
+ </div>
+ <div class="pair wide">
+ <figure><video src="media/pistol-noskill.mp4" poster="media/pistol-noskill-poster.webp" muted loop playsinline preload="auto"></video><span class="tag no">Without</span></figure>
+ <figure><video src="media/pistol-skill.mp4" poster="media/pistol-skill-poster.webp" muted loop playsinline preload="auto"></video><span class="tag yes">With skills</span></figure>
+ </div>
+ <div class="controls"><button class="play">Pause</button><button class="restart">Restart both</button></div>
+ <div class="notes">
+ <div class="note no"><b>Without skills produced</b><ul><li>96-frame GIF, 640 x 360</li><li>Test frames and a review sheet</li></ul></div>
+ <div class="note yes"><b>With skills produced</b><ul><li>88-frame GIF, 720 x 405</li><li>19 named parts (slide, barrel, mag, pins, sights)</li><li>Mesh QA pass: no z-fighting, no floating parts, clean manifold geometry</li><li>Multi-angle wireframe review renders</li></ul></div>
+ </div>
+ </section>
+
+ <footer>Get the skills: <a href="https://github.com/EL4CTEO/blender-skills">github.com/EL4CTEO/blender-skills</a></footer>
+</main>
+<script>
+ document.querySelectorAll('.slider').forEach(function (s) {
+ var input = s.querySelector('input');
+ var set = function () { s.style.setProperty('--pos', input.value + '%'); };
+ input.addEventListener('input', set); set();
+ });
+
+ document.querySelectorAll('.pair').forEach(function (pair) {
+ var vids = Array.prototype.slice.call(pair.querySelectorAll('video'));
+ var controls = pair.nextElementSibling;
+ if (vids.length < 2 || !controls) return;
+ var playBtn = controls.querySelector('.play');
+ function playAll() { vids.forEach(function (v) { var p = v.play(); if (p) p.catch(function () {}); }); playBtn.textContent = 'Pause'; }
+ function restart() { vids.forEach(function (v) { v.currentTime = 0; }); playAll(); }
+ playBtn.addEventListener('click', function () {
+ if (vids[0].paused) { playAll(); } else { vids.forEach(function (v) { v.pause(); }); playBtn.textContent = 'Play'; }
+ });
+ controls.querySelector('.restart').addEventListener('click', restart);
+ // keep both clips in step: when the first loops, restart the second
+ vids[0].addEventListener('seeked', function () { if (vids[0].currentTime < 0.1) vids[1].currentTime = 0; });
+ restart();
+ });
+</script>
+</body>
+</html>
diff --git a/docs/comparison/media/blanket-noskill-poster.webp b/docs/comparison/media/blanket-noskill-poster.webp
new file mode 100644
index 0000000..e4a9a05
Binary files /dev/null and b/docs/comparison/media/blanket-noskill-poster.webp differ
diff --git a/docs/comparison/media/blanket-noskill.mp4 b/docs/comparison/media/blanket-noskill.mp4
new file mode 100644
index 0000000..73e8bb2
Binary files /dev/null and b/docs/comparison/media/blanket-noskill.mp4 differ
diff --git a/docs/comparison/media/blanket-skill-poster.webp b/docs/comparison/media/blanket-skill-poster.webp
new file mode 100644
index 0000000..3a7a10c
Binary files /dev/null and b/docs/comparison/media/blanket-skill-poster.webp differ
diff --git a/docs/comparison/media/blanket-skill.mp4 b/docs/comparison/media/blanket-skill.mp4
new file mode 100644
index 0000000..49031b2
Binary files /dev/null and b/docs/comparison/media/blanket-skill.mp4 differ
diff --git a/docs/comparison/media/concrete-detail-noskill.webp b/docs/comparison/media/concrete-detail-noskill.webp
new file mode 100644
index 0000000..242c910
Binary files /dev/null and b/docs/comparison/media/concrete-detail-noskill.webp differ
diff --git a/docs/comparison/media/concrete-detail-skill.webp b/docs/comparison/media/concrete-detail-skill.webp
new file mode 100644
index 0000000..ac2a46e
Binary files /dev/null and b/docs/comparison/media/concrete-detail-skill.webp differ
diff --git a/docs/comparison/media/concrete-hero-noskill-crop.webp b/docs/comparison/media/concrete-hero-noskill-crop.webp
new file mode 100644
index 0000000..b7427b9
Binary files /dev/null and b/docs/comparison/media/concrete-hero-noskill-crop.webp differ
diff --git a/docs/comparison/media/concrete-hero-noskill.webp b/docs/comparison/media/concrete-hero-noskill.webp
new file mode 100644
index 0000000..4d3330e
Binary files /dev/null and b/docs/comparison/media/concrete-hero-noskill.webp differ
diff --git a/docs/comparison/media/concrete-hero-skill-crop.webp b/docs/comparison/media/concrete-hero-skill-crop.webp
new file mode 100644
index 0000000..6da495c
Binary files /dev/null and b/docs/comparison/media/concrete-hero-skill-crop.webp differ
diff --git a/docs/comparison/media/concrete-hero-skill.webp b/docs/comparison/media/concrete-hero-skill.webp
new file mode 100644
index 0000000..1ab4e27
Binary files /dev/null and b/docs/comparison/media/concrete-hero-skill.webp differ
diff --git a/docs/comparison/media/pistol-noskill-poster.webp b/docs/comparison/media/pistol-noskill-poster.webp
new file mode 100644
index 0000000..b64fb0e
Binary files /dev/null and b/docs/comparison/media/pistol-noskill-poster.webp differ
diff --git a/docs/comparison/media/pistol-noskill.mp4 b/docs/comparison/media/pistol-noskill.mp4
new file mode 100644
index 0000000..3f833a0
Binary files /dev/null and b/docs/comparison/media/pistol-noskill.mp4 differ
diff --git a/docs/comparison/media/pistol-skill-poster.webp b/docs/comparison/media/pistol-skill-poster.webp
new file mode 100644
index 0000000..9125705
Binary files /dev/null and b/docs/comparison/media/pistol-skill-poster.webp differ
diff --git a/docs/comparison/media/pistol-skill.mp4 b/docs/comparison/media/pistol-skill.mp4
new file mode 100644
index 0000000..d1798e1
Binary files /dev/null and b/docs/comparison/media/pistol-skill.mp4 differ
diff --git a/docs/comparison/media/preview.jpg b/docs/comparison/media/preview.jpg
new file mode 100644
index 0000000..cd5fca0
Binary files /dev/null and b/docs/comparison/media/preview.jpg differ
diff --git a/skills/blender-addon-development/SKILL.md b/skills/blender-addon-development/SKILL.md
index ded27f9..e89ad6d 100644
--- a/skills/blender-addon-development/SKILL.md
+++ b/skills/blender-addon-development/SKILL.md
@@ -4,7 +4,7 @@ description: Write Blender 5.2 add-ons as extensions - blender_manifest.toml, op
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Add-on (Extension) Development
diff --git a/skills/blender-animation/SKILL.md b/skills/blender-animation/SKILL.md
index 3186a09..2afcd11 100644
--- a/skills/blender-animation/SKILL.md
+++ b/skills/blender-animation/SKILL.md
@@ -4,7 +4,7 @@ description: Animation in Blender 5.2 - slotted/layered actions and the channelb
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Animation
diff --git a/skills/blender-asset-qa/SKILL.md b/skills/blender-asset-qa/SKILL.md
index b4ba4c7..b0b9073 100644
--- a/skills/blender-asset-qa/SKILL.md
+++ b/skills/blender-asset-qa/SKILL.md
@@ -4,7 +4,7 @@ description: Mandatory review gate for any mesh or asset created or edited in Bl
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Asset QA (review gate)
diff --git a/skills/blender-character-rigging/SKILL.md b/skills/blender-character-rigging/SKILL.md
index 86a9944..e7c4fea 100644
--- a/skills/blender-character-rigging/SKILL.md
+++ b/skills/blender-character-rigging/SKILL.md
@@ -4,7 +4,7 @@ description: Character rigging in Blender 5.2 - Rigify metarig fit/generate, bon
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Character Rigging
diff --git a/skills/blender-core/SKILL.md b/skills/blender-core/SKILL.md
index 6a432e6..44128f8 100644
--- a/skills/blender-core/SKILL.md
+++ b/skills/blender-core/SKILL.md
@@ -5,7 +5,7 @@ license: MIT
compatibility: Blender 5.2 LTS or newer. Optional blender-mcp server for live sessions.
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Blender Core (5.2 LTS+)
@@ -27,6 +27,8 @@ metadata:
| Export: glTF/FBX/USD to Roblox, Unity, Unreal, Godot, web | `blender-export-pipelines` |
| Cycles/EEVEE settings, compositor, batch render | `blender-rendering` |
| Lighting, HDRI, camera, turntable | `blender-lighting-lookdev` |
+| Time of day, night, sunset, fog, mood (cyberpunk, horror...) | `blender-time-of-day` |
+| Rain, snow, wet surfaces, puddles, lightning, dust/embers | `blender-weather-fx` |
| Cloth, rigid body, fluids, hair, GN physics | `blender-simulation` |
| Writing add-ons / extensions | `blender-addon-development` |
| Batch/headless pipelines, file conversion | `blender-pipeline-automation` |
diff --git a/skills/blender-export-pipelines/SKILL.md b/skills/blender-export-pipelines/SKILL.md
index c013b62..8172db7 100644
--- a/skills/blender-export-pipelines/SKILL.md
+++ b/skills/blender-export-pipelines/SKILL.md
@@ -4,7 +4,7 @@ description: Export from Blender 5.2 with verified presets - Roblox (FBX/glTF, c
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Export Pipelines
diff --git a/skills/blender-facial-shapekeys/SKILL.md b/skills/blender-facial-shapekeys/SKILL.md
index a6ea2bb..2c75722 100644
--- a/skills/blender-facial-shapekeys/SKILL.md
+++ b/skills/blender-facial-shapekeys/SKILL.md
@@ -4,7 +4,7 @@ description: Facial rigs and shape keys in Blender 5.2 - ARKit 52 blendshapes, v
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Facial Rig & Shape Keys
diff --git a/skills/blender-game-optimization/SKILL.md b/skills/blender-game-optimization/SKILL.md
index 8c27505..f648df3 100644
--- a/skills/blender-game-optimization/SKILL.md
+++ b/skills/blender-game-optimization/SKILL.md
@@ -4,7 +4,7 @@ description: Optimize Blender assets for real-time engines - triangle/material/t
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Game Optimization
diff --git a/skills/blender-geometry-nodes/SKILL.md b/skills/blender-geometry-nodes/SKILL.md
index ac3433c..f3b3fea 100644
--- a/skills/blender-geometry-nodes/SKILL.md
+++ b/skills/blender-geometry-nodes/SKILL.md
@@ -4,7 +4,7 @@ description: Geometry Nodes in Blender 5.2 - fields, domains, attributes, instan
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Geometry Nodes
diff --git a/skills/blender-hardsurface-modeling/SKILL.md b/skills/blender-hardsurface-modeling/SKILL.md
index 5f54854..1838e20 100644
--- a/skills/blender-hardsurface-modeling/SKILL.md
+++ b/skills/blender-hardsurface-modeling/SKILL.md
@@ -4,7 +4,7 @@ description: Hard-surface and prop modeling in Blender 5.2 - blockout-to-detail
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Hard-Surface Modeling
diff --git a/skills/blender-lighting-lookdev/SKILL.md b/skills/blender-lighting-lookdev/SKILL.md
index 0f6469e..b0c8447 100644
--- a/skills/blender-lighting-lookdev/SKILL.md
+++ b/skills/blender-lighting-lookdev/SKILL.md
@@ -4,12 +4,12 @@ description: Lighting, cameras and look-dev in Blender 5.2 - studio 3-point and
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Lighting & Look-dev
-The execution model is in `blender-core`. Render settings are in `blender-rendering`.
+The execution model is in `blender-core`. Render settings are in `blender-rendering`. Full time-of-day, night and fog environments are in `blender-time-of-day`.
## One call: presentation scene
```
diff --git a/skills/blender-pbr-materials/SKILL.md b/skills/blender-pbr-materials/SKILL.md
index 7637db6..e8604b8 100644
--- a/skills/blender-pbr-materials/SKILL.md
+++ b/skills/blender-pbr-materials/SKILL.md
@@ -4,7 +4,7 @@ description: Physically based materials in Blender 5.2 - metal/roughness rules,
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# PBR Materials
diff --git a/skills/blender-pipeline-automation/SKILL.md b/skills/blender-pipeline-automation/SKILL.md
index eee933b..7f9f171 100644
--- a/skills/blender-pipeline-automation/SKILL.md
+++ b/skills/blender-pipeline-automation/SKILL.md
@@ -4,7 +4,7 @@ description: Automate Blender 5.2 at scale - headless CLI flags, batch convert/i
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Pipeline Automation
diff --git a/skills/blender-rendering/SKILL.md b/skills/blender-rendering/SKILL.md
index 1912e41..537fb8b 100644
--- a/skills/blender-rendering/SKILL.md
+++ b/skills/blender-rendering/SKILL.md
@@ -4,7 +4,7 @@ description: Render with Blender 5.2 Cycles/EEVEE/Workbench - quality presets, G
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Rendering
diff --git a/skills/blender-retopology-uv/SKILL.md b/skills/blender-retopology-uv/SKILL.md
index 12b3637..5372468 100644
--- a/skills/blender-retopology-uv/SKILL.md
+++ b/skills/blender-retopology-uv/SKILL.md
@@ -4,7 +4,7 @@ description: Retopology and UVs in Blender 5.2 - auto retopo (Quadriflow, Decima
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Retopology & UVs
diff --git a/skills/blender-scene-setup/SKILL.md b/skills/blender-scene-setup/SKILL.md
index e0bf836..15f1c2f 100644
--- a/skills/blender-scene-setup/SKILL.md
+++ b/skills/blender-scene-setup/SKILL.md
@@ -4,7 +4,7 @@ description: Set up and audit Blender scenes the way studios do - units and real
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Scene Setup & Hygiene
diff --git a/skills/blender-sculpting/SKILL.md b/skills/blender-sculpting/SKILL.md
index 4ea4174..301310a 100644
--- a/skills/blender-sculpting/SKILL.md
+++ b/skills/blender-sculpting/SKILL.md
@@ -4,7 +4,7 @@ description: Sculpting in Blender 5.2 - base-to-detail workflow, voxel remesh, d
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Sculpting
diff --git a/skills/blender-simulation/SKILL.md b/skills/blender-simulation/SKILL.md
index 55cda89..bcb0f0e 100644
--- a/skills/blender-simulation/SKILL.md
+++ b/skills/blender-simulation/SKILL.md
@@ -4,7 +4,7 @@ description: Physics in Blender 5.2 - rigid bodies (density mass, shapes, bake t
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Simulation
diff --git a/skills/blender-texture-baking/SKILL.md b/skills/blender-texture-baking/SKILL.md
index acc47ca..1685203 100644
--- a/skills/blender-texture-baking/SKILL.md
+++ b/skills/blender-texture-baking/SKILL.md
@@ -4,7 +4,7 @@ description: Bake texture maps in Blender 5.2 Cycles - high-to-low normal maps w
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Texture Baking (Cycles)
diff --git a/skills/blender-time-of-day/SKILL.md b/skills/blender-time-of-day/SKILL.md
new file mode 100644
index 0000000..d3c1835
--- /dev/null
+++ b/skills/blender-time-of-day/SKILL.md
@@ -0,0 +1,62 @@
+---
+name: blender-time-of-day
+description: Time of day and atmosphere in Blender 5.2 - measured sky + sun for dawn, morning, noon, golden hour, sunset, blue hour, overcast, night/moonlight with stars and city glow, exposure balance, height fog from visibility, god rays, Cycles vs EEVEE volumes, compositor grade, stylized moods (cyberpunk neon, horror, underwater, desert). Use for any day/night, sunset, foggy or mood lighting scene.
+license: MIT
+metadata:
+ author: blender-agent-skills
+ version: "1.1.0"
+---
+
+# Time of Day & Atmosphere
+
+The execution model is in `blender-core`. Studio and product lighting are in `blender-lighting-lookdev`, render settings in `blender-rendering`, and rain, snow, wetness and lightning in `blender-weather-fx`.
+
+## One call
+```
+scripts/scene_mood.py -- --time golden # sun 6 deg, warm, long shadows
+scripts/scene_mood.py -- --time night --fog-visibility 250 # moonlight + stars + haze
+scripts/scene_mood.py -- --time noon --overcast 0.8 # soft grey day
+scripts/scene_mood.py -- --mood cyberpunk # moonless, neon rim pair, fog, bloom
+scripts/scene_mood.py -- --time morning --fog-visibility 120 --fog-height 4 # valley fog
+```
+Times: `noon morning afternoon golden sunrise sunset blue_hour night moonless`. Moods: `cyberpunk horror underwater desert` (each sets defaults that explicit flags override). Override the sun with `--elevation DEG` (negative = below the horizon) and `--heading DEG` (0 = +Y, 90 = +X). If you leave out `--heading`, the sun sits 135° from the camera's view direction, which gives side/back light that shows form. Front light looks flat.
+
+The script builds `ENV_World`, the `ENV_Mood` collection (sun or moon, fog box, accent lights) and, for moods, `ENV_Grade` (a compositor tree). Your objects are untouched, and re-running replaces everything it made. It returns the key light's strength, color and elevation, the exposure, and any warnings.
+
+## How it stays physically right
+- **Sky**: `ShaderNodeTexSky` `MULTIPLE_SCATTERING` (5.0+; `SINGLE_SCATTERING` is the legacy "Nishita") with `sun_disc=False`. A **Sun lamp** is the sun, because it gives sharp shadows in both engines. The lamp's color and its strength relative to the sky come from a table **measured from Blender 5.2's own sky model** at each elevation (sunset sun ≈ `[1.0, 0.22, 0]`, noon ≈ `[1.0, 0.86, 0.68]`). That keeps the sky and the sun consistent.
+- **Scale**: noon gives a sun of ≈ 4 W/m² with a grey card at 0.18 under AgX at exposure 0.
+- **Exposure balance**: each preset meters a grey card between the ground and a wall facing the sun, then scales the *environment* lights so the card lands at the preset's brightness (noon 1.0, golden 0.85, sunset 0.7, blue hour 0.35, night 0.2, moonless 0.1). Your practical lights keep their usual wattage and read correctly against it.
+- **Physical alternative**: `--use-exposure` puts the difference in `view_settings.exposure` instead. The result returns `practical_scale`: multiply your lamp wattages by it to keep the same look.
+- **Night**: the moon is a Sun lamp at 0.3 W/m² before scaling (35°, cool `[0.72, 0.82, 1.0]`; moonlight is physically ~4100 K, and it reads blue because of the Purkinje shift). The night dome is a zenith gradient, a city glow at the horizon (sodium orange; magenta for cyberpunk), and stars visible to camera rays only.
+- **Fog**: a box volume around the scene and the camera. Density = **3.912 / visibility** (Koschmieder: visibility in meters → extinction per meter). Add `--fog-height` for an exponential ground fog. Exposure compensates for light lost in fog by up to 4 EV, so fog stays dense instead of just dark. The background seen by the camera is blended toward the fog color.
+
+## Fog and volumetrics
+| Look | `--fog-visibility` (m) |
+|---|---|
+| Clear air / distant haze | 5000–20000 |
+| Haze, desert dust | 1000–3000 |
+| Mist | 500–1000 |
+| Fog | 100–500 |
+| Dense fog, horror | 20–60 |
+| Underwater (clear → murky) | 30 → 8 |
+- **God rays** need four things: a strong key (sun/spot), occluders (windows, trees, a gobo), forward scattering (`--fog-anisotropy 0.6–0.85`), and EEVEE `use_volumetric_shadows` (the script turns it on).
+- **Cycles 5.x** renders volumes with **null scattering** by default (unbiased, no step size). `scene.cycles.volume_biased=True` brings back ray marching (`volume_step_rate`). Height fog is a heterogeneous volume and is noisier, so give it more samples or denoise.
+- **EEVEE** volumes are froxels: `volumetric_tile_size` 4 → 2 for detail, and `volumetric_end` must cover the fog (the script sets it). Very dense fog close to the camera bands, so prefer Cycles for it.
+- Cheap distant haze without volumes: the Mist pass (`view_layer.use_pass_mist`, `world.mist_settings.start/depth`) mixed in the compositor.
+- Deeper detail is in [references/fog-volumetrics.md](references/fog-volumetrics.md).
+
+## Rules
+- Decide the light direction first (side/back), then the time. Low sun (golden, sunset) = long shadows and warm key against a cool sky fill, which is the most flattering combination.
+- Night is not "a blue tint": keep **contrast** (hard moon shadows, pools of warm practicals, dark silhouettes), lower saturation, and add practical sources. See [references/night-and-moods.md](references/night-and-moods.md).
+- Practicals use real color temperatures (`light.use_temperature=True`, `light.temperature`): sodium 2000 K, tungsten 2700 K, warm LED 3000 K, neutral LED 4000 K, neon as emissive tubes. Watts and conversions are in [references/light-values.md](references/light-values.md).
+- Keep the view transform AgX (the script sets it, along with a mood look like `AgX - Punchy`). `--keep-view` preserves yours.
+- Verify every mood with a render, not the viewport: fog, stars and bloom only show in rendered output. Use `blender-rendering` `render_batch.py --preset preview`.
+
+## Gotchas
+- Below the horizon the sky texture shows a dark "ground". Extend the ground plane or terrain to the horizon, or keep the horizon out of frame.
+- The bloom/glare threshold is **scene-linear, before** the view exposure. With `--use-exposure` the script scales the threshold for you.
+- The script won't overwrite a compositor tree that isn't `ENV_Grade`; it reports that instead.
+- `SunLight.use_nodes` and light node trees are deprecated in 5.x (removal planned for 6.0). Use light color and `temperature` instead.
+- The sky texture's `sun_direction` only applies to the legacy Preetham/Hosek models. `sun_rotation` 0 places the sun toward +Y and 90° toward +X (measured).
+- Changing the render engine doesn't need a re-run. The script sets both the EEVEE and Cycles volume settings.
diff --git a/skills/blender-time-of-day/references/fog-volumetrics.md b/skills/blender-time-of-day/references/fog-volumetrics.md
new file mode 100644
index 0000000..8a015fb
--- /dev/null
+++ b/skills/blender-time-of-day/references/fog-volumetrics.md
@@ -0,0 +1,38 @@
+# Fog and volumetrics (5.2)
+
+## Density from visibility
+Meteorological visibility V (m) is where contrast drops to 2%. Extinction σ = 3.912 / V (Koschmieder), in units of 1/m (Blender units = meters). For Principled Volume with a white `Color`, `Density` ≈ σ.
+
+| V (m) | σ (Density) | Look |
+|---|---|---|
+| 10000 | 0.0004 | clear air, distant mountains fade |
+| 2000 | 0.002 | haze |
+| 500 | 0.008 | mist |
+| 150 | 0.026 | fog |
+| 40 | 0.098 | dense fog |
+| 15 | 0.26 | can't see across the street |
+
+**Height fog**: `density(z) = σ · exp(−(z − ground) / H)`, H = 1–3 m (ground fog) or 5–20 m (valley/city). `scene_mood.py --fog-height H` builds it with Geometry Position → Math nodes.
+
+## Phase function (forward scattering = glow around lights and god rays)
+- Principled Volume `Anisotropy` 0.5–0.7 for fog and haze, 0.85 for water. 0 = isotropic, a flat look.
+- Volume Scatter in 5.x has `phase`: `HENYEY_GREENSTEIN`, `FOURNIER_FORAND`, `DRAINE`, `RAYLEIGH`, `MIE`. `MIE` + `Diameter` (µm; fog droplets ~10–20) is the most physical choice for fog in Cycles. `RAYLEIGH` suits clear-air blue scattering. Principled Volume `Anisotropy` is the safe choice when a file must render in both engines.
+
+## Cycles
+- 5.0+: **null scattering** is the default (unbiased, handles mixed dense/thin volumes, no step size). `cycles.volume_biased = True` restores ray marching (`volume_step_rate`, `volume_max_steps`), which is sometimes faster for simple homogeneous fog.
+- `cycles.volume_bounces` 0 = single scattering (fast, darker). 1–2 for dense, bright fog.
+- Noise: volumes converge slowly. Use 256+ spp with adaptive sampling, the OIDN denoiser, and a **separate fog pass**: put the fog box in its own view layer, set the other objects to holdout, and composite. Fog denoises much better alone.
+- `use_volume_guiding` (path guiding, CPU) helps dense lit fog.
+
+## EEVEE (5.x)
+- Froxel grid: `eevee.volumetric_tile_size` "2"/"4"/"8", `volumetric_samples` 64–128, and `volumetric_start/end`: the range must enclose the fog, and a tight range gives more precision.
+- `use_volumetric_shadows` (+ `volumetric_shadow_samples`) is required for god rays.
+- `volumetric_ray_depth` (accurate volume intersection) raises the count of overlapping volume surfaces you can stack before artifacts appear.
+- World volumes are infinite in EEVEE; use a box for local fog. Thin slabs and very dense fog band, so use cards or Cycles for those.
+
+## God rays checklist
+Strong directional key → occluder with gaps (window frame, trees, slatted blinds) → fog σ 0.01–0.05 with anisotropy 0.6–0.8 → camera looking toward the light. Cycles gives crisp shafts. In EEVEE, enable volumetric shadows and use tile size 2.
+
+## Cheap alternatives
+- **Mist pass**: `view_layer.use_pass_mist`, `world.mist_settings` (`start`, `depth`, `falloff`). Mix the fog color in the compositor using the mist as the factor. No volume cost, but no light shafts.
+- **Fog cards**: camera-facing planes with a soft alpha-noise emission/transparent material, for background layers. They intersect geometry visibly, so keep them clear of objects.
diff --git a/skills/blender-time-of-day/references/light-values.md b/skills/blender-time-of-day/references/light-values.md
new file mode 100644
index 0000000..03ec373
--- /dev/null
+++ b/skills/blender-time-of-day/references/light-values.md
@@ -0,0 +1,53 @@
+# Light values (measured in Blender 5.2.2)
+
+## Sun by elevation (Multiple Scattering sky, altitude 100 m, default air/aerosol/ozone)
+Sun color = normalized direct-normal irradiance. "Sun W/m²" is the lamp strength `scene_mood.py` uses before exposure balancing (sky strength 0.0285). "Sky share" = sky irradiance on a horizontal plane ÷ direct irradiance on a horizontal plane.
+
+| Elevation | Name | Sun color (RGB) | Sun W/m² | Sky share |
+|---|---|---|---|---|
+| 60° | noon | 1.00 0.86 0.68 | 4.0 | 0.12 |
+| 35° | afternoon | 1.00 0.83 0.61 | 3.7 | 0.16 |
+| 20° | morning | 1.00 0.78 0.49 | 3.2 | 0.26 |
+| 6° | golden | 1.00 0.55 0.16 | 1.4 | 0.98 |
+| 1° | sunrise/sunset | 1.00 0.22 0.00 | 0.19 | 17 |
+| −4° | blue hour | (no direct sun) | 0 | sky only, strongly blue |
+| < −12° | night | (sky ≈ black) | 0 | use the night dome + moon |
+
+The sky goes from dominating at the horizon to about 12% of the light at noon. This is why golden hour shadows are blue and noon shadows are deep.
+
+## Lamp units (measured: white Lambert plane, Cycles)
+| Lamp | Irradiance at distance r |
+|---|---|
+| Sun, strength S | E = S (W/m²) |
+| Point / spot, power P | E = P / (4π r²) |
+| Area (small, on axis), power P | E = P / (π r²) |
+A grey card reads 0.18 when E ≈ π (≈ 3.14) at exposure 0.
+
+## Color temperature of real sources
+| Source | Kelvin |
+|---|---|
+| Candle / fire | 1800–1900 |
+| High-pressure sodium street lamp | 2000–2200 |
+| Tungsten bulb | 2700 |
+| Warm LED / halogen | 3000 |
+| Neutral LED street lamp / fluorescent | 4000–4500 |
+| Moonlight (physical) | ~4100 (render it cooler: Purkinje shift) |
+| Noon sun | 5500–5800 |
+| Overcast sky | 6500–7500 |
+| Blue-hour sky | 9000–12000 |
+In 5.x: `light.use_temperature = True; light.temperature = 2700`. `light.color` still multiplies the temperature color.
+
+## Practical wattages (exposure 0, the scene_mood balance)
+| Source | Blender light |
+|---|---|
+| Table lamp / 60 W bulb | point 30–60 W, radius 0.05 m |
+| Street lamp | spot 200–600 W, 2000–4000 K, spot size 100–140° |
+| Window glow (interior lit) | area light in the window or emission 2–10 |
+| Neon tube | emission strength 5–30 on a tube mesh + a weak area light for the spill |
+| Car headlight | spot 300–800 W, blend 0.3, 5000 K |
+With `--use-exposure`, multiply by the returned `practical_scale`.
+
+## Sky texture parameters
+- `altitude` (m): higher = darker, bluer sky with less haze. `air_density` scales Rayleigh (blue). `aerosol_density` scales Mie (haze, whiter sky, a bigger glow around the sun). `ozone_density` deepens twilight blue.
+- Hazy or polluted day: `aerosol_density` 2–5. Crisp mountain air: `altitude` 2000+, `aerosol_density` 0.3.
+- Both scattering models are very bright by default (physical units), so keep them balanced with a sun lamp or exposure. Never crank the strength to 1 and leave it.
diff --git a/skills/blender-time-of-day/references/night-and-moods.md b/skills/blender-time-of-day/references/night-and-moods.md
new file mode 100644
index 0000000..436a8a2
--- /dev/null
+++ b/skills/blender-time-of-day/references/night-and-moods.md
@@ -0,0 +1,36 @@
+# Night, blue hour and stylized moods
+
+## Night that reads as night
+1. **Contrast, not darkness**: one hard key (moon, high sun lamp angle ≈ 0.5°, crisp shadows) plus pools of warm practicals, with backgrounds falling to silhouette. A uniformly dim, blue image reads as underexposed day.
+2. **Color split**: cool ambient/moon (`[0.72, 0.82, 1.0]` or 7000–9000 K) against warm practicals (2000–3000 K). The complementary contrast sells it.
+3. **Lower saturation**: compositor Hue/Saturation 0.7–0.85. The eye loses color vision at night (Purkinje shift).
+4. **Night sky**: night HDRIs often contain light pollution that ruins rural scenes, so use the procedural dome (`--city-glow 0` for wilderness). The moon disc is not rendered: put a textured plane far away, or use an HDRI with a moon, if it must be visible.
+5. **Practicals first in a moonless scene**: windows, street lamps and signs carry the image. Add a little fog (`--fog-visibility 200–500`) so lights bloom and cast visible cones.
+6. **Camera**: a real night exposure means a longer shutter (more motion blur), a wider aperture (shallower depth of field) and grain. Keep `render.motion_blur_shutter` at 0.5 or above for moving elements.
+7. **Workflow**: turn lights on one at a time. A night scene with ten lights often works with three. Use light groups / light linking (`blender-lighting-lookdev`) to balance them without moving them.
+
+## Blue hour (sun 4–6° below the horizon)
+- Sky-only lighting: soft and deep blue, with no shadows. The best moment is when the practicals balance the sky, not overpower it: the script's balance keeps 50 W lamps visible but not blown out.
+- Windows and street lights on, a warm/cool split, a long exposure look (smooth water, light trails).
+
+## Golden hour / sunset
+- Sun 0–8°: warm key (measured `[1, 0.55, 0.16]` at 6°), long shadows, blue shadow fill from the sky.
+- Backlight or rim the subject and let the sun flare (compositor Glare `Fog Glow` or `Streaks`, threshold 1).
+- Haze adds depth: `--fog-visibility 2000–5000` with `--fog-color 1 0.85 0.7`.
+
+## Moods (`--mood`)
+| Mood | Time and key | Atmosphere | Grade |
+|---|---|---|---|
+| cyberpunk | moonless; magenta + cyan area rim pair | fog 150 m, 10 m height, magenta city glow | AgX - Punchy, bloom 0.6, saturation 1.1 |
+| horror | night; low moon 12°, sickly cyan | fog 35 m hugging the ground (1.5 m) | AgX - High Contrast, saturation 0.55, darker |
+| underwater | sun 70° through water | uniform volume 30 m, teal scatter, absorption tint | AgX - Base Contrast, saturation 0.9 |
+| desert | sun 45°, hot | warm haze 3000 m | AgX - Medium High Contrast, warm white point |
+
+### Finishing each mood
+- **cyberpunk**: wet streets are half the look (`blender-weather-fx` `surface_weather.py --wetness 0.7 --puddles 0.5`). Add emissive neon signs (strength 10–30) with light-linked spill, and rain for drama.
+- **horror**: one motivated source (a flickering bulb: keyframe the energy with noise), deep vignettes, fog between the camera and the subject, a desaturated green-cyan cast. Hide the threat in silhouette.
+- **underwater**: caustics need either a gobo/projected texture or Cycles caustics, which are slow. The fast fake is an animated Voronoi caustic pattern (W or Mapping driven by `frame`) added as brightness in the ground's shader, or on a gobo plane in front of a spot light. Add floating particles (`precipitation.py --type dust`), god rays from the surface (anisotropy 0.85), and blur the background.
+- **desert**: high sun, short shadows, bleached highlights. Add a heat shimmer in comp (`CompositorNodeDisplace` driven by a small animated noise) and dust particles in the air. Use high albedo sand (0.4–0.6 sRGB).
+
+## Grade order (compositor, 5.x API: options are input sockets)
+Render Layers → Glare (`Type` "Bloom" / "Fog Glow", `Threshold` 1, `Strength`) → Color Balance (`Type` "White Point", `Input Temperature`) → Hue/Saturation → (Lens Distortion `Dispersion` 0.01–0.03 for a stylized look) → Group Output. `scene.compositing_node_group` holds the tree.
diff --git a/skills/blender-time-of-day/scripts/_bpyx.py b/skills/blender-time-of-day/scripts/_bpyx.py
new file mode 100644
index 0000000..9048f69
--- /dev/null
+++ b/skills/blender-time-of-day/scripts/_bpyx.py
@@ -0,0 +1,136 @@
+"""_bpyx - tiny shared helpers for blender-agent-skills scripts (Blender 5.2+).
+
+Source of truth: shared/_bpyx.py. Copies in skills/*/scripts/ are synced by
+tools/sync_shared.py - never edit a copy.
+
+Every skill script follows one contract:
+ run(**kwargs) -> dict # call from MCP / Python (import the module)
+ blender -b f.blend -P x.py -- --arg v # CLI: prints one line "@@JSON@@{...}"
+"""
+import argparse
+import json
+import sys
+
+import bpy
+
+MARK = "@@JSON@@"
+
+
+def argv():
+ """Arguments after '--' (Blender ignores them)."""
+ return sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+
+
+def _default(o):
+ if hasattr(o, "__len__") and not isinstance(o, str):
+ try:
+ return [round(v, 5) if isinstance(v, float) else v for v in o]
+ except TypeError:
+ pass
+ if isinstance(o, (set, frozenset)):
+ return sorted(o)
+ return str(o)
+
+
+def emit(data):
+ """Print compact JSON on one marked line (parsed by run_in_blender.py)."""
+ print(MARK + json.dumps(data, separators=(",", ":"), default=_default), flush=True)
+ return data
+
+
+def parser(doc):
+ """ArgumentParser whose help is the script docstring's first line."""
+ return argparse.ArgumentParser(description=(doc or "").strip().splitlines()[0])
+
+
+def cli(run, p):
+ """CLI entry: parse args after '--', run, emit JSON. Exit 1 on failure."""
+ args = p.parse_args(argv())
+ try:
+ result = run(**vars(args))
+ save = getattr(args, "save", None)
+ if save:
+ bpy.ops.wm.save_as_mainfile(filepath=bpy.path.abspath(save))
+ result["saved"] = save
+ emit(result)
+ except Exception as e: # report, don't dump a traceback into agent context
+ emit({"ok": False, "error": f"{type(e).__name__}: {e}"})
+ if bpy.app.background:
+ sys.exit(1)
+
+
+def add_common(p, save=True):
+ """--objects / --save flags shared by most scripts."""
+ p.add_argument("--objects", nargs="*", default=None,
+ help="object names (default: selected, else all meshes)")
+ if save:
+ p.add_argument("--save", default=None, help="save .blend to this path after run")
+ return p
+
+
+def objects(names=None, types=("MESH",)):
+ """Resolve names -> objects. No names: selected of `types`, else all visible of `types`."""
+ if names:
+ missing = [n for n in names if n not in bpy.data.objects]
+ if missing:
+ raise KeyError(f"objects not found: {missing}")
+ return [bpy.data.objects[n] for n in names]
+ pool = [o for o in bpy.context.scene.objects if not types or o.type in types]
+ sel = [o for o in pool if o.select_get()]
+ return sel or [o for o in pool if o.visible_get()]
+
+
+def object_mode():
+ """Leave edit/sculpt/pose modes; most data API work needs OBJECT mode."""
+ ob = bpy.context.view_layer.objects.active
+ if ob and ob.mode != "OBJECT":
+ bpy.ops.object.mode_set(mode="OBJECT")
+
+
+def select_only(objs, active=None):
+ """Select exactly `objs` and make `active` (default first) active."""
+ for o in bpy.context.view_layer.objects:
+ o.select_set(False)
+ for o in objs:
+ o.select_set(True)
+ bpy.context.view_layer.objects.active = active or (objs[0] if objs else None)
+
+
+def node(tree, type_):
+ """First node of `type_` (e.g. 'BSDF_PRINCIPLED'). Names are localized - never look up by name."""
+ return next((n for n in tree.nodes if n.type == type_), None)
+
+
+def enum_ids(owner, prop):
+ """Valid identifiers of an enum property (works on types or instances)."""
+ return [i.identifier for i in owner.bl_rna.properties[prop].enum_items]
+
+
+def set_enum(owner, prop, value):
+ """Assign an enum; on failure raise listing valid values (dynamic enums under-report)."""
+ try:
+ setattr(owner, prop, value)
+ except TypeError as e:
+ raise ValueError(f"{prop}={value!r} invalid: {e}") from None
+
+
+def mesh_tris(ob, evaluated=True):
+ """Triangle count (evaluated = with modifiers)."""
+ if evaluated:
+ eo = ob.evaluated_get(bpy.context.evaluated_depsgraph_get())
+ me = eo.to_mesh()
+ try:
+ me.calc_loop_triangles()
+ return len(me.loop_triangles)
+ finally:
+ eo.to_mesh_clear()
+ me = ob.data
+ me.calc_loop_triangles()
+ return len(me.loop_triangles)
+
+
+def r(v, n=4):
+ """Round a float or a vector for compact JSON."""
+ if isinstance(v, float):
+ return round(v, n)
+ return [round(x, n) for x in v]
diff --git a/skills/blender-time-of-day/scripts/scene_mood.py b/skills/blender-time-of-day/scripts/scene_mood.py
new file mode 100644
index 0000000..35b6189
--- /dev/null
+++ b/skills/blender-time-of-day/scripts/scene_mood.py
@@ -0,0 +1,469 @@
+"""Time-of-day / mood environment in one call: physically measured sky + matching sun or moon lamp,
+night sky with stars and city glow, height fog sized from meteorological visibility, exposure
+balance, optional stylized mood (accent lights, AgX look, compositor grade).
+
+Everything lives in the ENV_Mood collection / ENV_World / ENV_Grade; re-running replaces it.
+Sun color and sun/sky ratio come from Blender 5.2's Multiple Scattering sky, measured per elevation.
+Usage:
+ blender -b f.blend -P scene_mood.py -- [--time noon|morning|afternoon|golden|sunrise|sunset|
+ blue_hour|night|moonless] [--mood none|cyberpunk|horror|underwater|desert]
+ [--elevation DEG] [--heading DEG] [--overcast 0-1] [--fog-visibility M] [--fog-height M]
+ [--fog-color R G B] [--fog-anisotropy 0.6] [--no-grade] [--use-exposure] [--keep-view]
+ [--moon-elevation 35] [--city-glow 0-1] [--stars 0-1] [--save out.blend]
+ MCP: import scene_mood; print(scene_mood.run(time="golden", fog_visibility=300))
+"""
+import math
+import os
+import sys
+
+import bpy
+from mathutils import Vector
+
+sys.path.insert(0, os.path.dirname(__file__))
+import _bpyx as bx # noqa: E402
+
+PREFIX, COLL, WORLD, GRADE = "ENV_", "ENV_Mood", "ENV_World", "ENV_Grade"
+K_SKY = 0.0285 # sky model -> scene units: noon sun ~4 W/m2, grey card ~0.18 at exposure 0
+LUM = (0.2126, 0.7152, 0.0722)
+
+# Measured in Blender 5.2.2 (Multiple Scattering, altitude 100 m, default densities):
+# elevation deg -> horizontal sky irradiance RGB (sun disc off), direct-normal sun irradiance RGB.
+SKY_TABLE = [
+ (-12, (0.00052, 0.00434, 0.02001), (0, 0, 0)),
+ (-9, (0.00134, 0.01087, 0.05), (0, 0, 0)),
+ (-6, (0.0056, 0.02903, 0.12731), (0, 0, 0)),
+ (-4, (0.04899, 0.08454, 0.27704), (0, 0, 0)),
+ (-2, (0.37054, 0.38863, 0.76517), (0, 0, 0)),
+ (0, (1.22718, 1.29752, 1.90794), (4.0847, 0.5232, 0.0)),
+ (1, (1.72506, 1.96472, 2.74431), (17.8917, 3.9918, 0.0)),
+ (2, (2.18728, 2.69088, 3.72502), (33.7886, 10.5753, 0.0666)),
+ (4, (2.97495, 4.12061, 5.93637), (61.1676, 27.8893, 4.5117)),
+ (6, (3.61373, 5.3837, 8.18156), (81.6948, 45.2236, 12.9207)),
+ (10, (4.57352, 7.33074, 11.97798), (108.1851, 72.2033, 32.4792)),
+ (15, (5.4053, 8.96377, 15.17675), (126.7271, 93.6768, 53.019)),
+ (20, (6.01476, 10.11608, 17.36756), (137.6212, 107.1634, 68.0404)),
+ (30, (6.90652, 11.77815, 20.50427), (149.517, 122.6031, 87.2194)),
+ (45, (7.84406, 13.52765, 23.82461), (157.6205, 133.5704, 102.1744)),
+ (60, (8.48658, 14.73384, 26.12468), (161.3662, 138.7539, 109.6074)),
+ (90, (9.00377, 15.70996, 27.99332), (163.7695, 142.0494, 114.3969)),
+]
+
+# time: sun elevation (None = night), target grey-card brightness relative to noon
+TIMES = {
+ "noon": (60, 1.0), "morning": (20, 1.0), "afternoon": (35, 1.0), "golden": (6, 0.85),
+ "sunrise": (1, 0.7), "sunset": (1, 0.7), "blue_hour": (-4, 0.35),
+ "night": (None, 0.2), "moonless": (None, 0.1),
+}
+# mood: defaults (explicit arguments win)
+MOODS = {
+ "none": {},
+ "cyberpunk": dict(time="moonless", fog_visibility=150, fog_height=10, fog_color=(0.85, 0.8, 1.0),
+ fog_anisotropy=0.5, city_glow=1.0, glow_color=(0.9, 0.2, 0.6), accents=True,
+ look="AgX - Punchy", saturation=1.1, bloom=0.6, white_point=6500),
+ "horror": dict(time="night", moon_elevation=12, moon_color=(0.6, 0.8, 0.85), fog_visibility=35,
+ fog_height=1.5, fog_color=(0.7, 0.78, 0.8), look="AgX - High Contrast",
+ saturation=0.55, bloom=0.15, brightness=0.1, white_point=7500),
+ "underwater": dict(time="noon", elevation=70, fog_visibility=30, fog_height=0,
+ fog_color=(0.25, 0.7, 0.75), absorption=(0.1, 0.55, 0.6), fog_anisotropy=0.85,
+ look="AgX - Base Contrast", saturation=0.9, bloom=0.2, brightness=0.4, underwater=True),
+ "desert": dict(time="afternoon", elevation=45, fog_visibility=3000, fog_height=0,
+ fog_color=(1.0, 0.82, 0.6), look="AgX - Medium High Contrast", saturation=1.05,
+ bloom=0.1, white_point=5800),
+}
+
+
+def _lerp_table(el):
+ el = max(min(el, 90), -12)
+ for (e0, s0, d0), (e1, s1, d1) in zip(SKY_TABLE, SKY_TABLE[1:]):
+ if e0 <= el <= e1:
+ t = (el - e0) / (e1 - e0)
+ return ([a + (b - a) * t for a, b in zip(s0, s1)], [a + (b - a) * t for a, b in zip(d0, d1)])
+ return list(SKY_TABLE[-1][1]), list(SKY_TABLE[-1][2])
+
+
+def lum(c):
+ return sum(a * b for a, b in zip(c, LUM))
+
+
+def _sun_dir(el, heading):
+ """Direction TO the light. heading 0 = +Y, 90 = +X (matches ShaderNodeTexSky.sun_rotation)."""
+ e, h = math.radians(el), math.radians(heading)
+ return Vector((math.sin(h) * math.cos(e), math.cos(h) * math.cos(e), math.sin(e)))
+
+
+def _scene_bounds():
+ pts = [o.matrix_world @ Vector(c) for o in bpy.context.scene.objects
+ if o.type in {"MESH", "CURVES", "CURVE"} and not o.name.startswith(PREFIX) and o.visible_get()
+ for c in o.bound_box]
+ if not pts:
+ return Vector((-5, -5, 0)), Vector((5, 5, 3))
+ lo = Vector((min(p.x for p in pts), min(p.y for p in pts), min(p.z for p in pts)))
+ hi = Vector((max(p.x for p in pts), max(p.y for p in pts), max(p.z for p in pts)))
+ return lo, hi
+
+
+def _clear():
+ for o in [o for o in bpy.data.objects if o.name.startswith(PREFIX + "Mood_")]:
+ data = o.data
+ bpy.data.objects.remove(o)
+ if data is not None and data.users == 0:
+ for coll in (bpy.data.lights, bpy.data.meshes):
+ if data.name in coll and coll[data.name] == data:
+ coll.remove(data)
+ break
+ for m in [m for m in bpy.data.materials if m.name.startswith(PREFIX + "Mood_")]:
+ bpy.data.materials.remove(m)
+
+
+def _coll():
+ col = bpy.data.collections.get(COLL)
+ if col is None:
+ col = bpy.data.collections.new(COLL)
+ if col.name not in bpy.context.scene.collection.children:
+ bpy.context.scene.collection.children.link(col)
+ return col
+
+
+def _light(col, name, kind, energy, color, direction=None, loc=None, target=None, **kw):
+ ld = bpy.data.lights.new(PREFIX + "Mood_" + name, kind)
+ ld.energy, ld.color = energy, color
+ for k, v in kw.items():
+ setattr(ld, k, v)
+ ob = bpy.data.objects.new(PREFIX + "Mood_" + name, ld)
+ if direction is not None: # sun: local -Z points away from the light direction
+ ob.rotation_euler = (-direction).to_track_quat("-Z", "Y").to_euler()
+ if loc is not None:
+ ob.location = loc
+ if target is not None:
+ ob.rotation_euler = (target - Vector(loc)).to_track_quat("-Z", "Y").to_euler()
+ col.objects.link(ob)
+ return ob
+
+
+def _norm(c):
+ m = max(c) or 1.0
+ return tuple(max(x / m, 0.0) for x in c)
+
+
+def _math(nt, op, a=None, b=None):
+ n = nt.nodes.new("ShaderNodeMath")
+ n.operation = op
+ for i, v in enumerate((a, b)):
+ if v is None:
+ continue
+ if isinstance(v, (int, float)):
+ n.inputs[i].default_value = v
+ else:
+ nt.links.new(v, n.inputs[i])
+ return n.outputs[0]
+
+
+def _mix_rgb(nt, fac, a, b, blend="MIX"):
+ m = nt.nodes.new("ShaderNodeMix")
+ m.data_type, m.blend_type = "RGBA", blend
+ for sock, v in ((m.inputs[0], fac), (m.inputs[6], a), (m.inputs[7], b)):
+ if isinstance(v, (int, float)):
+ sock.default_value = v
+ elif isinstance(v, tuple):
+ sock.default_value = (*v[:3], 1.0)
+ else:
+ nt.links.new(v, sock)
+ return m.outputs[2]
+
+
+def _world(p, mult):
+ """Build ENV_World. Returns horizontal ambient irradiance (luminance, scene units)."""
+ w = bpy.data.worlds.get(WORLD) or bpy.data.worlds.new(WORLD)
+ w.use_nodes = True
+ nt = w.node_tree
+ nt.nodes.clear()
+ out = nt.nodes.new("ShaderNodeOutputWorld")
+ bg = nt.nodes.new("ShaderNodeBackground")
+ nt.links.new(bg.outputs[0], out.inputs["Surface"])
+ bpy.context.scene.world = w
+ ambient = 0.0
+ if p["underwater"]:
+ col = tuple(c * 0.02 * mult for c in p["fog_color"])
+ bg.inputs["Color"].default_value = (*col, 1)
+ return math.pi * lum(col)
+ if p["elevation"] is not None and p["elevation"] > -12:
+ sky = nt.nodes.new("ShaderNodeTexSky")
+ bx.set_enum(sky, "sky_type", "MULTIPLE_SCATTERING")
+ sky.sun_disc = False # the sun lamp is the sun (sharp shadows in both engines)
+ sky.sun_elevation = math.radians(p["elevation"])
+ sky.sun_rotation = math.radians(p["heading"])
+ sky_h, _ = _lerp_table(p["elevation"])
+ color = sky.outputs["Color"]
+ if p["overcast"] > 0:
+ oc = p["overcast_rgb"]
+ color = _mix_rgb(nt, p["overcast"], color, oc)
+ sky_h = [a + (b * math.pi - a) * p["overcast"] for a, b in zip(sky_h, oc)]
+ nt.links.new(color, bg.inputs["Color"])
+ bg.inputs["Strength"].default_value = K_SKY * mult
+ ambient = K_SKY * mult * lum(sky_h)
+ else: # night dome: zenith -> horizon glow, stars for camera rays only
+ zen = tuple(c * mult for c in (0.0040, 0.0065, 0.0140))
+ tc = nt.nodes.new("ShaderNodeTexCoord")
+ sep = nt.nodes.new("ShaderNodeSeparateXYZ")
+ nt.links.new(tc.outputs["Generated"], sep.inputs[0])
+ z = _math(nt, "MAXIMUM", sep.outputs["Z"], 0.0)
+ glow = _math(nt, "EXPONENT", _math(nt, "MULTIPLY", z, -7.0))
+ gc = tuple(c * zen[1] * 6 * p["city_glow"] / max(p["glow_color"]) for c in p["glow_color"])
+ dome = _mix_rgb(nt, glow, zen, gc)
+ if p["stars"] > 0:
+ vor = nt.nodes.new("ShaderNodeTexVoronoi")
+ vor.inputs["Scale"].default_value = 350.0
+ nt.links.new(tc.outputs["Generated"], vor.inputs["Vector"])
+ core = _math(nt, "LESS_THAN", vor.outputs["Distance"], 0.045)
+ bright = _math(nt, "GREATER_THAN", _math(nt, "POWER", vor.outputs["Color"], 1.0), 1 - 0.35 * p["stars"])
+ above = _math(nt, "GREATER_THAN", sep.outputs["Z"], 0.05)
+ star = _math(nt, "MULTIPLY", _math(nt, "MULTIPLY", core, bright), above)
+ star = _math(nt, "MULTIPLY", star, 1.0 - 0.8 * p["city_glow"])
+ lp = nt.nodes.new("ShaderNodeLightPath")
+ star = _math(nt, "MULTIPLY", star, lp.outputs["Is Camera Ray"])
+ dome = _mix_rgb(nt, star, dome, (2.5, 2.6, 3.0))
+ nt.links.new(dome, bg.inputs["Color"])
+ ambient = math.pi * lum(zen) * (1 + 0.5 * p["city_glow"])
+ if p["fog_visibility"]: # camera sees the far background through fog
+ lp = nt.nodes.new("ShaderNodeLightPath")
+ far = 1 - math.exp(-3.912 / p["fog_visibility"] * p["fog_far"])
+ fac = _math(nt, "MULTIPLY", lp.outputs["Is Camera Ray"], far)
+ link = bg.inputs["Color"].links[0] if bg.inputs["Color"].is_linked else None
+ src = link.from_socket if link else tuple(bg.inputs["Color"].default_value)[:3]
+ fc = tuple(c * ambient / math.pi / max(bg.inputs["Strength"].default_value, 1e-6) for c in p["fog_color"])
+ nt.links.new(_mix_rgb(nt, fac, src, fc), bg.inputs["Color"])
+ return ambient
+
+
+def _fog_box(lo, hi, cam):
+ pts = [lo, hi] + ([cam.matrix_world.translation] if cam else [])
+ a = Vector((min(v.x for v in pts), min(v.y for v in pts), min(v.z for v in pts)))
+ b = Vector((max(v.x for v in pts), max(v.y for v in pts), max(v.z for v in pts)))
+ pad = max((b - a).length * 0.25, 2.0)
+ return a - Vector((pad, pad, min(pad, 1.0))), b + Vector((pad, pad, pad))
+
+
+def _transmittance(p, lo, hi, top, el):
+ """Fraction of key/sky light reaching subject height through the fog (for exposure metering)."""
+ if not p["fog_visibility"]:
+ return 1.0
+ sigma, z = 3.912 / p["fog_visibility"], lo.z + 0.25 * (hi.z - lo.z)
+ s = max(math.sin(math.radians(el)), 0.1)
+ if p["fog_height"]:
+ h = p["fog_height"]
+ depth = sigma * h * (math.exp(-(z - lo.z) / h) - math.exp(-(top - lo.z) / h))
+ else:
+ depth = sigma * max(top - z, 0.0)
+ return max(math.exp(-depth / s), 1 / 16) # meter at most 4 EV up: fog should still read dense
+
+
+def _fog(p, col, lo, a, b):
+ """Box volume around scene + camera. Density = extinction from visibility (Koschmieder 3.912/V)."""
+ sigma = 3.912 / p["fog_visibility"]
+ me = bpy.data.meshes.new(PREFIX + "Mood_Fog")
+ vs = [(x, y, z) for x in (a.x, b.x) for y in (a.y, b.y) for z in (a.z, b.z)]
+ me.from_pydata(vs, [], [(0, 1, 3, 2), (4, 6, 7, 5), (0, 4, 5, 1), (2, 3, 7, 6), (0, 2, 6, 4), (1, 5, 7, 3)])
+ ob = bpy.data.objects.new(PREFIX + "Mood_Fog", me)
+ col.objects.link(ob)
+ ob.display_type = "BOUNDS"
+ mat = bpy.data.materials.new(PREFIX + "Mood_Fog")
+ me.materials.append(mat)
+ nt = mat.node_tree
+ nt.nodes.clear()
+ out = nt.nodes.new("ShaderNodeOutputMaterial")
+ vol = nt.nodes.new("ShaderNodeVolumePrincipled")
+ vol.inputs["Color"].default_value = (*p["fog_color"], 1)
+ vol.inputs["Anisotropy"].default_value = p["fog_anisotropy"]
+ if p.get("absorption"):
+ vol.inputs["Absorption Color"].default_value = (*p["absorption"], 1)
+ nt.links.new(vol.outputs[0], out.inputs["Volume"])
+ if p["fog_height"]: # exponential height falloff above the ground
+ geo = nt.nodes.new("ShaderNodeNewGeometry")
+ sep = nt.nodes.new("ShaderNodeSeparateXYZ")
+ nt.links.new(geo.outputs["Position"], sep.inputs[0])
+ h = _math(nt, "MAXIMUM", _math(nt, "SUBTRACT", sep.outputs["Z"], lo.z), 0.0)
+ dens = _math(nt, "MULTIPLY", _math(nt, "EXPONENT", _math(nt, "DIVIDE", h, -p["fog_height"])), sigma)
+ nt.links.new(dens, vol.inputs["Density"])
+ else:
+ vol.inputs["Density"].default_value = sigma
+ return ob, sigma, (b - a).length
+
+
+def _grade(p, ev_to_threshold):
+ sc = bpy.context.scene
+ cur = sc.compositing_node_group
+ if cur is not None and cur.name != GRADE:
+ return "kept existing compositor tree"
+ ng = bpy.data.node_groups.get(GRADE) or bpy.data.node_groups.new(GRADE, "CompositorNodeTree")
+ ng.nodes.clear()
+ ng.interface.clear()
+ ng.interface.new_socket("Image", in_out="OUTPUT", socket_type="NodeSocketColor")
+ rl = ng.nodes.new("CompositorNodeRLayers")
+ img = rl.outputs["Image"]
+ if p["bloom"] > 0:
+ g = ng.nodes.new("CompositorNodeGlare")
+ g.inputs["Type"].default_value = "Bloom"
+ g.inputs["Quality"].default_value = "High"
+ g.inputs["Threshold"].default_value = ev_to_threshold
+ g.inputs["Strength"].default_value = p["bloom"]
+ g.inputs["Size"].default_value = 0.6
+ ng.links.new(img, g.inputs["Image"])
+ img = g.outputs["Image"]
+ if p["white_point"] != 6500:
+ cb = ng.nodes.new("CompositorNodeColorBalance")
+ cb.inputs["Type"].default_value = "White Point"
+ cb.inputs["Input Temperature"].default_value = p["white_point"]
+ ng.links.new(img, cb.inputs["Image"])
+ img = cb.outputs["Image"]
+ if p["saturation"] != 1.0:
+ hs = ng.nodes.new("CompositorNodeHueSat")
+ hs.inputs["Saturation"].default_value = p["saturation"]
+ ng.links.new(img, hs.inputs["Image"])
+ img = hs.outputs["Image"]
+ gout = ng.nodes.new("NodeGroupOutput")
+ ng.links.new(img, gout.inputs[0])
+ sc.compositing_node_group = ng
+ sc.render.use_compositing = True
+ return GRADE
+
+
+def run(time=None, mood="none", elevation=None, heading=None, overcast=0.0, fog_visibility=None,
+ fog_height=None, fog_color=None, fog_anisotropy=None, grade=True, use_exposure=False,
+ keep_view=False, moon_elevation=None, city_glow=None, stars=None, **_):
+ if mood not in MOODS:
+ raise ValueError(f"mood must be one of {sorted(MOODS)}")
+ bx.object_mode()
+ md = MOODS[mood]
+ p = dict(time="noon", elevation=None, heading=None, overcast=0.0, fog_visibility=None, fog_height=0,
+ fog_color=(1, 1, 1), fog_anisotropy=0.6, absorption=None, moon_elevation=35,
+ moon_color=None, city_glow=0.0, glow_color=(1.0, 0.45, 0.15), stars=1.0, accents=False,
+ look=None, saturation=1.0, bloom=0.0, brightness=None, white_point=6500, underwater=False)
+ p.update(md)
+ for k, v in dict(time=time, elevation=elevation, heading=heading, fog_visibility=fog_visibility,
+ fog_height=fog_height, fog_color=fog_color, fog_anisotropy=fog_anisotropy,
+ moon_elevation=moon_elevation, city_glow=city_glow, stars=stars).items():
+ if v is not None:
+ p[k] = tuple(v) if isinstance(v, list) else v
+ p["overcast"] = max(0.0, min(1.0, overcast or md.get("overcast", 0.0)))
+ if p["time"] not in TIMES:
+ raise ValueError(f"time must be one of {sorted(TIMES)}")
+ t_el, t_bright = TIMES[p["time"]]
+ if p["elevation"] is None:
+ p["elevation"] = t_el
+ night = p["elevation"] is None or p["elevation"] < -12
+ if p["time"] in ("night", "moonless"):
+ night, p["elevation"] = True, None
+ if p["brightness"] is None:
+ p["brightness"] = t_bright * (1 - 0.15 * p["overcast"])
+ if night and p["time"] in ("night", "moonless") and mood == "none" and city_glow is None:
+ p["city_glow"] = 0.3 if p["time"] == "night" else 0.6
+ sc = bpy.context.scene
+ cam = sc.camera
+ lo, hi = _scene_bounds()
+ center = (lo + hi) / 2
+ extent = max((hi - lo).length, 1.0)
+ if p["heading"] is None: # side/back light reads form; front light flattens
+ yaw = 0.0
+ if cam:
+ f = cam.matrix_world.to_quaternion() @ Vector((0, 0, -1))
+ yaw = math.degrees(math.atan2(f.x, f.y))
+ p["heading"] = (yaw + 135.0) % 360
+ p["fog_far"] = max(extent * 4, 200.0)
+ _clear()
+ col = _coll()
+ res = {"ok": True, "time": p["time"], "mood": mood, "heading": round(p["heading"], 1)}
+ warnings = []
+
+ # key light (sun / moon) in sky-model units, before the brightness multiplier
+ key_dir, key_e, key_rgb = None, 0.0, (1, 1, 1)
+ if not night and p["elevation"] > 0:
+ _, dni = _lerp_table(p["elevation"])
+ key_dir = _sun_dir(p["elevation"], p["heading"])
+ key_e = K_SKY * lum(dni) * (1 - p["overcast"]) ** 1.5
+ key_rgb = _norm(dni)
+ sun_angle = math.radians(0.545 + 25 * p["overcast"])
+ elif night and p["time"] == "night":
+ key_dir = _sun_dir(p["moon_elevation"], (p["heading"] + 40) % 360)
+ key_e = 0.3
+ key_rgb = p["moon_color"] or (0.72, 0.82, 1.0) # moonlight reads cool (Purkinje shift)
+ sun_angle = math.radians(0.52)
+ if p["overcast"] > 0 and not night:
+ sky_h, dni = _lerp_table(p["elevation"])
+ glob = (lum(sky_h) + lum(dni) * max(math.sin(math.radians(p["elevation"])), 0)) * 0.3
+ p["overcast_rgb"] = tuple(c * glob / math.pi for c in (0.95, 0.98, 1.04))
+ # balance: grey card under the key + ambient should read at `brightness` x 0.18
+ amb0 = _world(p, 1.0)
+ fa, fb = _fog_box(lo, hi, cam)
+ e_key = 0.0
+ if key_dir is not None: # meter between a ground plane and a wall facing the key
+ a = math.asin(key_dir.z)
+ e_key = key_e * (math.sin(a) + math.cos(a)) / 2
+ e_key *= _transmittance(p, lo, hi, fb.z, math.degrees(a))
+ e_ref = max(e_key + amb0 * _transmittance(p, lo, hi, fb.z, 45), 1e-6)
+ ev = math.log2(p["brightness"] * math.pi / e_ref)
+ mult = 1.0 if use_exposure else 2 ** ev
+ _world(p, mult)
+ if key_dir is not None and key_e > 1e-6:
+ _light(col, "Moon" if night else "Sun", "SUN", key_e * mult, key_rgb, direction=key_dir,
+ angle=sun_angle)
+ res["key"] = {"light": PREFIX + "Mood_" + ("Moon" if night else "Sun"), "strength": round(key_e * mult, 4),
+ "color": bx.r(list(key_rgb), 3), "elevation": round(math.degrees(math.asin(key_dir.z)), 1)}
+ if p["accents"]: # neon rim pair: magenta / cyan from opposite sides
+ d = extent * 0.6
+ e_target = p["brightness"] * math.pi * 4 # accents out-shine the ambient
+ for nm, side, rgb in (("NeonA", -1, (1.0, 0.1, 0.6)), ("NeonB", 1, (0.1, 0.8, 1.0))):
+ loc = center + Vector((side * d, d * 0.3, extent * 0.25))
+ _light(col, nm, "AREA", e_target * math.pi * d * d, rgb, loc=loc, target=center,
+ size=extent * 0.3, shape="DISK")
+ res["accents"] = 2
+ vs = sc.view_settings
+ if not keep_view:
+ bx.set_enum(vs, "view_transform", "AgX")
+ vs.look = p["look"] or "None"
+ vs.exposure = round(ev, 2) if use_exposure else 0.0
+ res["exposure"] = round(ev, 2)
+ res["practical_scale"] = round(2 ** -ev if use_exposure else 1.0, 4)
+ res["ambient"] = round(amb0 * mult, 4)
+ if p["fog_visibility"]:
+ fog, sigma, size = _fog(p, col, lo, fa, fb)
+ res["fog"] = {"object": fog.name, "density": round(sigma, 5), "visibility_m": p["fog_visibility"],
+ "height_m": p["fog_height"] or None}
+ ee = sc.eevee
+ ee.use_volumetric_shadows = True
+ ee.volumetric_tile_size = "4"
+ ee.volumetric_samples = max(ee.volumetric_samples, 96)
+ ee.volumetric_end = max(ee.volumetric_end, size)
+ sc.cycles.volume_bounces = max(sc.cycles.volume_bounces, 1)
+ if grade and (p["bloom"] or p["saturation"] != 1.0 or p["white_point"] != 6500):
+ # bloom threshold is scene-linear (before the view exposure): keep it at display white
+ res["grade"] = _grade(p, 2 ** -ev if use_exposure else 1.0)
+ if night and p["time"] == "moonless" and not p["accents"]:
+ warnings.append("moonless: add practical lights (street/window/neon) as the key")
+ if sc.render.engine == "BLENDER_EEVEE" and p["fog_visibility"] and p["fog_visibility"] < 15:
+ warnings.append("EEVEE: very dense fog bands at tile size 4; use 2 or Cycles")
+ if not cam:
+ warnings.append("no scene camera: heading defaulted to 135 deg")
+ if warnings:
+ res["warnings"] = warnings
+ return res
+
+
+if __name__ == "__main__":
+ p = bx.parser(__doc__)
+ p.add_argument("--time", default=None, choices=sorted(TIMES))
+ p.add_argument("--mood", default="none", choices=sorted(MOODS))
+ p.add_argument("--elevation", type=float, default=None)
+ p.add_argument("--heading", type=float, default=None)
+ p.add_argument("--overcast", type=float, default=0.0)
+ p.add_argument("--fog-visibility", type=float, default=None)
+ p.add_argument("--fog-height", type=float, default=None)
+ p.add_argument("--fog-color", type=float, nargs=3, default=None)
+ p.add_argument("--fog-anisotropy", type=float, default=None)
+ p.add_argument("--moon-elevation", type=float, default=None)
+ p.add_argument("--city-glow", type=float, default=None)
+ p.add_argument("--stars", type=float, default=None)
+ p.add_argument("--no-grade", dest="grade", action="store_false")
+ p.add_argument("--use-exposure", action="store_true")
+ p.add_argument("--keep-view", action="store_true")
+ p.add_argument("--save", default=None)
+ bx.cli(run, p)
diff --git a/skills/blender-weather-fx/SKILL.md b/skills/blender-weather-fx/SKILL.md
new file mode 100644
index 0000000..a701787
--- /dev/null
+++ b/skills/blender-weather-fx/SKILL.md
@@ -0,0 +1,64 @@
+---
+name: blender-weather-fx
+description: Weather effects in Blender 5.2 - looping Geometry Nodes rain, snow, dust, ash and embers with ground hits and splashes, wet surfaces, puddles with animated ripples, wall streaks, snow cover (shader + real snow geometry), storm lightning with multi-stroke flashes and bolts, engine-ready weather masks. Use for rain, storm, snow, wet street, puddle, dust or ember scenes.
+license: MIT
+metadata:
+ author: blender-agent-skills
+ version: "1.1.0"
+---
+
+# Weather FX
+
+The execution model is in `blender-core`. Sky, sun/moon, fog and mood come from `blender-time-of-day`, so run `scene_mood.py` first, then add weather. Rendering settings are in `blender-rendering`.
+
+## One call each
+```
+scripts/precipitation.py -- --type rain --intensity heavy --ground Street Roofs --wind 2 0
+scripts/surface_weather.py -- --objects Street Car Walls --wetness 0.7 --puddles 0.4 --ripples 1 --streaks 0.5
+scripts/lightning.py -- --flashes 2 --strokes 3
+scripts/precipitation.py -- --type snow --intensity moderate --ground Terrain
+scripts/surface_weather.py -- --objects Terrain Roofs --snow 0.8 --snow-depth 0.06
+scripts/surface_weather.py -- --objects Street Car Walls --remove # exact restore
+```
+A rainy night: `scene_mood.py --time night --fog-visibility 250` → rain → wetness + puddles → lightning. Rain and puddles at night are what sell a wet scene: wet surfaces reflect every practical light.
+
+## precipitation.py (rain, snow, dust, ash, embers)
+- Builds a GN modifier on `ENV_Weather_<Type>`. Its box covers what the camera sees across the frame range: world-fixed, so moving cameras don't drag the rain. With no camera, it covers a 18 m box. The floor is the lowest top of `--ground`.
+- **Seamless loop with no simulation**: each particle lives N whole times per loop (`Lives`), so the last frame + 1 equals the first frame exactly. It renders any frame on its own and works headless.
+- **Real speeds**: rain 7 m/s (9 at heavy/storm), snow 1, ash 0.6, dust 0.15, embers rise at 1.5, combined with `--wind X Y` (m/s).
+- **Ground**: a raycast against the `--ground` objects stops particles at the first hit (roofs, awnings, streets). Rain spawns splash crowns lasting 80 ms at each hit, aligned to the surface normal.
+- **Streaks, not motion blur**: rain is a 3-sided streak of length = speed × ½ frame (a 180° shutter), aligned to the travel direction. Motion blur off is cheaper and looks the same.
+- Particles closer than 1.5 m to the camera are hidden (`Near Clear`), because huge blobs ruin shots. The viewport shows 10% (`Viewport Fraction`), renders show 100%.
+- Density per intensity (particles/m³): rain 5/15/40/80, snow 10/30/80/160. Override with `--density`. The count is capped by `--max-count` (400k), and the result warns when it caps.
+- All values remain modifier inputs (Count, Speed, Wind, Lives, Particle Size, Streak Length, Sway, Ground, Splash...), so tweak them there instead of re-running.
+
+## surface_weather.py (wet, puddles, ripples, streaks, snow)
+- Puts one `ENV_Weather` shader group in front of each Principled BSDF and records the originals on the material. `--remove` restores links and values exactly.
+- **Wet** (Lagarde model): porous albedo darkens (up to 55% × `--porosity`), roughness drops, and a water film is added as **Coat**. Use porosity 0.6–0.9 for asphalt, concrete, wood and fabric, and 0.1–0.2 for metal, glass and plastic.
+- **Puddles**: domain-warped world-space noise on up-facing faces. Coverage ≈ `--puddles`, feature size `--scale` (m, default 3). Inside a puddle: full coat, mirror coat roughness 0.02, and a flattened base normal, because water fills the cracks.
+- **Ripples**: expanding rings, one per ~17 cm cell, driven by a `frame` driver (a simple expression, so it works without auto-run scripts). They only show inside puddles.
+- **Streaks**: vertical noise on walls adds coat runs.
+- **Snow**: up-facing coverage with a noisy edge, albedo 0.9, roughness 0.6 and a fine bump. `--snow-depth` adds real thickness with the `ENV_SnowCover` GN modifier: up-facing faces are subdivided and extruded upward by a noise height that is never zero, so there's no z-fighting. It uses the `ENV_M_Snow` material with subsurface.
+- `--vertex-mask` writes the `ENV_Weather` color attribute (R puddles, G snow, B walls) for engine shaders.
+
+## lightning.py
+- A strike is 3 return strokes ~50 ms apart (at least 2 frames apart, so the flicker reads at 24 fps), each a peak followed by a 2-frame decay. `--strokes`, `--flashes` or `--frames` set the timing. The flash is a cool `ENV_Storm_Flash` sun (12° soft) keyed against the scene's key light (×2.5).
+- `ENV_Storm_Bolt` is a branching emissive curve (midpoint displacement plus 4 branches), keyed with the flash. By default it is 300 m away, in frame and off-center. The world background strength flashes too (`--no-sky` to skip).
+- Keys use LINEAR interpolation (flashes must snap, not ease).
+
+## Rules
+- **Rain is visible only when backlit or side-lit** against a darker background: put a practical or bright sky behind it. Front-lit rain disappears.
+- Combine layers: fog (atmosphere) + rain streaks (mid) + splashes/ripples (ground) + wet reflections. Any one alone looks fake.
+- Real scale is mandatory: speeds, densities and puddle sizes are in meters (`blender-scene-setup`).
+- Check with a render at the final resolution. Rain density and streak visibility don't show in the viewport (10% count, no fog).
+- Run `blender-asset-qa` on the snow geometry if the asset will be exported.
+
+## Games and real-time
+Weather is an engine system (Unreal Niagara, Unity VFX Graph, Roblox ParticleEmitter). From Blender, export the **masks**: the vertex color attribute (`--vertex-mask`) or baked textures (`blender-texture-baking` self-bake of the wet material), plus snow cover meshes. Details are in [references/realtime-engines.md](references/realtime-engines.md). Physical values and the look library are in [references/weather-values.md](references/weather-values.md).
+
+## Gotchas
+- GN particles are instances, so `object.data` stays empty. Read results through the evaluated depsgraph (`depsgraph.object_instances`).
+- Background (`-b`) evaluation counts as the viewport for the `Is Viewport` node, so a headless test sees 10% of the count. Renders get 100%.
+- Ground objects are linked into the `ENV_Weather_<Type>_Ground` collection (linked, not moved).
+- `surface_weather` changes shared materials: every object using that material gets wet. Duplicate materials first to limit it.
+- Coat appears in both engines. EEVEE needs raytracing on (`eevee.use_raytracing`) for good puddle reflections.
diff --git a/skills/blender-weather-fx/references/realtime-engines.md b/skills/blender-weather-fx/references/realtime-engines.md
new file mode 100644
index 0000000..69a6aaf
--- /dev/null
+++ b/skills/blender-weather-fx/references/realtime-engines.md
@@ -0,0 +1,25 @@
+# Weather for games and real-time
+
+In engines, weather is a runtime system: particles, post-processing and material parameters. Blender's job is to deliver **meshes and masks** that the engine shaders read. Never export rain or snow instances as geometry.
+
+## What to export from Blender
+| Asset | How |
+|---|---|
+| Wetness/puddle/snow mask per vertex | `surface_weather.py --vertex-mask` → color attribute `ENV_Weather` (R puddles, G snow, B walls). Make it the active color attribute (`mesh.color_attributes.active_color_name = "ENV_Weather"`) |
+| Mask textures | bake the wet material with `blender-texture-baking` (self-bake: basecolor/roughness), or bake the mask into a channel of a packed texture |
+| Snow cover mesh | apply `ENV_SnowCover` (or export it as a separate LOD-able mesh), then `blender-asset-qa` + `blender-game-optimization` |
+| Puddle decals | planes with a water material, slightly above the ground (≥ 2 mm, never coplanar: z-fighting) |
+| Rain splash / ripple flipbooks | render a top-down ripple with `surface_weather` on a plane (orthographic camera), then pack the frames into an atlas |
+
+Exporter flags (5.2): glTF `export_vertex_color="ACTIVE"` (or `"NAME"` + `export_vertex_color_name="ENV_Weather"`); FBX `colors_type="LINEAR"` for masks (sRGB would gamma-shift the values) with `prioritize_active_color=True`.
+
+## Engine side (what reads the masks)
+- **Unreal**: a wetness material function (darken albedo, lower roughness, puddle normal flatten), driven by a Material Parameter Collection `Wetness` × vertex color R. Rain = Niagara GPU sprites with depth-buffer collision, plus ripple decals.
+- **Unity (URP/HDRP)**: a Shader Graph wet layer using vertex color, or HDRP decals for puddles. Rain = VFX Graph (GPU) with depth collision. Snow = a vertex color G blend to a snow layer.
+- **Godot 4**: a ShaderMaterial reading `COLOR`, with GPUParticles3D + a particle collision heightfield.
+- **Roblox**: no custom shaders. Use MaterialVariant / SurfaceAppearance swaps for wet and snowy versions, ParticleEmitter (`Speed`, `Acceleration`, `Drag`) for rain and snow, and Atmosphere (`Density`, `Haze`, `Glare`) for fog. Keep particle `Rate` low on mobile.
+
+## Budgets
+- Rain on mobile: around a few hundred camera-attached sprites. PC/console: thousands of GPU particles. Never use per-drop geometry.
+- Masks: vertex colors cost nothing extra if the mesh already has colors. A mask texture shares an existing packed channel (for example the A of ORM).
+- Fog: engine height fog (Unreal Exponential Height Fog, Unity Fog, Roblox Atmosphere). Match its density to `scene_mood` visibility: extinction ≈ 3.912 / visibility (m).
diff --git a/skills/blender-weather-fx/references/weather-values.md b/skills/blender-weather-fx/references/weather-values.md
new file mode 100644
index 0000000..70238e0
--- /dev/null
+++ b/skills/blender-weather-fx/references/weather-values.md
@@ -0,0 +1,40 @@
+# Weather values and look library
+
+## Rain
+| Quantity | Value |
+|---|---|
+| Terminal velocity by drop diameter | 0.5 mm ≈ 2 m/s · 1 mm ≈ 4 · 2 mm ≈ 6.5 · 5 mm ≈ 9 m/s (Gunn & Kinzer) |
+| Rain rate classes | light < 2.5 mm/h · moderate 2.5–7.6 · heavy > 7.6 (AMS) |
+| On camera | a streak = speed × exposure time: 7 m/s × 1/48 s ≈ 15 cm at 24 fps with a 180° shutter |
+| Splash | crown 2–4 cm, lives ~50–100 ms; secondary droplets bounce 5–10 cm |
+| Water | IOR 1.33, roughness 0–0.05 still, 0.05–0.15 rippled |
+- Visible density is far lower than physical density (thousands of tiny drops per m³). `precipitation.py` uses 5–80/m³ of *visible* streaks; storms read better with fog and wind than with more particles.
+- Wind tilts the rain: 2–5 m/s for a slant, 10+ for a storm. Gusts: keyframe the modifier's `Wind` input.
+- Rain is lit by what's behind it. Rim and backlight it (street lamps, headlights, a bright sky). Against a bright sky it reads dark; against a dark background it reads bright.
+
+## Wet surfaces (after Lagarde, "Water drop" series)
+- Porous materials (asphalt, concrete, brick, wood, fabric) darken by 20–50% as water fills the pores. Non-porous ones (metal, glass, plastic, car paint) don't darken, they only gain a water film.
+- Wet roughness drops sharply. Puddles are mirrors (water film ≈ 0.02) and hide the underlying normal detail (`surface_weather.py` flattens the base normal under puddles).
+- Puddles collect in low, flat areas: up-facing faces and cavities. To place them yourself, paint a vertex color or mask and feed it to the group's `Puddles` input.
+- Drying edges: a thin darker rim around puddles (the wet halo) sells it. Widen the mask edge if needed.
+
+## Snow
+| Quantity | Value |
+|---|---|
+| Fall speed | flakes 0.5–1.5 m/s, graupel 1–3 m/s |
+| Flake size | 2–10 mm (big wet flakes up to 2–5 cm in calm air) |
+| Albedo | fresh 0.8–0.9 · old/settled 0.6–0.8 · melting/dirty 0.4–0.6 |
+| Look | strong subsurface (blue-shifted radius), roughness 0.5–0.7, sparkle = tiny glossy flakes |
+- Snow settles on surfaces facing up, thins at edges, and is absent under overhangs. The shader handles facing; occlusion needs a painted mask or a raycast/AO bake.
+- Real thickness (`--snow-depth`) matters on roofs, ledges and the ground. Thin dustings stay shader-only.
+
+## Dust, ash, embers
+- Dust: tiny (0.5–1 mm), slow, floating (sway). Visible only in beams of light, so pair it with fog + god rays.
+- Ash: flat flakes, slow tumbling fall, dark grey; post-fire or volcanic mood.
+- Embers: emissive orange (strength 10–50), rising and swaying, short-lived. Pair with bloom (`scene_mood.py` grade) and a warm point light near the fire.
+
+## Lightning
+- A flash is 3–4 return strokes ~40–60 ms apart, 0.2–0.5 s total; the bolt channel shows a bright core with glow.
+- Cloud-to-ground bolts start at the cloud base (1–3 km up). Branches fork downward.
+- The flash lights the scene from the strike direction with cool white light (≈ 8000 K), stronger than the moon.
+- Use 1–3 flashes per shot. Constant flashing reads as a strobe, not a storm.
diff --git a/skills/blender-weather-fx/scripts/_bpyx.py b/skills/blender-weather-fx/scripts/_bpyx.py
new file mode 100644
index 0000000..9048f69
--- /dev/null
+++ b/skills/blender-weather-fx/scripts/_bpyx.py
@@ -0,0 +1,136 @@
+"""_bpyx - tiny shared helpers for blender-agent-skills scripts (Blender 5.2+).
+
+Source of truth: shared/_bpyx.py. Copies in skills/*/scripts/ are synced by
+tools/sync_shared.py - never edit a copy.
+
+Every skill script follows one contract:
+ run(**kwargs) -> dict # call from MCP / Python (import the module)
+ blender -b f.blend -P x.py -- --arg v # CLI: prints one line "@@JSON@@{...}"
+"""
+import argparse
+import json
+import sys
+
+import bpy
+
+MARK = "@@JSON@@"
+
+
+def argv():
+ """Arguments after '--' (Blender ignores them)."""
+ return sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+
+
+def _default(o):
+ if hasattr(o, "__len__") and not isinstance(o, str):
+ try:
+ return [round(v, 5) if isinstance(v, float) else v for v in o]
+ except TypeError:
+ pass
+ if isinstance(o, (set, frozenset)):
+ return sorted(o)
+ return str(o)
+
+
+def emit(data):
+ """Print compact JSON on one marked line (parsed by run_in_blender.py)."""
+ print(MARK + json.dumps(data, separators=(",", ":"), default=_default), flush=True)
+ return data
+
+
+def parser(doc):
+ """ArgumentParser whose help is the script docstring's first line."""
+ return argparse.ArgumentParser(description=(doc or "").strip().splitlines()[0])
+
+
+def cli(run, p):
+ """CLI entry: parse args after '--', run, emit JSON. Exit 1 on failure."""
+ args = p.parse_args(argv())
+ try:
+ result = run(**vars(args))
+ save = getattr(args, "save", None)
+ if save:
+ bpy.ops.wm.save_as_mainfile(filepath=bpy.path.abspath(save))
+ result["saved"] = save
+ emit(result)
+ except Exception as e: # report, don't dump a traceback into agent context
+ emit({"ok": False, "error": f"{type(e).__name__}: {e}"})
+ if bpy.app.background:
+ sys.exit(1)
+
+
+def add_common(p, save=True):
+ """--objects / --save flags shared by most scripts."""
+ p.add_argument("--objects", nargs="*", default=None,
+ help="object names (default: selected, else all meshes)")
+ if save:
+ p.add_argument("--save", default=None, help="save .blend to this path after run")
+ return p
+
+
+def objects(names=None, types=("MESH",)):
+ """Resolve names -> objects. No names: selected of `types`, else all visible of `types`."""
+ if names:
+ missing = [n for n in names if n not in bpy.data.objects]
+ if missing:
+ raise KeyError(f"objects not found: {missing}")
+ return [bpy.data.objects[n] for n in names]
+ pool = [o for o in bpy.context.scene.objects if not types or o.type in types]
+ sel = [o for o in pool if o.select_get()]
+ return sel or [o for o in pool if o.visible_get()]
+
+
+def object_mode():
+ """Leave edit/sculpt/pose modes; most data API work needs OBJECT mode."""
+ ob = bpy.context.view_layer.objects.active
+ if ob and ob.mode != "OBJECT":
+ bpy.ops.object.mode_set(mode="OBJECT")
+
+
+def select_only(objs, active=None):
+ """Select exactly `objs` and make `active` (default first) active."""
+ for o in bpy.context.view_layer.objects:
+ o.select_set(False)
+ for o in objs:
+ o.select_set(True)
+ bpy.context.view_layer.objects.active = active or (objs[0] if objs else None)
+
+
+def node(tree, type_):
+ """First node of `type_` (e.g. 'BSDF_PRINCIPLED'). Names are localized - never look up by name."""
+ return next((n for n in tree.nodes if n.type == type_), None)
+
+
+def enum_ids(owner, prop):
+ """Valid identifiers of an enum property (works on types or instances)."""
+ return [i.identifier for i in owner.bl_rna.properties[prop].enum_items]
+
+
+def set_enum(owner, prop, value):
+ """Assign an enum; on failure raise listing valid values (dynamic enums under-report)."""
+ try:
+ setattr(owner, prop, value)
+ except TypeError as e:
+ raise ValueError(f"{prop}={value!r} invalid: {e}") from None
+
+
+def mesh_tris(ob, evaluated=True):
+ """Triangle count (evaluated = with modifiers)."""
+ if evaluated:
+ eo = ob.evaluated_get(bpy.context.evaluated_depsgraph_get())
+ me = eo.to_mesh()
+ try:
+ me.calc_loop_triangles()
+ return len(me.loop_triangles)
+ finally:
+ eo.to_mesh_clear()
+ me = ob.data
+ me.calc_loop_triangles()
+ return len(me.loop_triangles)
+
+
+def r(v, n=4):
+ """Round a float or a vector for compact JSON."""
+ if isinstance(v, float):
+ return round(v, n)
+ return [round(x, n) for x in v]
diff --git a/skills/blender-weather-fx/scripts/lightning.py b/skills/blender-weather-fx/scripts/lightning.py
new file mode 100644
index 0000000..f163f93
--- /dev/null
+++ b/skills/blender-weather-fx/scripts/lightning.py
@@ -0,0 +1,182 @@
+"""Storm lightning: keyed multi-stroke flashes (a real strike is 3-4 return strokes ~40-60 ms apart),
+a cloud-lit flash light, an optional branching emissive bolt and a sky flash on the world.
+
+Everything is ENV_Storm_*; re-running replaces it. Times are in frames of the current scene fps.
+Usage:
+ blender -b f.blend -P lightning.py -- [--flashes 2] [--frames 30 80] [--strokes 3]
+ [--at X Y] [--distance 300] [--height 450] [--strength 1.0] [--no-bolt] [--no-sky]
+ [--seed 0] [--save out.blend]
+ MCP: import lightning; print(lightning.run(flashes=2, strength=1.5))
+"""
+import math
+import os
+import random
+import sys
+
+import bpy
+from mathutils import Vector
+
+sys.path.insert(0, os.path.dirname(__file__))
+import _bpyx as bx # noqa: E402
+
+PREFIX = "ENV_Storm_"
+
+
+def _clear():
+ for o in [o for o in bpy.data.objects if o.name.startswith(PREFIX)]:
+ data = o.data
+ bpy.data.objects.remove(o)
+ for coll in (bpy.data.lights, bpy.data.curves):
+ if data is not None and data.name in coll and coll[data.name].users == 0:
+ coll.remove(coll[data.name])
+ break
+ m = bpy.data.materials.get(PREFIX + "Bolt")
+ if m:
+ bpy.data.materials.remove(m)
+
+
+def _bolt_points(rng, top, bottom, depth=7, jag=0.12):
+ """Midpoint displacement between top and bottom; returns a list of Vectors."""
+ pts = [top, bottom]
+ for lvl in range(depth):
+ out = [pts[0]]
+ for a, b in zip(pts, pts[1:]):
+ seg = (b - a).length
+ mid = (a + b) / 2 + Vector((rng.gauss(0, 1), rng.gauss(0, 1), rng.gauss(0, 0.3))) * seg * jag
+ out += [mid, b]
+ pts = out
+ return pts
+
+
+def _curve(name, polylines, radii, mat, col):
+ cu = bpy.data.curves.new(name, "CURVE")
+ cu.dimensions = "3D"
+ cu.bevel_depth, cu.bevel_resolution = 1.0, 0
+ for pts, r in zip(polylines, radii):
+ sp = cu.splines.new("POLY")
+ sp.points.add(len(pts) - 1)
+ for i, p in enumerate(pts):
+ taper = 1.0 - 0.6 * i / max(len(pts) - 1, 1)
+ sp.points[i].co = (*p, 1.0)
+ sp.points[i].radius = r * taper
+ cu.materials.append(mat)
+ ob = bpy.data.objects.new(name, cu)
+ ob.visible_shadow = False
+ col.objects.link(ob)
+ return ob
+
+
+def _envelope(rng, starts, strokes, fps):
+ """{frame: intensity 0..1}. Each stroke: peak, 20% next frame, gone after ~3 frames."""
+ env = {}
+ gap = max(2, round(0.05 * fps)) # ~50 ms between strokes; >= 2 frames so the flicker reads
+ for s in starts:
+ t = s
+ for k in range(strokes):
+ peak = 1.0 if k == 0 else rng.uniform(0.5, 0.9)
+ for dt, v in ((0, peak), (1, peak * 0.2), (2, peak * 0.05)):
+ env[t + dt] = max(env.get(t + dt, 0.0), v)
+ t += gap + rng.randint(0, gap)
+ env.setdefault(s - 1, 0.0)
+ env.setdefault(t + 2, 0.0)
+ return dict(sorted(env.items()))
+
+
+def run(flashes=2, frames=None, strokes=3, at=None, distance=300.0, height=450.0, strength=1.0,
+ bolt=True, sky=True, seed=0, **_):
+ bx.object_mode()
+ rng = random.Random(seed)
+ sc = bpy.context.scene
+ fps = sc.render.fps / sc.render.fps_base
+ if frames:
+ starts = [int(f) for f in frames]
+ else:
+ span = max(sc.frame_end - sc.frame_start - 12, 1)
+ starts = sorted(sc.frame_start + 4 + int(span * (i + rng.uniform(0.2, 0.8)) / flashes) for i in range(flashes))
+ env = _envelope(rng, starts, strokes, fps)
+ _clear()
+ col = bpy.data.collections.get("ENV_Weather") or bpy.data.collections.new("ENV_Weather")
+ if col.name not in sc.collection.children:
+ sc.collection.children.link(col)
+ cam = sc.camera
+ if at:
+ strike = Vector((at[0], at[1], 0.0))
+ elif cam: # in view, far behind the subject, slightly off-center
+ fwd = cam.matrix_world.to_quaternion() @ Vector((0, 0, -1))
+ side = cam.matrix_world.to_quaternion() @ Vector((1, 0, 0))
+ fwd.z = side.z = 0
+ strike = cam.matrix_world.translation + fwd.normalized() * distance + side.normalized() * distance * 0.25
+ strike.z = 0.0
+ else:
+ strike = Vector((0, distance, 0))
+ # flash light: diffuse cloud light from the strike direction
+ key = next((o for o in bpy.data.objects if o.name in ("ENV_Mood_Sun", "ENV_Mood_Moon")), None)
+ base = max(key.data.energy * 2.5 if key else 2.0, 1.0) * strength
+ ld = bpy.data.lights.new(PREFIX + "Flash", "SUN")
+ ld.color, ld.angle = (0.78, 0.84, 1.0), math.radians(12)
+ lo = bpy.data.objects.new(PREFIX + "Flash", ld)
+ to_strike = (strike + Vector((0, 0, height * 0.6))).normalized()
+ lo.rotation_euler = (-to_strike).to_track_quat("-Z", "Y").to_euler()
+ col.objects.link(lo)
+ prefs = bpy.context.preferences.edit
+ keep = prefs.keyframe_new_interpolation_type
+ prefs.keyframe_new_interpolation_type = "LINEAR"
+ try:
+ for f, v in env.items():
+ ld.energy = base * v
+ ld.keyframe_insert("energy", frame=f)
+ res = {"ok": True, "flash_frames": starts, "keys": len(env), "light": lo.name,
+ "peak_strength": round(base, 3), "strike": bx.r(list(strike), 1)}
+ if bolt:
+ mat = bpy.data.materials.new(PREFIX + "Bolt")
+ nt = mat.node_tree
+ nt.nodes.clear()
+ em = nt.nodes.new("ShaderNodeEmission")
+ em.inputs["Color"].default_value = (0.8, 0.86, 1.0, 1)
+ out = nt.nodes.new("ShaderNodeOutputMaterial")
+ nt.links.new(em.outputs[0], out.inputs["Surface"])
+ top = strike + Vector((rng.uniform(-0.2, 0.2) * height, rng.uniform(-0.2, 0.2) * height, height))
+ main = _bolt_points(rng, top, strike)
+ lines, radii = [main], [height * 0.0012]
+ for _b in range(4):
+ i = rng.randint(len(main) // 8, len(main) // 2)
+ a = main[i]
+ end = a + Vector((rng.uniform(-1, 1) * height * 0.25, rng.uniform(-1, 1) * height * 0.25,
+ -rng.uniform(0.15, 0.4) * height))
+ lines.append(_bolt_points(rng, a, end, depth=5))
+ radii.append(radii[0] * 0.45)
+ bo = _curve(PREFIX + "Bolt", lines, radii, mat, col)
+ strength_sock = em.inputs["Strength"]
+ for f, v in env.items():
+ strength_sock.default_value = 400.0 * v * strength
+ strength_sock.keyframe_insert("default_value", frame=f)
+ res["bolt"] = bo.name
+ w = sc.world
+ if sky and w and w.node_tree:
+ bg = bx.node(w.node_tree, "BACKGROUND")
+ if bg is not None and not bg.inputs["Strength"].is_linked:
+ s0 = bg.inputs["Strength"].default_value
+ for f, v in env.items():
+ bg.inputs["Strength"].default_value = s0 * (1 + 3 * v * strength)
+ bg.inputs["Strength"].keyframe_insert("default_value", frame=f)
+ bg.inputs["Strength"].default_value = s0
+ res["sky_flash"] = w.name
+ finally:
+ prefs.keyframe_new_interpolation_type = keep
+ return res
+
+
+if __name__ == "__main__":
+ p = bx.parser(__doc__)
+ p.add_argument("--flashes", type=int, default=2)
+ p.add_argument("--frames", type=int, nargs="*", default=None)
+ p.add_argument("--strokes", type=int, default=3)
+ p.add_argument("--at", type=float, nargs=2, default=None)
+ p.add_argument("--distance", type=float, default=300.0)
+ p.add_argument("--height", type=float, default=450.0)
+ p.add_argument("--strength", type=float, default=1.0)
+ p.add_argument("--no-bolt", dest="bolt", action="store_false")
+ p.add_argument("--no-sky", dest="sky", action="store_false")
+ p.add_argument("--seed", type=int, default=0)
+ p.add_argument("--save", default=None)
+ bx.cli(run, p)
diff --git a/skills/blender-weather-fx/scripts/precipitation.py b/skills/blender-weather-fx/scripts/precipitation.py
new file mode 100644
index 0000000..008ead6
--- /dev/null
+++ b/skills/blender-weather-fx/scripts/precipitation.py
@@ -0,0 +1,355 @@
+"""Rain, snow, dust, ash or embers as a seamlessly looping Geometry Nodes system (no simulation:
+deterministic, headless-safe, any frame renders on its own).
+
+Particles live in a world-fixed box that covers what the camera sees (sampled over the frame
+range), fall at real speeds along the wind, stop on --ground objects (raycast) and, for rain,
+spawn splash crowns at the impact point. All values stay editable on the ENV_Weather_<type>
+object's modifier.
+Usage:
+ blender -b f.blend -P precipitation.py -- --type rain|snow|dust|ash|embers
+ [--intensity light|moderate|heavy|storm] [--density N_per_m3] [--wind X Y]
+ [--ground Street Roof ...] [--distance 18] [--loop-frames 96] [--seed 0] [--no-splash]
+ [--max-count 400000] [--save out.blend]
+ MCP: import precipitation; print(precipitation.run(type="rain", intensity="heavy", ground=["Street"]))
+"""
+import math
+import os
+import sys
+
+import bpy
+from mathutils import Vector
+
+sys.path.insert(0, os.path.dirname(__file__))
+import _bpyx as bx # noqa: E402
+
+PREFIX = "ENV_Weather_"
+# per type: fall speed m/s (terminal velocity), particle size m, sway m, gravity sign,
+# target lifetime s, visible density per m3 by intensity (light, moderate, heavy, storm)
+TYPES = {
+ "rain": dict(speed=7.0, size=0.0012, sway=0.0, sign=-1, life=1.0, density=(5, 15, 40, 80)),
+ "snow": dict(speed=1.0, size=0.006, sway=0.25, sign=-1, life=4.0, density=(10, 30, 80, 160)),
+ "dust": dict(speed=0.15, size=0.0008, sway=0.6, sign=-1, life=6.0, density=(10, 30, 80, 150)),
+ "ash": dict(speed=0.6, size=0.004, sway=0.4, sign=-1, life=4.0, density=(5, 15, 40, 80)),
+ "embers": dict(speed=1.5, size=0.004, sway=0.5, sign=1, life=3.0, density=(1, 3, 8, 15)),
+}
+INTENSITY = {"light": 0, "moderate": 1, "heavy": 2, "storm": 3}
+
+
+class _T:
+ """Minimal node-graph helper: n(type, inputs..., **props) -> node; sockets by enabled name."""
+
+ def __init__(self, nt):
+ self.nt = nt
+
+ @staticmethod
+ def sock(coll, key):
+ if isinstance(key, int):
+ return [s for s in coll if s.enabled][key]
+ s = next((s for s in coll if s.enabled and (s.name == key or s.identifier == key)), None)
+ if s is None:
+ raise KeyError(f"{key} not in {[s.name for s in coll if s.enabled]}")
+ return s
+
+ def n(self, type_, ins=None, **props):
+ node = self.nt.nodes.new(type_)
+ for k, v in props.items():
+ setattr(node, k, v)
+ for k, v in (ins or {}).items():
+ s = self.sock(node.inputs, k)
+ if isinstance(v, bpy.types.NodeSocket):
+ self.nt.links.new(v, s)
+ else:
+ s.default_value = v
+ return node
+
+ def out(self, node, key=0):
+ return self.sock(node.outputs, key)
+
+ def math(self, op, a, b=0.0, c=None):
+ ins = {0: a, 1: b} if c is None else {0: a, 1: b, 2: c}
+ node = self.nt.nodes.new("ShaderNodeMath")
+ node.operation = op
+ for i, v in ins.items():
+ s = node.inputs[i]
+ if isinstance(v, bpy.types.NodeSocket):
+ self.nt.links.new(v, s)
+ else:
+ s.default_value = v
+ return node.outputs[0]
+
+ def vmath(self, op, a, b=None, scale=None):
+ node = self.nt.nodes.new("ShaderNodeVectorMath")
+ node.operation = op
+ for s, v in ((node.inputs[0], a), (node.inputs[1], b), (node.inputs[3], scale)):
+ if v is None:
+ continue
+ if isinstance(v, bpy.types.NodeSocket):
+ self.nt.links.new(v, s)
+ else:
+ s.default_value = v
+ return node.outputs["Value" if op in ("LENGTH", "DOT_PRODUCT", "DISTANCE") else "Vector"]
+
+
+def _iface(nt, name, kind, default=None, io="INPUT", **kw):
+ s = nt.interface.new_socket(name, in_out=io, socket_type=f"NodeSocket{kind}")
+ if default is not None:
+ s.default_value = default
+ for k, v in kw.items():
+ setattr(s, k, v)
+ return s
+
+
+def build_tree(name, kind):
+ nt = bpy.data.node_groups.get(name) or bpy.data.node_groups.new(name, "GeometryNodeTree")
+ nt.nodes.clear()
+ nt.interface.clear()
+ nt.is_modifier = True
+ _iface(nt, "Geometry", "Geometry")
+ for nm, k, d, extra in (
+ ("Count", "Int", 10000, {"min_value": 0}), ("Size", "Vector", (20, 20, 10), {}),
+ ("Speed", "Float", 7.0, {"min_value": 0.001}), ("Wind", "Vector", (0, 0, 0), {}),
+ ("Gravity Sign", "Float", -1.0, {}), ("Lives", "Int", 2, {"min_value": 1, "max_value": 64}),
+ ("Loop Frames", "Int", 96, {"min_value": 1}), ("Start Frame", "Int", 1, {}),
+ ("FPS", "Float", 24.0, {}), ("Particle Size", "Float", 0.001, {}),
+ ("Streak Length", "Float", 0.15, {}), ("Sway", "Float", 0.0, {}), ("Seed", "Int", 0, {}),
+ ("Ground", "Collection", None, {}), ("Splash", "Bool", True, {}),
+ ("Splash Time", "Float", 0.08, {}), ("Material", "Material", None, {}),
+ ("Camera", "Object", None, {}), ("Near Clear", "Float", 1.5, {}),
+ ("Viewport Fraction", "Float", 0.1, {"min_value": 0.0, "max_value": 1.0})):
+ _iface(nt, nm, k, d, **extra)
+ _iface(nt, "Geometry", "Geometry", io="OUTPUT")
+ t = _T(nt)
+ gi = t.n("NodeGroupInput")
+ go = t.n("NodeGroupOutput")
+ I = lambda k: t.out(gi, k) # noqa: E731
+ idx = t.out(t.n("GeometryNodeInputIndex"))
+ two_pi = 2 * math.pi
+
+ # Lifetime loop: each particle lives `Lives` times per loop. Life k of a loop always reuses the
+ # same random start, so frame Start+Loop == frame Start exactly, at the true speed.
+ tm = t.n("GeometryNodeInputSceneTime")
+ loop_t = t.math("DIVIDE", t.math("SUBTRACT", t.out(tm, "Frame"), I("Start Frame")), I("Loop Frames"))
+ phase0 = t.out(t.n("FunctionNodeRandomValue", {"Min": 0.0, "Max": 1.0, "ID": idx, "Seed": I("Seed")},
+ data_type="FLOAT"))
+ tl = t.math("MULTIPLY_ADD", loop_t, I("Lives"), phase0)
+ life = t.math("FLOORED_MODULO", t.math("FLOOR", tl), I("Lives"))
+ f = t.math("FRACT", tl)
+ lid = t.math("MULTIPLY_ADD", idx, 64.0, life) # per-life random stream
+
+ def rnd(off, lo=0.0, hi=1.0):
+ seed = t.math("ADD", I("Seed"), float(off))
+ return t.out(t.n("FunctionNodeRandomValue", {"Min": lo, "Max": hi, "ID": lid, "Seed": seed},
+ data_type="FLOAT"))
+
+ size = t.n("ShaderNodeSeparateXYZ", {0: I("Size")})
+ sx, sy, sz = t.out(size, "X"), t.out(size, "Y"), t.out(size, "Z")
+ sign = I("Gravity Sign")
+ # direction of travel: wind/speed horizontally, gravity sign vertically
+ wdir = t.vmath("SCALE", I("Wind"), scale=t.math("DIVIDE", 1.0, I("Speed")))
+ direc = t.vmath("NORMALIZE", t.vmath("ADD", wdir, t.out(t.n("ShaderNodeCombineXYZ", {"Z": sign}))))
+ speed = t.vmath("LENGTH", t.vmath("ADD", I("Wind"), t.out(t.n("ShaderNodeCombineXYZ", {"Z": I("Speed")}))))
+ life_s = t.math("DIVIDE", t.math("DIVIDE", I("Loop Frames"), I("FPS")), I("Lives"))
+ length = t.math("MULTIPLY", speed, life_s) # distance covered in one life
+ start = t.out(t.n("ShaderNodeCombineXYZ", {
+ "X": t.math("MULTIPLY", t.math("SUBTRACT", rnd(1), 0.5), sx),
+ "Y": t.math("MULTIPLY", t.math("SUBTRACT", rnd(2), 0.5), sy),
+ "Z": t.math("MULTIPLY", rnd(3), sz)}))
+ # ground: first hit along this life's path (collection geometry relative to this object)
+ coll = t.n("GeometryNodeCollectionInfo", {"Collection": I("Ground")}, transform_space="RELATIVE")
+ real = t.n("GeometryNodeRealizeInstances", {"Geometry": t.out(coll)})
+ ray = t.n("GeometryNodeRaycast", {"Target Geometry": t.out(real), "Source Position": start,
+ "Ray Direction": direc, "Ray Length": length}, data_type="FLOAT")
+ hit = t.math("MULTIPLY", t.out(ray, "Is Hit"), t.math("LESS_THAN", sign, 0.0))
+ hit_d = t.out(t.n("GeometryNodeSwitch", {"Switch": t.math("GREATER_THAN", hit, 0.5),
+ "False": length, "True": t.out(ray, "Hit Distance")},
+ input_type="FLOAT"))
+ travel = t.math("MULTIPLY", f, length)
+ pos = t.vmath("ADD", start, t.vmath("SCALE", direc, scale=travel))
+ # sway (snow/dust/ash/embers): two sines per life
+ swx = t.math("SINE", t.math("MULTIPLY", t.math("MULTIPLY_ADD", f, 2.0, rnd(5)), two_pi))
+ swy = t.math("COSINE", t.math("MULTIPLY", t.math("MULTIPLY_ADD", f, 1.5, rnd(6)), two_pi))
+ sway = t.vmath("SCALE", t.out(t.n("ShaderNodeCombineXYZ", {"X": swx, "Y": swy})), scale=I("Sway"))
+ pos = t.vmath("ADD", pos, sway)
+ alive = t.math("LESS_THAN", travel, hit_d)
+ # keep a clear zone around the camera: particles closer than ~1.5 m render as huge blobs
+ cam = t.n("GeometryNodeObjectInfo", {"Object": I("Camera")}, transform_space="RELATIVE")
+ near = t.math("GREATER_THAN", t.vmath("DISTANCE", pos, t.out(cam, "Location")), I("Near Clear"))
+ alive = t.math("MULTIPLY", alive, near)
+ # fade in/out over the first/last 10% of a life: no popping
+ fade = t.math("MINIMUM", t.math("MINIMUM", t.math("MULTIPLY", f, 10.0),
+ t.math("MULTIPLY", t.math("SUBTRACT", 1.0, f), 10.0)), 1.0)
+
+ # full count in renders, a fraction in the viewport (keeps scenes interactive)
+ vp_count = t.math("MULTIPLY", I("Count"), I("Viewport Fraction"))
+ count = t.out(t.n("GeometryNodeSwitch", {"Switch": t.out(t.n("GeometryNodeIsViewport")),
+ "False": I("Count"), "True": vp_count}, input_type="INT"))
+ pts = t.n("GeometryNodePoints", {"Count": count, "Position": pos})
+ # particle mesh: rain = thin 3-sided streak along travel, others = small blobs/flakes
+ if kind == "rain":
+ drop = t.n("GeometryNodeMeshCone", {"Vertices": 3, "Radius Top": 0.0,
+ "Radius Bottom": I("Particle Size"), "Depth": I("Streak Length")},
+ fill_type="NONE")
+ rot = t.out(t.n("FunctionNodeAlignRotationToVector", {"Vector": direc}, axis="Z"))
+ scale = t.out(t.n("ShaderNodeCombineXYZ", {"X": fade, "Y": fade, "Z": t.math("MULTIPLY", fade, rnd(7, 0.7, 1.3))}))
+ else:
+ if kind == "ash":
+ drop = t.n("GeometryNodeMeshGrid", {"Size X": I("Particle Size"), "Size Y": I("Particle Size"),
+ "Vertices X": 2, "Vertices Y": 2})
+ else:
+ drop = t.n("GeometryNodeMeshIcoSphere", {"Radius": I("Particle Size"), "Subdivisions": 1})
+ eul = t.n("FunctionNodeRandomValue", {"ID": idx, "Seed": I("Seed"), "Min": (0, 0, 0),
+ "Max": (6.283, 6.283, 6.283)}, data_type="FLOAT_VECTOR")
+ rot = t.out(t.n("FunctionNodeEulerToRotation", {"Euler": t.out(eul)}))
+ s = t.math("MULTIPLY", fade, rnd(7, 0.5, 1.5))
+ scale = t.out(t.n("ShaderNodeCombineXYZ", {"X": s, "Y": s, "Z": s}))
+ mat_drop = t.n("GeometryNodeSetMaterial", {"Geometry": t.out(drop), "Material": I("Material")})
+ inst = t.n("GeometryNodeInstanceOnPoints", {"Points": t.out(pts), "Selection": alive,
+ "Instance": t.out(mat_drop), "Rotation": rot, "Scale": scale})
+ result = t.out(inst)
+ if kind == "rain": # splash crown at the impact point right after the hit
+ win = t.math("DIVIDE", I("Splash Time"), life_s) # splash duration as a fraction of a life
+ since = t.math("SUBTRACT", f, t.math("DIVIDE", hit_d, length))
+ on = t.math("MULTIPLY", t.math("MULTIPLY", hit, t.math("LESS_THAN", since, win)),
+ t.math("MULTIPLY", t.math("GREATER_THAN", since, 0.0), I("Splash")))
+ grow = t.math("DIVIDE", since, win)
+ hit_pos = t.out(ray, "Hit Position")
+ spts = t.n("GeometryNodePoints", {"Count": count, "Position": hit_pos})
+ crown = t.n("GeometryNodeMeshCone", {"Vertices": 8, "Radius Top": 0.03, "Radius Bottom": 0.006,
+ "Depth": 0.02}, fill_type="NONE")
+ cmat = t.n("GeometryNodeSetMaterial", {"Geometry": t.out(crown), "Material": I("Material")})
+ up = t.out(t.n("FunctionNodeAlignRotationToVector", {"Vector": t.out(ray, "Hit Normal")}, axis="Z"))
+ g = t.math("MULTIPLY_ADD", grow, 0.8, 0.2)
+ cs = t.out(t.n("ShaderNodeCombineXYZ", {"X": g, "Y": g, "Z": t.math("SUBTRACT", 1.0, grow)}))
+ sinst = t.n("GeometryNodeInstanceOnPoints", {"Points": t.out(spts), "Selection": on,
+ "Instance": t.out(cmat), "Rotation": up, "Scale": cs})
+ join = t.n("GeometryNodeJoinGeometry")
+ nt.links.new(t.out(sinst), join.inputs[0])
+ nt.links.new(result, join.inputs[0])
+ result = t.out(join)
+ nt.links.new(result, go.inputs[0])
+ return nt
+
+
+def _material(kind):
+ name = PREFIX + "M_" + kind.capitalize()
+ mat = bpy.data.materials.get(name) or bpy.data.materials.new(name)
+ b = bx.node(mat.node_tree, "BSDF_PRINCIPLED")
+ vals = {
+ "rain": {"Base Color": (0.8, 0.85, 0.9, 1), "Roughness": 0.05, "IOR": 1.33,
+ "Transmission Weight": 0.8, "Alpha": 0.35},
+ "snow": {"Base Color": (0.9, 0.92, 0.95, 1), "Roughness": 0.6, "Subsurface Weight": 0.3},
+ "dust": {"Base Color": (0.55, 0.47, 0.38, 1), "Roughness": 1.0, "Alpha": 0.6},
+ "ash": {"Base Color": (0.08, 0.08, 0.08, 1), "Roughness": 1.0},
+ "embers": {"Base Color": (0.05, 0.02, 0.0, 1), "Emission Color": (1.0, 0.32, 0.04, 1),
+ "Emission Strength": 25.0},
+ }[kind]
+ for k, v in vals.items():
+ b.inputs[k].default_value = v
+ return mat
+
+
+def _camera_box(cam, distance, lo_z, frames):
+ """World AABB of the camera's near frustum (0..distance) over the frame range."""
+ sc = bpy.context.scene
+ keep = sc.frame_current
+ pts = []
+ step = max(1, (frames[1] - frames[0]) // 8)
+ half = math.atan(cam.data.sensor_width / 2 / cam.data.lens) # sensor fit AUTO: larger axis
+ for fr in range(frames[0], frames[1] + 1, step):
+ sc.frame_set(fr)
+ m = cam.matrix_world
+ for d in (0.0, distance * 0.5, distance):
+ w = d * math.tan(min(half, math.radians(60)))
+ for sx in (-1, 1):
+ for sy in (-1, 1):
+ pts.append(m @ Vector((sx * w, sy * w, -d)))
+ sc.frame_set(keep)
+ a = Vector((min(p.x for p in pts), min(p.y for p in pts), lo_z))
+ top = min(max(max(p.z for p in pts) + 2.0, lo_z + 6), lo_z + 15) # rain above ~15 m reads as haze
+ b = Vector((max(p.x for p in pts), max(p.y for p in pts), top))
+ return a, b
+
+
+def run(type="rain", intensity="moderate", density=None, wind=(0.0, 0.0), ground=None, distance=18.0, # noqa: A002
+ loop_frames=None, seed=0, splash=True, max_count=400000, **_):
+ if type not in TYPES:
+ raise ValueError(f"type must be one of {sorted(TYPES)}")
+ bx.object_mode()
+ spec = TYPES[type]
+ sc = bpy.context.scene
+ fps = sc.render.fps / sc.render.fps_base
+ frames = (sc.frame_start, sc.frame_end)
+ loop = int(loop_frames or (frames[1] - frames[0] + 1))
+ grounds = bx.objects(ground) if ground else []
+ # box floor = the lowest ground *top*, so particles missing the ground stop at its level
+ lo_z = min((max((o.matrix_world @ Vector(c)).z for c in o.bound_box) for o in grounds), default=0.0)
+ cam = sc.camera
+ if cam:
+ a, b = _camera_box(cam, distance, lo_z, frames)
+ else:
+ a, b = Vector((-distance / 2, -distance / 2, lo_z)), Vector((distance / 2, distance / 2, lo_z + 10))
+ size = b - a
+ dens = density if density is not None else spec["density"][INTENSITY[intensity]]
+ count = int(size.x * size.y * size.z * dens)
+ res = {"ok": True, "type": type}
+ if count > max_count:
+ res["warning"] = f"count {count} capped to {max_count}: reduce --distance or --density"
+ count = max_count
+ speed = spec["speed"] * (1.25 if intensity in ("heavy", "storm") and type == "rain" else 1.0)
+ w = Vector((*wind, 0.0))
+ lives = max(1, min(64, round(loop / fps / spec["life"])))
+ eff_speed = math.hypot(speed, w.length)
+ shutter = 0.5 / fps # 180-degree shutter: what a camera smears a drop into
+ name = PREFIX + type.capitalize()
+ nt = build_tree(name, "rain" if type == "rain" else type)
+ ob = bpy.data.objects.get(name)
+ if ob is None:
+ ob = bpy.data.objects.new(name, bpy.data.meshes.new(name))
+ col = bpy.data.collections.get("ENV_Weather") or bpy.data.collections.new("ENV_Weather")
+ if col.name not in sc.collection.children:
+ sc.collection.children.link(col)
+ col.objects.link(ob)
+ ob.location = (a.x + size.x / 2, a.y + size.y / 2, a.z)
+ for m in [m for m in ob.modifiers if m.type == "NODES"]:
+ ob.modifiers.remove(m)
+ mod = ob.modifiers.new(name, "NODES")
+ mod.node_group = nt
+ gcol = None
+ if grounds:
+ gcol = bpy.data.collections.get(name + "_Ground") or bpy.data.collections.new(name + "_Ground")
+ for o in list(gcol.objects):
+ gcol.objects.unlink(o)
+ for o in grounds:
+ gcol.objects.link(o)
+ vals = {"Count": count, "Size": tuple(size), "Speed": speed, "Wind": tuple(w),
+ "Gravity Sign": float(spec["sign"]), "Lives": lives, "Loop Frames": loop,
+ "Start Frame": frames[0], "FPS": fps, "Particle Size": spec["size"],
+ "Streak Length": max(eff_speed * shutter, 0.02), "Sway": spec["sway"], "Seed": seed,
+ "Ground": gcol, "Splash": bool(splash and type == "rain"),
+ "Splash Time": 0.08, "Material": _material(type), "Camera": cam}
+ ids = {i.name: i.identifier for i in nt.interface.items_tree if getattr(i, "in_out", "") == "INPUT"}
+ for k, v in vals.items():
+ getattr(mod.properties.inputs, ids[k]).value = v
+ res.update({"object": ob.name, "count": count, "box_m": bx.r(list(size), 2),
+ "speed_ms": round(eff_speed, 2), "life_s": round(loop / fps / lives, 2), "loop_frames": loop,
+ "ground": [o.name for o in grounds]})
+ if type == "rain":
+ res["streak_m"] = round(vals["Streak Length"], 3)
+ res["note"] = "rain reads only when backlit: put a light or bright sky behind it"
+ return res
+
+
+if __name__ == "__main__":
+ p = bx.parser(__doc__)
+ p.add_argument("--type", default="rain", choices=sorted(TYPES))
+ p.add_argument("--intensity", default="moderate", choices=list(INTENSITY))
+ p.add_argument("--density", type=float, default=None)
+ p.add_argument("--wind", type=float, nargs=2, default=(0.0, 0.0))
+ p.add_argument("--ground", nargs="*", default=None)
+ p.add_argument("--distance", type=float, default=18.0)
+ p.add_argument("--loop-frames", type=int, default=None)
+ p.add_argument("--seed", type=int, default=0)
+ p.add_argument("--no-splash", dest="splash", action="store_false")
+ p.add_argument("--max-count", type=int, default=400000)
+ p.add_argument("--save", default=None)
+ bx.cli(run, p)
diff --git a/skills/blender-weather-fx/scripts/surface_weather.py b/skills/blender-weather-fx/scripts/surface_weather.py
new file mode 100644
index 0000000..b1d2e9f
--- /dev/null
+++ b/skills/blender-weather-fx/scripts/surface_weather.py
@@ -0,0 +1,366 @@
+"""Reversible weather layer on existing materials: wetness (porous darkening + water film coat),
+puddles with flattened normals and animated rain ripples, rain streaks on walls, snow cover; plus
+optional real snow geometry (GN shell) and a vertex-color mask for game engines.
+
+Inserts one ENV_Weather group node in front of every Principled BSDF of the target objects'
+materials; the original links/values are stored on the material and --remove restores them exactly.
+Masks are world-space, so puddles and snow line up across objects. Works in Cycles and EEVEE.
+Usage:
+ blender -b f.blend -P surface_weather.py -- --objects Street Car [--wetness 0.6] [--puddles 0.4]
+ [--ripples 1] [--streaks 0.5] [--snow 0.7] [--snow-depth 0.06] [--porosity 0.6]
+ [--scale 3.0] [--vertex-mask] [--save out.blend]
+ blender -b f.blend -P surface_weather.py -- --objects Street Car --remove
+ MCP: import surface_weather as sw; print(sw.run(objects=["Street"], wetness=0.7, puddles=0.4))
+"""
+import json
+import math
+import os
+import sys
+
+import bpy
+from mathutils import Vector, noise
+
+sys.path.insert(0, os.path.dirname(__file__))
+import _bpyx as bx # noqa: E402
+
+GROUP, SNOW_GN, SNOW_MAT, TAG, KEY = "ENV_Weather", "ENV_SnowCover", "ENV_M_Snow", "ENV_W_", "env_weather"
+WRAPPED = ("Base Color", "Roughness", "Normal", "Coat Weight", "Coat Roughness", "Coat Normal")
+PARAMS = ("Wetness", "Puddles", "Ripples", "Streaks", "Snow", "Porosity", "Scale")
+
+
+class _G:
+ def __init__(self, nt):
+ self.nt = nt
+
+ def link(self, a, b):
+ self.nt.links.new(a, b)
+
+ def set(self, sock, v):
+ if isinstance(v, bpy.types.NodeSocket):
+ self.link(v, sock)
+ elif v is not None:
+ sock.default_value = v
+
+ def n(self, type_, **props):
+ node = self.nt.nodes.new(type_)
+ for k, v in props.items():
+ setattr(node, k, v)
+ return node
+
+ def math(self, op, a, b=0.0, c=None, clamp=False):
+ m = self.n("ShaderNodeMath", operation=op, use_clamp=clamp)
+ for i, v in enumerate((a, b, c)):
+ self.set(m.inputs[i], v)
+ return m.outputs[0]
+
+ def mrange(self, v, a, b, lo=0.0, hi=1.0):
+ m = self.n("ShaderNodeMapRange", clamp=True)
+ for i, x in enumerate((v, a, b, lo, hi)):
+ self.set(m.inputs[i], x)
+ return m.outputs[0]
+
+ def mix(self, kind, fac, a, b):
+ m = self.n("ShaderNodeMix", data_type=kind)
+ sock = {"FLOAT": (0, 2, 3, 0), "VECTOR": (0, 4, 5, 1), "RGBA": (0, 6, 7, 2)}[kind]
+ self.set(m.inputs[sock[0]], fac)
+ self.set(m.inputs[sock[1]], a)
+ self.set(m.inputs[sock[2]], b)
+ return m.outputs[sock[3]]
+
+ def noise(self, vec, scale, detail=3.0, rough=0.55):
+ n = self.n("ShaderNodeTexNoise")
+ self.set(n.inputs["Vector"], vec)
+ self.set(n.inputs["Scale"], scale)
+ n.inputs["Detail"].default_value = detail
+ n.inputs["Roughness"].default_value = rough
+ return n.outputs["Factor"]
+
+
+def build_group():
+ ng = bpy.data.node_groups.get(GROUP) or bpy.data.node_groups.new(GROUP, "ShaderNodeTree")
+ ng.nodes.clear()
+ ng.interface.clear()
+ for nm, kind, d in (("Base Color", "Color", (0.8, 0.8, 0.8, 1)), ("Roughness", "Float", 0.5),
+ ("Normal", "Vector", None), ("Coat Weight", "Float", 0.0),
+ ("Coat Roughness", "Float", 0.03), ("Wetness", "Float", 0.0),
+ ("Puddles", "Float", 0.0), ("Ripples", "Float", 0.0), ("Streaks", "Float", 0.0),
+ ("Snow", "Float", 0.0), ("Porosity", "Float", 0.6), ("Scale", "Float", 1.5)):
+ s = ng.interface.new_socket(nm, in_out="INPUT", socket_type=f"NodeSocket{kind}")
+ if d is not None:
+ s.default_value = d
+ for nm, kind in (("Base Color", "Color"), ("Roughness", "Float"), ("Normal", "Vector"),
+ ("Coat Weight", "Float"), ("Coat Roughness", "Float"), ("Coat Normal", "Vector")):
+ ng.interface.new_socket(nm, in_out="OUTPUT", socket_type=f"NodeSocket{kind}")
+ g = _G(ng)
+ gi, go = g.n("NodeGroupInput"), g.n("NodeGroupOutput")
+ I = gi.outputs # noqa: E741
+ geo = g.n("ShaderNodeNewGeometry")
+ pos, nrm = geo.outputs["Position"], geo.outputs["Normal"]
+ sep_n = g.n("ShaderNodeSeparateXYZ")
+ g.link(nrm, sep_n.inputs[0])
+ up = sep_n.outputs["Z"]
+ sep_p = g.n("ShaderNodeSeparateXYZ")
+ g.link(pos, sep_p.inputs[0])
+ flat = g.n("ShaderNodeCombineXYZ") # world XY: puddles/ripples ignore height
+ g.link(sep_p.outputs["X"], flat.inputs["X"])
+ g.link(sep_p.outputs["Y"], flat.inputs["Y"])
+ inv_scale = g.math("DIVIDE", 1.0, I["Scale"])
+ # puddles: low-frequency noise on up-facing surfaces; coverage ~ Puddles
+ wn = g.n("ShaderNodeTexNoise") # domain warp: organic puddle edges
+ g.link(flat.outputs[0], wn.inputs["Vector"])
+ g.link(g.math("MULTIPLY", inv_scale, 0.7), wn.inputs["Scale"])
+ warp = g.n("ShaderNodeVectorMath", operation="MULTIPLY_ADD")
+ g.link(wn.outputs["Color"], warp.inputs[0])
+ amp = g.n("ShaderNodeCombineXYZ") # warp amplitude ~ 0.3 x feature size
+ wa = g.math("MULTIPLY", I["Scale"], 0.3)
+ g.link(wa, amp.inputs["X"])
+ g.link(wa, amp.inputs["Y"])
+ g.link(amp.outputs[0], warp.inputs[1])
+ g.link(flat.outputs[0], warp.inputs[2])
+ pn = g.noise(warp.outputs[0], inv_scale, 6.0, 0.6)
+ thr = g.math("MULTIPLY_ADD", I["Puddles"], -0.24, 0.62)
+ puddle = g.math("MULTIPLY", g.mrange(pn, thr, g.math("ADD", thr, 0.04)), g.mrange(up, 0.9, 0.97))
+ puddle = g.math("MULTIPLY", puddle, g.math("GREATER_THAN", I["Puddles"], 0.0))
+ wet = g.math("ADD", I["Wetness"], puddle, clamp=True)
+ # streaks: vertically stretched noise on walls
+ side = g.math("SUBTRACT", 1.0, g.math("MULTIPLY", up, up))
+ mp = g.n("ShaderNodeMapping")
+ g.link(pos, mp.inputs["Vector"])
+ mp.inputs["Scale"].default_value = (14.0, 14.0, 0.7)
+ streak = g.math("MULTIPLY", g.mrange(g.noise(mp.outputs[0], 1.0, 2.0), 0.5, 0.62),
+ g.math("MULTIPLY", side, I["Streaks"]))
+ # ripples: expanding rings, one per Voronoi cell, random phase; time from a frame driver
+ t = g.n("ShaderNodeValue", label="ENV time (s)")
+ fc = t.outputs[0].driver_add("default_value")
+ fps = bpy.context.scene.render.fps / bpy.context.scene.render.fps_base
+ fc.driver.expression = f"frame / {fps:g}"
+ vor = g.n("ShaderNodeTexVoronoi")
+ vor.voronoi_dimensions = "2D"
+ g.link(flat.outputs[0], vor.inputs["Vector"])
+ vor.inputs["Scale"].default_value = 6.0 # ~17 cm cells
+ cr = g.n("ShaderNodeSeparateColor")
+ g.link(vor.outputs["Color"], cr.inputs[0])
+ phase = g.math("FRACT", g.math("MULTIPLY_ADD", t.outputs[0], 1.6, cr.outputs[0]))
+ ring = g.math("SUBTRACT", 1.0, g.math("DIVIDE", g.math("ABSOLUTE", g.math(
+ "SUBTRACT", vor.outputs["Distance"], g.math("MULTIPLY", phase, 0.5))), 0.06), clamp=True)
+ ring = g.math("MULTIPLY", ring, g.math("SUBTRACT", 1.0, phase))
+ rip_h = g.math("MULTIPLY", ring, g.math("MULTIPLY", I["Ripples"], puddle))
+ bump_r = g.n("ShaderNodeBump")
+ bump_r.inputs["Strength"].default_value = 0.6
+ bump_r.inputs["Distance"].default_value = 0.002
+ g.link(rip_h, bump_r.inputs["Height"])
+ g.link(nrm, bump_r.inputs["Normal"])
+ # wet response (Lagarde): porous albedo darkens, roughness drops, a water film = coat
+ dark = g.math("SUBTRACT", 1.0, g.math("MULTIPLY", g.math("MULTIPLY", I["Porosity"], wet), 0.55))
+ base = g.mix("RGBA", 1.0, I["Base Color"], (0, 0, 0, 1))
+ m = base.node
+ m.blend_type = "MULTIPLY"
+ m.inputs[0].default_value = 1.0
+ dvec = g.n("ShaderNodeCombineColor")
+ for i in range(3):
+ g.link(dark, dvec.inputs[i])
+ g.link(dvec.outputs[0], m.inputs[7])
+ rough = g.math("MULTIPLY", I["Roughness"], g.math("MULTIPLY_ADD", wet, -0.6, 1.0))
+ coat_w = g.math("ADD", g.math("MULTIPLY_ADD", I["Wetness"], 0.6, puddle), streak, clamp=True)
+ coat_w = g.math("MAXIMUM", coat_w, I["Coat Weight"])
+ coat_r = g.mix("FLOAT", puddle, g.mix("FLOAT", I["Wetness"], I["Coat Roughness"], 0.12), 0.02)
+ normal = g.mix("VECTOR", puddle, I["Normal"], nrm) # water fills the cracks
+ # snow: up-facing with noisy edge; overrides everything it covers
+ sn = g.noise(pos, 2.0, 6.0, 0.6)
+ s_thr = g.math("MULTIPLY_ADD", I["Snow"], -0.8, 1.0) # coverage 1 -> anything facing up-ish
+ snow = g.mrange(g.math("MULTIPLY_ADD", g.math("SUBTRACT", sn, 0.5), 0.5, up), s_thr, g.math("ADD", s_thr, 0.15))
+ snow = g.math("MULTIPLY", snow, g.math("GREATER_THAN", I["Snow"], 0.0))
+ bump_s = g.n("ShaderNodeBump")
+ bump_s.inputs["Strength"].default_value = 0.25
+ g.link(g.noise(pos, 40.0, 2.0), bump_s.inputs["Height"])
+ g.link(normal, bump_s.inputs["Normal"])
+ g.link(g.mix("RGBA", snow, base, (0.88, 0.9, 0.94, 1)), go.inputs["Base Color"])
+ g.link(g.mix("FLOAT", snow, rough, 0.6), go.inputs["Roughness"])
+ g.link(g.mix("VECTOR", snow, normal, bump_s.outputs[0]), go.inputs["Normal"])
+ g.link(g.math("MULTIPLY", coat_w, g.math("SUBTRACT", 1.0, snow)), go.inputs["Coat Weight"])
+ g.link(coat_r, go.inputs["Coat Roughness"])
+ g.link(bump_r.outputs[0], go.inputs["Coat Normal"])
+ return ng
+
+
+def _src(sock):
+ if sock.is_linked:
+ lk = sock.links[0]
+ return {"node": lk.from_node.name, "out": lk.from_socket.identifier}
+ v = sock.default_value
+ return {"value": list(v) if hasattr(v, "__len__") else v}
+
+
+def _apply_mat(mat, ng, vals):
+ nt = mat.node_tree
+ record = json.loads(mat.get(KEY, "{}"))
+ for bsdf in [n for n in nt.nodes if n.type == "BSDF_PRINCIPLED"]:
+ gname = TAG + bsdf.name
+ gn = nt.nodes.get(gname)
+ if gn is None: # first application: remember and rewire
+ record[bsdf.name] = {k: _src(bsdf.inputs[k]) for k in WRAPPED}
+ gn = nt.nodes.new("ShaderNodeGroup")
+ gn.name, gn.label, gn.node_tree = gname, "ENV Weather", ng
+ gn.location = bsdf.location.x - 260, bsdf.location.y
+ for k in ("Base Color", "Roughness", "Coat Weight", "Coat Roughness"):
+ s = bsdf.inputs[k]
+ if s.is_linked:
+ nt.links.new(s.links[0].from_socket, gn.inputs[k])
+ else:
+ gn.inputs[k].default_value = s.default_value
+ if bsdf.inputs["Normal"].is_linked:
+ nt.links.new(bsdf.inputs["Normal"].links[0].from_socket, gn.inputs["Normal"])
+ else: # unlinked = shading normal; an unlinked group vector would be (0,0,0)
+ geo = nt.nodes.new("ShaderNodeNewGeometry")
+ geo.name = TAG + "geo_" + bsdf.name
+ geo.location = gn.location.x - 200, gn.location.y - 300
+ nt.links.new(geo.outputs["Normal"], gn.inputs["Normal"])
+ for k in WRAPPED:
+ nt.links.new(gn.outputs[k], bsdf.inputs[k])
+ for k, v in vals.items():
+ gn.inputs[k].default_value = v
+ mat[KEY] = json.dumps(record)
+
+
+def _remove_mat(mat):
+ nt = mat.node_tree
+ record = json.loads(mat.get(KEY, "{}"))
+ for bname, socks in record.items():
+ bsdf = nt.nodes.get(bname)
+ if bsdf is None:
+ continue
+ for k, src in socks.items():
+ s = bsdf.inputs[k]
+ for lk in list(s.links):
+ nt.links.remove(lk)
+ if "node" in src and src["node"] in nt.nodes:
+ nt.links.new(nt.nodes[src["node"]].outputs[src["out"]], s)
+ elif "value" in src:
+ s.default_value = src["value"]
+ for n in [n for n in nt.nodes if n.name.startswith(TAG)]:
+ nt.nodes.remove(n)
+ if KEY in mat:
+ del mat[KEY]
+
+
+def _snow_tree():
+ ng = bpy.data.node_groups.get(SNOW_GN) or bpy.data.node_groups.new(SNOW_GN, "GeometryNodeTree")
+ ng.nodes.clear()
+ ng.interface.clear()
+ ng.is_modifier = True
+ for nm, kind, d in (("Geometry", "Geometry", None), ("Coverage", "Float", 0.7), ("Depth", "Float", 0.06),
+ ("Noise Scale", "Float", 1.5), ("Material", "Material", None)):
+ s = ng.interface.new_socket(nm, in_out="INPUT", socket_type=f"NodeSocket{kind}")
+ if d is not None:
+ s.default_value = d
+ ng.interface.new_socket("Geometry", in_out="OUTPUT", socket_type="NodeSocketGeometry")
+ g = _G(ng)
+ gi, go = g.n("NodeGroupInput"), g.n("NodeGroupOutput")
+ I = gi.outputs # noqa: E741
+ sep_n = g.n("ShaderNodeSeparateXYZ")
+ g.link(g.n("GeometryNodeInputNormal").outputs["Normal"], sep_n.inputs[0])
+ sel = g.math("GREATER_THAN", sep_n.outputs["Z"], g.math("MULTIPLY_ADD", I["Coverage"], -0.8, 1.0))
+ part = g.n("GeometryNodeSeparateGeometry", domain="FACE")
+ g.link(I["Geometry"], part.inputs["Geometry"])
+ g.link(sel, part.inputs["Selection"])
+ sub = g.n("GeometryNodeSubdivideMesh")
+ g.link(part.outputs["Selection"], sub.inputs["Mesh"])
+ sub.inputs["Level"].default_value = 2
+ nz = g.noise(g.n("GeometryNodeInputPosition").outputs[0], g.math("DIVIDE", 1.0, I["Noise Scale"]))
+ h = g.math("MULTIPLY", g.math("MULTIPLY_ADD", nz, 0.8, 0.6), I["Depth"]) # never 0: no z-fighting
+ off = g.n("ShaderNodeCombineXYZ")
+ g.link(h, off.inputs["Z"])
+ ext = g.n("GeometryNodeExtrudeMesh", mode="FACES")
+ g.link(sub.outputs[0], ext.inputs["Mesh"])
+ g.link(off.outputs[0], ext.inputs["Offset"])
+ ext.inputs["Individual"].default_value = False
+ smooth = g.n("GeometryNodeSetShadeSmooth")
+ g.link(ext.outputs["Mesh"], smooth.inputs["Geometry"])
+ sm = g.n("GeometryNodeSetMaterial")
+ g.link(smooth.outputs[0], sm.inputs["Geometry"])
+ g.link(I["Material"], sm.inputs["Material"])
+ join = g.n("GeometryNodeJoinGeometry")
+ g.link(sm.outputs[0], join.inputs[0])
+ g.link(I["Geometry"], join.inputs[0])
+ g.link(join.outputs[0], go.inputs[0])
+ return ng
+
+
+def _snow_material():
+ mat = bpy.data.materials.get(SNOW_MAT) or bpy.data.materials.new(SNOW_MAT)
+ b = bx.node(mat.node_tree, "BSDF_PRINCIPLED")
+ for k, v in {"Base Color": (0.88, 0.9, 0.94, 1), "Roughness": 0.6, "Subsurface Weight": 0.6,
+ "Subsurface Radius": (0.6, 0.8, 1.0), "Subsurface Scale": 0.03}.items():
+ b.inputs[k].default_value = v
+ return mat
+
+
+def _vertex_mask(ob, puddles, snow, scale):
+ """Color attribute ENV_Weather (R puddle, G snow, B wall/streak) for engine shaders."""
+ me = ob.data
+ attr = me.color_attributes.get("ENV_Weather") or me.color_attributes.new("ENV_Weather", "FLOAT_COLOR", "POINT")
+ mw, nm = ob.matrix_world, ob.matrix_world.to_3x3().inverted().transposed()
+ cols = []
+ for v in me.vertices:
+ p, n = mw @ v.co, (nm @ v.normal).normalized()
+ nz = noise.noise(Vector((p.x / scale, p.y / scale, 0.0))) * 0.5 + 0.5
+ thr = 0.62 - 0.24 * puddles
+ pud = (min(max((nz - thr) / 0.04, 0), 1) * min(max((n.z - 0.9) / 0.07, 0), 1)) if puddles else 0.0
+ sthr = 1 - 0.8 * snow
+ sn = min(max((n.z - sthr) / 0.15, 0), 1) if snow else 0.0
+ cols.extend((pud, sn, 1 - n.z * n.z, 1.0))
+ attr.data.foreach_set("color", cols)
+ me.color_attributes.active_color_name = attr.name # exporters write the active color
+ return attr.name
+
+
+def run(objects=None, wetness=0.0, puddles=0.0, ripples=0.0, streaks=0.0, snow=0.0, snow_depth=0.0,
+ porosity=0.6, scale=3.0, vertex_mask=False, remove=False, **_):
+ bx.object_mode()
+ obs = [o for o in bx.objects(objects) if o.type == "MESH"]
+ mats = {s.material for o in obs for s in o.material_slots if s.material and s.material.node_tree}
+ if remove:
+ for m in mats:
+ _remove_mat(m)
+ for o in obs:
+ for md in [md for md in o.modifiers if md.name == SNOW_GN]:
+ o.modifiers.remove(md)
+ ca = o.data.color_attributes.get("ENV_Weather")
+ if ca:
+ o.data.color_attributes.remove(ca)
+ return {"ok": True, "removed": sorted(m.name for m in mats), "objects": [o.name for o in obs]}
+ no_mat = [o.name for o in obs if not any(s.material for s in o.material_slots)]
+ ng = build_group()
+ vals = dict(Wetness=wetness, Puddles=puddles, Ripples=ripples, Streaks=streaks, Snow=snow,
+ Porosity=porosity, Scale=scale)
+ for m in mats:
+ _apply_mat(m, ng, vals)
+ res = {"ok": True, "materials": sorted(m.name for m in mats), "objects": [o.name for o in obs],
+ "params": {k: v for k, v in vals.items() if v}}
+ if no_mat:
+ res["warning"] = f"no material (skipped): {no_mat}"
+ if snow_depth > 0:
+ sg, smat = _snow_tree(), _snow_material()
+ for o in obs:
+ md = o.modifiers.get(SNOW_GN) or o.modifiers.new(SNOW_GN, "NODES")
+ md.node_group = sg
+ ids = {i.name: i.identifier for i in sg.interface.items_tree if getattr(i, "in_out", "") == "INPUT"}
+ for k, v in (("Coverage", snow or 0.7), ("Depth", snow_depth), ("Noise Scale", scale), ("Material", smat)):
+ getattr(md.properties.inputs, ids[k]).value = v
+ res["snow_geometry"] = {"modifier": SNOW_GN, "depth_m": snow_depth}
+ if vertex_mask:
+ res["vertex_mask"] = [_vertex_mask(o, puddles, snow, scale) for o in obs][:1]
+ if ripples and not puddles:
+ res["note"] = "ripples only show inside puddles (--puddles > 0)"
+ return res
+
+
+if __name__ == "__main__":
+ p = bx.add_common(bx.parser(__doc__))
+ for k in ("wetness", "puddles", "ripples", "streaks", "snow", "snow-depth"):
+ p.add_argument(f"--{k}", type=float, default=0.0)
+ p.add_argument("--porosity", type=float, default=0.6)
+ p.add_argument("--scale", type=float, default=3.0)
+ p.add_argument("--vertex-mask", action="store_true")
+ p.add_argument("--remove", action="store_true")
+ bx.cli(run, p)
diff --git a/skills/blender-workflow-recipes/SKILL.md b/skills/blender-workflow-recipes/SKILL.md
index 4fc3e8b..aec155c 100644
--- a/skills/blender-workflow-recipes/SKILL.md
+++ b/skills/blender-workflow-recipes/SKILL.md
@@ -1,10 +1,10 @@
---
name: blender-workflow-recipes
-description: End-to-end Blender 5.2 playbooks chaining the blender-* skills with QA gates - game props (mid-poly, high-to-low), game characters (sculpt/AI mesh to rigged, animated export), Roblox props/accessories/avatars, AI or downloaded asset cleanup, procedural environments, web/AR assets, product turntables. Use for complete multi-stage asset requests.
+description: End-to-end Blender 5.2 playbooks chaining the blender-* skills with QA gates - game props (mid-poly, high-to-low), game characters (sculpt/AI mesh to rigged, animated export), Roblox props/accessories/avatars, AI or downloaded asset cleanup, procedural environments, web/AR assets, product turntables, mood/weather shots (night, rain, snow, fog). Use for complete multi-stage asset requests.
license: MIT
metadata:
author: blender-agent-skills
- version: "0.1.0"
+ version: "1.1.0"
---
# Workflow Recipes
@@ -66,3 +66,9 @@ Recipe 1 or 2 with budgets `--budget web` (≤30k tris, 1–2 materials, 2k text
2. Set the render resolution, then `turntable.py --objects Product --rig studio --backdrop --frames 120 --lens 85`
3. `render_batch.py --preset preview --frames 1` → review → `--preset product --frames 1-120 --format PNG` → encode, or `--format MP4`.
4. Gate: no fireflies or clipped highlights (AgX / Khronos PBR Neutral), and the product sits on the backdrop (contact shadow).
+
+## 9. Mood / weather shot (rainy night, snowy morning, foggy dawn)
+1. Scene at real scale with a camera. QA the hero assets first (wet reflections and snow expose z-fighting and gaps).
+2. `scene_mood.py --time night --fog-visibility 250` (or `--mood cyberpunk|horror|underwater|desert`). Add practical lights (street, windows, neon) at real color temperatures.
+3. Weather: `precipitation.py --type rain --intensity heavy --ground <ground/roofs>` → `surface_weather.py --objects <surfaces> --wetness 0.7 --puddles 0.4 --ripples 1 --streaks 0.5` → `lightning.py --flashes 2`. Snow: `--type snow` + `--snow 0.8 --snow-depth 0.06`.
+4. Gate: `render_batch.py --preset preview --frames <mid>,<flash>` at the final aspect ratio. Rain must read (backlit), puddles must reflect a light, the night must keep contrast. Then render the full loop (frame range = the precipitation loop).
diff --git a/tests/fixtures.py b/tests/fixtures.py
index 8256308..4009cdb 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -64,6 +64,27 @@ def unwrap(ob):
return ob
+def street():
+ """Ground slab (top at z=0), two buildings, a grey sphere, each with a Principled material, and a
+ camera looking down the street. Returns the object names."""
+ def mat(ob, rgb):
+ m = bpy.data.materials.new("M_" + ob.name)
+ b = next(n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED")
+ b.inputs["Base Color"].default_value = (*rgb, 1)
+ ob.data.materials.append(m)
+ return ob
+ mat(cube("Ground", size=1, location=(0, 0, -0.05)), (0.18, 0.18, 0.18)).scale = (30, 30, 0.1)
+ mat(cube("BldA", size=1, location=(-5, 6, 4)), (0.45, 0.4, 0.35)).scale = (4, 4, 8)
+ mat(cube("BldB", size=1, location=(5, 8, 5)), (0.3, 0.32, 0.35)).scale = (4, 4, 10)
+ mat(uv_sphere("Ball", radius=1, location=(0, 0, 1)), (0.18, 0.18, 0.18))
+ cam = bpy.data.objects.new("Cam", bpy.data.cameras.new("Cam"))
+ bpy.context.scene.collection.objects.link(cam)
+ cam.location, cam.rotation_euler = (0, -14, 3), (1.48, 0, 0)
+ bpy.context.scene.camera = cam
+ bpy.context.view_layer.update()
+ return ["Ground", "BldA", "BldB", "Ball"]
+
+
def simple_character():
"""Capsule-ish mesh + 3-bone chain armature, auto-weighted. Returns (mesh, armature)."""
def build(bm):
diff --git a/tests/test_atmosphere.py b/tests/test_atmosphere.py
new file mode 100644
index 0000000..83c3459
--- /dev/null
+++ b/tests/test_atmosphere.py
@@ -0,0 +1,64 @@
+import bpy
+import fixtures as fx
+from run_all import TMP, skill_module
+
+
+def _mean_luma(path):
+ img = bpy.data.images.load(path)
+ px = list(img.pixels)
+ bpy.data.images.remove(img)
+ return sum(px[i] * 0.2126 + px[i + 1] * 0.7152 + px[i + 2] * 0.0722 for i in range(0, len(px), 4)) / (len(px) / 4)
+
+
+def _render(tag):
+ sc = bpy.context.scene
+ sc.render.engine = "CYCLES"
+ sc.cycles.device, sc.cycles.samples, sc.cycles.use_denoising = "CPU", 8, False
+ sc.render.resolution_x, sc.render.resolution_y = 32, 18
+ sc.render.image_settings.file_format = "PNG"
+ sc.render.filepath = str(TMP / "mood" / f"{tag}.png")
+ bpy.ops.render.render(write_still=True)
+ return _mean_luma(sc.render.filepath)
+
+
+def test_time_presets_sun_color_and_balance():
+ fx.street()
+ sm = skill_module("blender-time-of-day", "scene_mood")
+ noon = sm.run(time="noon")
+ assert noon["key"]["color"][2] > 0.6 and abs(noon["exposure"]) < 0.3, noon
+ sunset = sm.run(time="sunset")
+ assert sunset["key"]["color"][1] < 0.4 and sunset["key"]["color"][2] < 0.05, sunset # red sun
+ assert len([o for o in bpy.data.objects if o.name.startswith("ENV_Mood_")]) == 1 # rerun replaces
+ blue = sm.run(time="blue_hour")
+ assert "key" not in blue and bpy.context.scene.world.name == "ENV_World"
+ night = sm.run(time="night")
+ assert night["key"]["light"] == "ENV_Mood_Moon"
+ sky = next(n for n in bpy.context.scene.world.node_tree.nodes if n.type == "TEX_VORONOI") # stars
+ assert sky is not None
+
+
+def test_night_renders_darker_than_noon():
+ fx.street()
+ sm = skill_module("blender-time-of-day", "scene_mood")
+ sm.run(time="noon")
+ day = _render("noon")
+ sm.run(time="night")
+ night = _render("night")
+ assert 0.25 < day < 0.85 and night < day * 0.75, (day, night)
+
+
+def test_fog_density_from_visibility_and_moods():
+ fx.street()
+ sm = skill_module("blender-time-of-day", "scene_mood")
+ r = sm.run(time="morning", fog_visibility=150, fog_height=4)
+ assert abs(r["fog"]["density"] - 3.912 / 150) < 1e-4, r
+ fog = bpy.data.objects[r["fog"]["object"]]
+ assert any(n.type == "PRINCIPLED_VOLUME" for n in fog.data.materials[0].node_tree.nodes)
+ assert bpy.context.scene.eevee.use_volumetric_shadows
+ r = sm.run(mood="cyberpunk")
+ assert r["accents"] == 2 and r["grade"] == "ENV_Grade", r
+ ng = bpy.context.scene.compositing_node_group
+ assert ng.name == "ENV_Grade" and any(n.bl_idname == "CompositorNodeGlare" for n in ng.nodes)
+ assert bpy.context.scene.view_settings.look == "AgX - Punchy"
+ r = sm.run(time="noon", use_exposure=True, mood="horror")
+ assert r["practical_scale"] > 0 and abs(bpy.context.scene.view_settings.exposure - r["exposure"]) < 0.01
diff --git a/tests/test_weather.py b/tests/test_weather.py
new file mode 100644
index 0000000..8a23114
--- /dev/null
+++ b/tests/test_weather.py
@@ -0,0 +1,88 @@
+import bpy
+import fixtures as fx
+from run_all import skill_module
+
+
+def _instances(ob, frame):
+ sc = bpy.context.scene
+ sc.frame_set(frame)
+ dg = bpy.context.evaluated_depsgraph_get()
+ return [tuple(i.matrix_world.translation) for i in dg.object_instances
+ if i.is_instance and i.parent and i.parent.original == ob]
+
+
+def test_precipitation_loops_and_stops_on_ground():
+ names = fx.street()
+ sc = bpy.context.scene
+ sc.frame_start, sc.frame_end = 1, 48
+ pr = skill_module("blender-weather-fx", "precipitation")
+ r = pr.run(type="rain", density=1.0, ground=names[:3], wind=(1.0, 0.0))
+ assert r["ok"] and r["count"] > 100 and abs(r["speed_ms"] - 7.07) < 0.05, r
+ ob = bpy.data.objects[r["object"]]
+ a, b = _instances(ob, 1), _instances(ob, 49) # loop end + 1 == start
+ assert a and len(a) == len(b)
+ assert max(abs(p - q) for u, v in zip(a, b) for p, q in zip(u, v)) < 1e-3
+ zs = [p[2] for p in _instances(ob, 17)]
+ assert min(zs) > -0.02, min(zs) # nothing falls through the street (top at z=0)
+ r = pr.run(type="snow", density=0.5, ground=["Ground"])
+ assert r["speed_ms"] == 1.0 and r["life_s"] > 0
+ r = pr.run(type="embers", density=0.2)
+ assert r["object"] == "ENV_Weather_Embers"
+
+
+def test_surface_weather_roundtrip_restores_materials():
+ names = fx.street()
+ mat = bpy.data.materials["M_Ground"]
+ nt = mat.node_tree
+ bsdf = next(n for n in nt.nodes if n.type == "BSDF_PRINCIPLED")
+ tex = nt.nodes.new("ShaderNodeTexNoise")
+ nt.links.new(tex.outputs["Color"], bsdf.inputs["Base Color"]) # linked input must survive
+ bsdf.inputs["Roughness"].default_value = 0.42
+ before = sorted((lk.from_node.name, lk.to_socket.identifier) for lk in nt.links)
+ sw = skill_module("blender-weather-fx", "surface_weather")
+ r = sw.run(objects=names, wetness=0.6, puddles=0.4, ripples=1, streaks=0.5, snow=0.3)
+ assert "M_Ground" in r["materials"], r
+ assert bsdf.inputs["Coat Weight"].is_linked and bsdf.inputs["Base Color"].links[0].from_node.name.startswith("ENV_W_")
+ sw.run(objects=names, wetness=0.9) # re-run updates in place, no second group
+ assert len([n for n in nt.nodes if n.name.startswith("ENV_W_") and n.type == "GROUP"]) == 1
+ sw.run(objects=names, remove=True)
+ after = sorted((lk.from_node.name, lk.to_socket.identifier) for lk in nt.links)
+ assert after == before and abs(bsdf.inputs["Roughness"].default_value - 0.42) < 1e-6
+ assert not any(n.name.startswith("ENV_W_") for n in nt.nodes) and "env_weather" not in mat
+
+
+def test_snow_geometry_and_vertex_mask():
+ fx.street()
+ ball = bpy.data.objects["Ball"]
+ faces0 = len(ball.data.polygons)
+ sw = skill_module("blender-weather-fx", "surface_weather")
+ r = sw.run(objects=["Ball"], snow=0.8, snow_depth=0.05, vertex_mask=True)
+ assert r["snow_geometry"]["depth_m"] == 0.05 and r["vertex_mask"] == ["ENV_Weather"]
+ eo = ball.evaluated_get(bpy.context.evaluated_depsgraph_get())
+ me = eo.to_mesh()
+ top = max(v.co.z for v in me.vertices)
+ faces = len(me.polygons)
+ eo.to_mesh_clear()
+ assert faces > faces0 and top > 1.0 + 0.02, (faces, top) # shell sits above the sphere top
+ assert ball.data.color_attributes.active_color_name == "ENV_Weather"
+ sw.run(objects=["Ball"], remove=True)
+ assert not ball.modifiers and "ENV_Weather" not in ball.data.color_attributes
+
+
+def test_lightning_keys_strokes_and_bolt():
+ fx.street()
+ sm = skill_module("blender-time-of-day", "scene_mood")
+ sm.run(time="night")
+ lt = skill_module("blender-weather-fx", "lightning")
+ r = lt.run(frames=[20], strokes=3, seed=1)
+ assert r["bolt"] == "ENV_Storm_Bolt" and r["sky_flash"] == "ENV_World", r
+ light = bpy.data.objects[r["light"]].data
+ sc = bpy.context.scene
+ vals = []
+ for f in range(18, 32):
+ sc.frame_set(f)
+ vals.append(light.energy)
+ peaks = sum(1 for i in range(1, len(vals) - 1) if vals[i] > vals[i - 1] and vals[i] >= vals[i + 1] and vals[i] > 0.3 * r["peak_strength"])
+ assert peaks == 3 and vals[0] == 0.0, vals
+ again = lt.run(frames=[20])
+ assert len([o for o in bpy.data.objects if o.name.startswith("ENV_Storm_")]) == 2 and again["ok"]
diff --git a/tools/trigger_check.py b/tools/trigger_check.py
index 817b947..df1e90f 100644
--- a/tools/trigger_check.py
+++ b/tools/trigger_check.py
@@ -34,6 +34,10 @@ CASES = [
("make a complete game-ready character from an AI generated mesh", "blender-workflow-recipes"),
("run bpy code in blender headless via the cli", "blender-core"),
("roblox layered clothing cage and R15 export", "blender-export-pipelines"),
+ ("golden hour sunset lighting with volumetric fog", "blender-time-of-day"),
+ ("make it a moonlit night scene with stars", "blender-time-of-day"),
+ ("rainy street with puddles, wet surfaces and lightning", "blender-weather-fx"),
+ ("snow falling and snow cover on the roofs", "blender-weather-fx"),
]