Canonical URL: https://sunfield.dev/blog/specular-metal-robotics-synthetic-data
Published: 2026-12-01 | Category: Robotics & CV | Reading time: 6 min
Hero Render: https://sunfield.dev/blog/robotics-metal-og.jpg

# Synthetic perception data for specular metal: catching bad poses before Cycles

Bottom-line: in a 10-sample bin-picking loop mixing two external glTF assets (`WaterBottle.glb`, `DamagedHelmet.glb`) with milled CNC aluminium parts, pre-render geometric checks rejected **4 of 4 broken poses** in `307 to 406 ms` before Cycles started. Clean `768x512 @ 64 spp` multi-AOV frames averaged **`1.06 GPU-s`** steady-state, ie, **`$0.42 per 1,000 frames`** (`3,398 frames/hr` on one RTX 3090).

## Why rasterisers struggle on machined metal

Real factory bins are full of brushed 6061 brackets, stainless collars, and chamfered steel flanges. Real-time rasterisers fake metallic reflections with screen-space approximations and baked cubemaps. If you fine-tune `SAM 2` or `FoundationPose` on those frames, the model learns the artefacts of the rasteriser instead of real grazing highlights and inter-object bounces inside a steel tray.

Cycles path-tracing gets those bounces right. The catch with naive domain randomisation is waste: if 30% to 40% of your random drops interpenetrate, float, or clip the camera edge, you either burn GPU budget rendering garbage or poison the training split with physically impossible ground truth.

## Putting a 300 ms gate in front of Cycles

We tested the gate on 10 randomised layouts across four industrial CC0 HDRIs, injecting two overlapping drops and one floating collar alongside normal placements.

| Sample | Condition | Gate time (server) | Cycles spent | Outcome |
| :--- | :--- | ---: | ---: | :--- |
| `sample_02` | Injected overlap (`0.075 m` penetration, `730` tri pairs) | `356.7 ms` | `0.00 GPU-s` | Rejected pre-Cycles |
| `sample_05` | Injected overlap (`0.124 m` penetration, `752` tri pairs) | `328.6 ms` | `0.00 GPU-s` | Rejected pre-Cycles |
| `sample_08` | Injected floating aluminium collar | `406.6 ms` | `0.00 GPU-s` | Rejected pre-Cycles |
| `sample_09` | Unintentional camera frustum edge clip | `307.5 ms` | `0.00 GPU-s` | Rejected pre-Cycles |
| `6` clean samples | Grounded, collision-free layouts | `206 to 337 ms` | `1.06 GPU-s/frame` | Rendered RGB, depth, normals, COCO |

We did not inject `sample_09` – the random camera pose clipped a part at the frame edge, and the gate caught it in `307.5 ms`. Across the run, warm single-pass spatial checks averaged `304 ms` and kept Cycles spend at `0.00 GPU-s` on all four defective scenes.

## Throughput numbers (`768x512 @ 64 spp`, `$0.00040/GPU-s`)

Batching frames inside one job is `3.2x` cheaper than firing one API call per frame:

- Batched multi-frame runs averaged `1.059 GPU-s/frame` steady-state → `3,398 frames/hr` on 1 GPU, `~27k frames/hr` on 8 GPUs (linear scaling), and **`$0.42 per 1,000 frames`**.
- Unbatched 1-frame calls averaged `3.472 GPU-s/frame` (each call repeats BVH setup and pre-flight cost probing) → `1,037 frames/hr` on 1 GPU, **`$1.39 per 1,000 frames`**.
- The entire 10-sample run plus the `1200x630` hero frame above cost **`$0.014`**.

In other words, batching 20 to 200 frames per render job cuts your cost by roughly `3.2x` with zero change to the image.

## Exact 2D COCO boxes from evaluated meshes

Projecting evaluated world-space vertices through `bpy_extras.object_utils.world_to_camera_view` agreed with unoccluded segmentation silhouettes to within `< 0.7 px`. Watch out: always set `scene.render.resolution_x` and `resolution_y` to your target aspect ratio before projecting boxes or computing camera intrinsics `K`, otherwise the sensor-fit calculation shifts silently.

```python
import bpy
from bpy_extras.object_utils import world_to_camera_view

def coco_bbox_for_object(scene, cam_obj, obj, width, height):
    depsgraph = bpy.context.evaluated_depsgraph_get()
    eval_obj = obj.evaluated_get(depsgraph)
    mesh = eval_obj.to_mesh()
    try:
        xs, ys = [], []
        for v in mesh.vertices:
            co_ndc = world_to_camera_view(scene, cam_obj, eval_obj.matrix_world @ v.co)
            if co_ndc.z > 0:
                xs.append(min(max(co_ndc.x * width, 0.0), float(width)))
                ys.append(min(max((1.0 - co_ndc.y) * height, 0.0), float(height)))
        if not xs:
            return None
        x0, x1 = min(xs), max(xs)
        y0, y1 = min(ys), max(ys)
        return [round(x0, 2), round(y0, 2), round(x1 - x0, 2), round(y1 - y0, 2)]
    finally:
        eval_obj.to_mesh_clear()
```

## What does not work out of the box yet

**8-bit PNG depth, not float32 EXR.** Sunfield's built-in `depth` pass currently writes an 8-bit normalised PNG rather than a metric float32 OpenEXR in metres. If you use the PNG pass, keep a worktable or enclosure behind the bin so background sky pixels do not hit `1e10` and crush foreground dynamic range. If you are training a metric `FoundationPose` model, write float32 EXR directly from your `bpy` script until we add native EXR pass export.

**No `K` or `cam_to_world` in `inspect()` yet.** Default `inspect()` telemetry does not return camera intrinsics or extrinsics today – extract them in `exec()` alongside your COCO labels.

NB, Cycles is a perception data generator, not a 60 Hz physics engine. If your task needs closed-loop physics control (think RL locomotion or contact-rich manipulation), use Isaac Sim or MuJoCo instead.
---

Sign in or connect Remote MCP (`https://sunfield.dev/mcp`) at https://sunfield.dev/login. All posts: https://sunfield.dev/blog
