---
name: studio-environment-lighting
description: Plan, build and review lighting for a small stylized environment (diorama, game scene, key art) with value structure, warm practicals and a controlled palette in Blender or Three.js. Use for "light this scene", "cozy night market", "moody lighting", "stylized environment render".
version: "1.1.0"
category: build
platforms: [CLAUDE_CODE, CURSOR, CODEX_CLI]
---

# Stylized environment lighting

Lighting is value design first and color second. A scene that reads in grayscale at thumbnail size will survive any palette. This skill gives an agent a repeatable pipeline: brief, grayscale blockout, key and fill, practicals, atmosphere, grade, review.

## When to use

- A small scene (street corner, market stall, room, island, diorama) needs a finished lighting pass.
- Comparing lighting variants (dusk vs night, warm vs cool) for key art or a game level.
- Converting an illustration's mood into a 3D or realtime scene.

## Agree on inputs first

- **Story point**: the single thing the eye should land on (lantern stall, doorway, character).
- **Time of day and weather**: sets key direction, color temperature and haze.
- **Palette**: 5 to 7 colors max. One dominant (often cool ambient), one accent (warm practical), neutrals.
- **Renderer**: Blender Eevee (fast, stylized), Cycles (accurate GI), Three.js (realtime web), Godot or Unity.
- **Output**: still size (e.g. 1920x1080, 1080x1350), turntable or camera move, realtime budget.

## Value plan (do this before any color)

Assign each depth plane a value band on 0 to 100 (L* lightness):

| Plane            | Night scene                         | Day scene          |
| ---------------- | ----------------------------------- | ------------------ |
| Sky / background | 15 to 30                            | 70 to 90           |
| Midground        | 20 to 40                            | 45 to 65           |
| Foreground frame | 5 to 15 (silhouette)                | 25 to 40           |
| Focal point      | 70 to 95, highest contrast in frame | high contrast edge |

Rule of thumb: the highest local contrast and the warmest saturated color both sit at the focal point. Everything else is calmer.

## Toolchain

- **Blender 4.x** with Eevee Next or Cycles, AgX view transform (default since 4.0; prefer it over Standard for highlight rolloff).
- **Three.js** with `ACESFilmicToneMapping` or `AgXToneMapping`, `renderer.outputColorSpace = THREE.SRGBColorSpace`.
- **Pillow / ImageMagick** for grayscale and thumbnail checks.
- Alternatives: Unity URP or HDRP, Godot 4 (WorldEnvironment with Filmic or AgX tonemap, volumetric fog).

## Workflow

### 1. Grayscale blockout

Override all materials with a mid-gray diffuse (Blender: View Layer > Override > Material, or `view_layer.material_override`). Light only with a sun or sky. Judge composition at 256 px wide. Fix overlaps and tangents now; they get harder to see once color arrives.

### 2. Key, fill, rim

Blender script for a dusk setup:

```python
import bpy, math
scn = bpy.context.scene
scn.render.engine = 'BLENDER_EEVEE_NEXT'   # 4.2 to 4.4; 'BLENDER_EEVEE' on 5.x; 'CYCLES' for final GI
scn.view_settings.view_transform = 'AgX'
scn.view_settings.look = 'AgX - Medium High Contrast'

def light(name, kind, energy, color, loc, rot=(0,0,0), size=None):
    data = bpy.data.lights.new(name, kind)
    data.energy = energy
    data.color = color
    if size and kind == 'AREA': data.size = size
    obj = bpy.data.objects.new(name, data)
    obj.location, obj.rotation_euler = loc, [math.radians(a) for a in rot]
    scn.collection.objects.link(obj)
    return obj

light('Key_Moon', 'SUN', 0.6, (0.62, 0.74, 1.0), (0,0,10), (55, 0, 35))  # cool, low
light('Rim',      'AREA', 300, (0.55, 0.65, 1.0), (-4, 6, 4), (70, 0, 200), size=3)
lantern = light('Practical_Lantern', 'POINT', 40, (1.0, 0.62, 0.3), (0.3, -0.2, 1.6))
lantern.data.shadow_soft_size = 0.05
```

World ambient: set the world background strength low (0.05 to 0.2 at night) with a desaturated blue, so shadows stay readable but not black.

### 3. Practicals

