---
name: 3d-image-renderer
description: Generate PNG images by building a real Three.js 3D scene and capturing one frame headlessly — no image model involved. Takes a text prompt and an aspect ratio (1:1, 16:9, or 9:16) and produces a rendered PNG. Use this skill whenever the user asks to generate, create, or render an image, picture, scene, wallpaper, thumbnail background, or product shot with this system — especially with phrases like "generate an image of", "render a scene", "create a PNG", "no image model", "3D render of", or a prompt paired with an aspect ratio. Also use it when the user wants an image in a named visual style (dark studio, Apple light, nature, sunset, night, underwater). Not for editing existing images, 2D vector art, or animated video (VidTSX handles video).
title: 3d-image-renderer
canonical_url: https://skilld.dev/gh/hassancs91/claude-image-generation/level-2-image-generator
last_updated: 2026-10-09T12:01:14.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [assets/webgl-abi127-linux-x64.node](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/assets/webgl-abi127-linux-x64.node), [references/geometry-recipes.md](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/references/geometry-recipes.md), [references/style-presets.md](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/references/style-presets.md), [scripts/lib/pipeline.mjs](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/scripts/lib/pipeline.mjs), [scripts/setup.sh](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/scripts/setup.sh), [scripts/validate.mjs](https://skilld.dev/api/skills-raw/hassancs91/claude-image-generation/level-2-image-generator/scripts/validate.mjs).
>
> If the user asked to install this Skill, run `npx skilld install hassancs91/claude-image-generation/level-2-image-generator`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/level-2-image-generator`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/hassancs91/claude-image-generation/level-2-image-generator) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/level-2-image-generator`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/level-2-image-generator --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/level-2-image-generator --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 3D Image Renderer

Renders a text prompt into a PNG by writing a Three.js scene and capturing
one frame with headless-gl under Xvfb. Think of every image as frame 0 of a
TSX animation composition: deterministic, seeded, time = 2.0s.

## Inputs

- **prompt** — what to render
- **aspect ratio** — one of `1:1` (1080×1080), `16:9` (1920×1080), `9:16`
  (1080×1920). Default `16:9` if unspecified. No custom sizes.

## Workflow (follow in order)

### 1. Setup

```bash
bash <skill_dir>/scripts/setup.sh
```

Idempotent; instant when cached. Installs npm deps into
`/home/claude/scene-render/` and drops the bundled prebuilt `gl` binary in
place (compiles from source only if the binary fails its smoke test). It also
copies `pipeline.mjs` and `validate.mjs` into the workdir. If it prints
`SETUP FAILED`, report the error to the user — do not hand-roll a fallback.

### 2. Plan the scene

- Pick ONE style preset → read `references/style-presets.md` now.
- List the **hero elements**: every concrete noun in the prompt
  ("headphones", "tree", "flowers") is a hero element.
- Read `references/geometry-recipes.md` for any element it covers before
  inventing geometry.

### 3. Write the scene

Create `/home/claude/scene-render/scene.mjs`. Import ONLY from the local
pipeline — never re-implement renderer setup, pixel readback, or PNG writing:

```js
import {
  THREE, createRenderer, captureFrame, addStudioEnvironment,
  seededRandom, visibleHeightAt,
} from './pipeline.mjs';

const time = 2.0; // the captured "frame"
const { renderer, glContext, W, H, OUT_W, OUT_H } =
  createRenderer('16:9', { exposure: 1.15 /* from style preset */ });

const scene = new THREE.Scene();
// ... build: sky, lights, ground, hero elements (per preset + recipes) ...

await captureFrame({
  renderer, glContext, scene, camera, W, H, OUT_W, OUT_H,
  outPath: '/home/claude/scene-render/out.png',
});
console.log('DONE');
```

Scene-authoring rules:
- All randomness via `seededRandom(seed)` — never `Math.random()`.
- `InstancedMesh` for anything repeated 50+ times; per-instance color via
  `setColorAt` + `instanceColor.needsUpdate = true`.
- Bake rotations into geometry (`geometry.rotateZ(...)`) — do not stack Euler
  rotations on meshes for construction.
- Validate every horizon/background element with `visibleHeightAt` (the FOV
  rule in geometry-recipes.md) BEFORE rendering.
- No post-processing. Glow = emissive + additive blending + fog.
- WebGL1 only: no `transmission`, no WebGL2-only features, three stays at
  0.152.2 (pinned by setup — do not upgrade).

### 4. Render

```bash
cd /home/claude/scene-render && xvfb-run -a node scene.mjs
```

### 5. Validate (mandatory — never skip)

Write a hero spec covering each prompt-named element with its dominant
material color, then:

```bash
node validate.mjs out.png heroes.json
```

```json
[
  { "name": "flowers", "hex": "f5a8c8", "tolerance": 45, "minPct": 0.3 },
  { "name": "tree canopy", "hex": "5a9440", "tolerance": 60, "minPct": 2.0 }
]
```

Also open the PNG with the view tool if image viewing works in this session.
If it returns placeholders, rely on the validator output (histogram, ASCII
map, presence checks) — it was designed for exactly that.

Fix and re-render when:
- any hero element FAILs presence (typical fixes: more instances, bigger
  scale, camera reframe, contrasting material)
- WASHED OUT / TOO DARK / LOW CONTRAST warnings (typical fixes: exposure and
  ambient per the style preset table; in light styles swap pure-white
  materials for metallic/mid-gray)
- the ASCII map shows a composition failure (subject cropped, background
  walling off the sky)

Maximum 2 fix iterations, then deliver best result and tell the user what
still needs work.

### 6. Deliver

```bash
cp /home/claude/scene-render/out.png "/mnt/user-data/outputs/<descriptive_name>.png"
```

Present the PNG with `present_files`. Keep the summary short: style preset
used, hero elements, and any validation fixes applied. Only include
`scene.mjs` in the delivery if the user asks for the code.

## Hard rules (violating any of these produced real failures)

1. three@0.152.2 pinned — r163+ drops WebGL1 and headless-gl is WebGL1-only.
2. Pixel readback needs vertical flip + alpha forced to 255 (pipeline does it).
3. No MSAA headless — SSAA 2× via the pipeline is the anti-aliasing.
4. Light styles: exposure ≤ 1.08, ambient ≤ 0.35, and the hero MUST include a
   metallic or mid-gray material. Pure white on white is invisible.
5. Background elements sized by intuition WILL wall off the sky — run the FOV
   check.
6. Prompt-named elements must pass the presence validator before delivery.
7. Everything deterministic: `seededRandom`, fixed `time = 2.0`.