- Every practical light (lantern, window, sign) needs a visible source: an emissive mesh (`Emission Strength` 5 to 20) plus a real light placed just outside it so it casts.
- Warm practicals at 2200 to 3200 K, cool ambient around 6500 to 9000 K. Blender 4.x lights accept a temperature directly on recent versions; otherwise use RGB like `(1.0, 0.6, 0.3)`.
- Use falloff to create pools of light and leave quiet dark gaps between them. Uniform brightness kills depth.
- Limit to 3 to 5 practicals in a small scene. Each one is a secondary focal point competing with the main one.

### 4. Atmosphere

- Blender Eevee: World Volume > Principled Volume, density 0.005 to 0.03. Cycles: same, but expect slower renders.
- Three.js: `scene.fog = new THREE.FogExp2(0x1b2238, 0.035)` and a bloom pass (`UnrealBloomPass(resolution, 0.6, 0.4, 0.85)`) only on emissives above threshold.
- Haze lifts background values. That separates depth planes for free.

### 5. Grade and output

Keep the grade in the render (AgX look, exposure, curves in the compositor) so it is reproducible. Render the same camera and exposure for every variant.

```bash
blender -b scene.blend -E CYCLES -o //renders/night_#### -F PNG -f 1
blender -b scene.blend --python-expr "import bpy; bpy.context.scene.cycles.samples=256" -f 1
```

Turntable or camera move to video:

```bash
ffmpeg -framerate 24 -i renders/night_%04d.png -c:v libx264 -crf 16 -pix_fmt yuv420p -movflags +faststart turntable.mp4
```

## Common variants

- **Time-of-day set**: duplicate scene, change only key angle, key color, world color and practical energy. Keep the camera locked; export a 2x2 comparison grid with `ffmpeg -i a.png -i b.png -i c.png -i d.png -filter_complex xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0 grid.png`.
- **Realtime web**: bake lighting to lightmaps in Blender (Cycles bake, `bpy.ops.object.bake(type='COMBINED')`) and use `MeshBasicMaterial` with the baked texture for cheap, consistent results.
- **Vertical key art 4:5 or 9:16**: re-frame the camera, do not crop; move the focal point to the upper third.
- **Painted look**: Eevee with Shader to RGB plus a Color Ramp (constant) for toon bands; keep 2 to 3 bands.

## Quality checks

- **Grayscale thumbnail**: `magick render.png -colorspace Gray -resize 256x thumb.png`. The focal point must be findable in under one second.
- **Value histogram**: `magick render.png -colorspace Gray -format %c histogram:info:- | sort -n | tail` or in Python with Pillow. Avoid more than 5% of pixels at pure 0 or 255 (crushed blacks, clipped whites) unless intentional.
- **Squint / blur test**: `magick render.png -blur 0x8 blur.png`; the composition's big shapes should still read.
- **Focal contrast**: measure luminance of the focal point vs its surroundings; aim for at least 3:1 local ratio, while the rest of the frame stays under that.
- **Palette count**: `magick render.png -colors 8 -unique-colors txt:` and confirm the dominant hues match the brief.
- **Noise**: Cycles renders at final resolution show no fireflies; use the OpenImageDenoise denoiser and clamp indirect at about 10.

## Pitfalls and fixes

| Problem                               | Fix                                                                         |
| ------------------------------------- | --------------------------------------------------------------------------- |
| Flat, muddy image                     | Values too close; widen bands between planes, darken foreground frame       |
| Everything orange                     | Warm practicals with no cool counterweight; cool the ambient and shadows    |
| Emissive lamps light nothing in Eevee | Emission is not a light source in Eevee; add a real light near each emitter |
| Blown highlights look neon            | Use AgX instead of Standard; lower emission strength rather than bloom      |
| Variants not comparable               | Locked camera, fixed exposure, same samples and seed for every render       |
| Three.js scene too dark or washed out | Missing `outputColorSpace` or textures not tagged `SRGBColorSpace`          |
| Painted-only effects claimed as 3D    | Document which glows, god rays and reflections are post or painted          |

## Deliverables

- [ ] Lighting brief: story point, time of day, palette swatches with hex values, value plan
- [ ] Grayscale blockout still and final still at the same camera
- [ ] Source file with lights named by role (Key, Fill, Rim, Practical_*)
- [ ] Render settings noted (engine, samples, view transform, look, exposure)
- [ ] Variant grid if variants were requested
- [ ] Notes on any painted or post effects not present in the 3D scene

[Lantern Market reference](https://skills-hub.ai/showcases/projects/lantern-market)
