File size: 10,432 Bytes
11c70d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | # Camera Placement, Rendering, and Post-processing
This guide describes the public PhysInOne workflow for placing cameras, creating
a Level Sequence, rendering EXR passes, and converting those passes into the
dataset layout.
## 1. Prerequisites
Install Unreal Engine 5.5.4 and enable these project plugins:
- Python Editor Script Plugin
- Editor Scripting Utilities
- Movie Render Queue
The project must contain `BP_CameraTrajectory` and the Movie Render Queue
configuration assets referenced by `render/render_config.bat`.
Install post-processing dependencies in a normal Python environment:
```bash
python -m pip install -r requirements-render.txt
```
The camera scripts run inside Unreal Engine, not in the normal Python
environment. The moving-camera script imports NumPy, so NumPy must also be
available to Unreal's Python interpreter.
## 2. Configure BP_CameraTrajectory
Place `BP_CameraTrajectory` at the center of the physical event. Its rotation
must be zero and its X, Y, and Z scales must be identical. Use the smallest
uniform scale that still lets every camera capture the entire event.

| Field in the Unreal panel | Meaning |
|---|---|
| `Num` | Number of managed static cameras named `CineCamera_0`, `CineCamera_1`, and so on. Choose the count required by your release protocol; `7` in the reference panel is only an example. |
| `Time` | Sequence duration in seconds. The script calculates the authoritative frame count as `round(Time Γ FPS)`. |
| `Random Sample Direction` | Randomly chooses clockwise or counterclockwise movement. |
| `Sample Clockwise` | Used only when `Random Sample Direction` is disabled. |
| `Random Hemisphere` | Randomly chooses the upper or lower hemisphere. |
| `Upper Hemisphere` | Used only when `Random Hemisphere` is disabled. |
| `Longtitude Range` | Longitude span in degrees. The property is intentionally spelled `LongtitudeRange` in the current Blueprint/API. |
| `Longitude Angles` / `Latitude Angles` | Output arrays written by the moving-camera generator. Do not edit them manually. |
| `Points Array` | Not consumed by the supplied Python scripts. |
| `Total Frames` | Not consumed by the supplied Python scripts; `Time Γ FPS` is authoritative. |
The default frame rate is 30 FPS. Redirect and laser phenomena that require
faster motion sampling use 60 FPS.
## 3. Generate static cameras
Open the target level in Unreal Editor. In the Unreal Output Log, run:
```text
py "D:/path/to/data_processing/camera/generate_static_cameras.py" --focal 18
```
Optional arguments:
| Argument | Default | Description |
|---|---:|---|
| `--focal` | `18` | Focal length in millimeters. |
| `--aperture` | `10` | Camera aperture. |
| `--radius` | `100` | Base sphere radius in Unreal centimeters before Blueprint scale. |
| `--min-latitude` | `30` | Minimum absolute sampling latitude. |
| `--max-latitude` | `60` | Maximum absolute sampling latitude. |
| `--deterministic` | off | Removes the stable level-specific longitude offset. |
The script replaces only cameras whose labels match `CineCamera_<integer>`.
It does not delete unrelated CineCamera actors or `CineCamera_Moving`.
Inspect every generated camera in the viewport. Move or resize
`BP_CameraTrajectory` and rerun the script if an important object is occluded or
outside the frame.
## 4. Generate the moving camera and Level Sequence
After approving the static cameras, run:
```text
py "D:/path/to/data_processing/camera/generate_camera_sequence.py" --focal 18
```
Useful arguments:
| Argument | Default | Description |
|---|---:|---|
| `--focal` | `18` | Focal length in millimeters. |
| `--aperture` | `10` | Camera aperture. |
| `--radius` | `100` | Base trajectory radius in centimeters. |
| `--latitude-range` | `60` | Maximum latitude magnitude. |
| `--path-type` | `random` | One of `random`, `arc`, `sine`, or `loop`. |
| `--seed` | level-derived | Explicit seed for a different reproducible path. |
| `--output-root` | project `Rendered/Videos` | Optional camera-metadata root. |
For a canonical level such as:
```text
/Game/PhysInOne/Scenes/Val/DoublePhysics/ExampleScene.ExampleScene
```
the script creates or replaces:
```text
/Game/PhysInOne/Trajectories/Val/DoublePhysics/ExampleScene_trajectory.ExampleScene_trajectory
```
and writes metadata to:
```text
<ProjectRoot>/Rendered/Videos/Val/DoublePhysics/ExampleScene_trajectory/
```
The generator replaces the sequence at that exact path and replaces only the
actor labeled `CineCamera_Moving`. It removes old camera metadata files but
never removes RGB, depth, segmentation, or other rendered-data directories.
The camera stage is the sole owner of:
```text
transforms_train.json
transforms_val.json
transforms_test.json
```
It chooses two approximately opposite static cameras for validation, uses the
first half of their timeline for validation, uses the first half of the other
static cameras for training, and uses the second half of all static cameras for
testing. The level-derived seed makes this choice reproducible. Post-processing
preserves these files exactly.
Open the generated sequence and inspect the complete Camera Cuts track. To try
a different trajectory, rerun with a different `--seed`. Reduce
`Longtitude Range` if the camera crosses walls or other occluders. Once a path is
approved, do not move `BP_CameraTrajectory` or the static cameras without
regenerating the sequence.
## 5. Configure headless rendering on Windows
Copy the example configuration:
```bat
copy render\render_config.example.bat render\render_config.bat
```
Edit these local paths in `render_config.bat`:
```bat
set "UE_CMD=C:\Program Files\Epic Games\UE_5.5\Engine\Binaries\Win64\UnrealEditor-Cmd.exe"
set "UPROJECT=D:\PhysicBenchmark\PhysInOne.uproject"
set "DDC_LOCAL=D:\UnrealCache\Local"
set "DDC_SHARED=D:\UnrealCache\Shared"
```
Also verify all nine Movie Render Queue configuration paths: Train, Val, and
Test for SinglePhysics, DoublePhysics, and TriplePhysics. The public project
stores these `.uasset` files in:
```text
PhysicBenchmark/Content/PhysInOne/Scripts/
```
This corresponds to `/Game/PhysInOne/Scripts/` inside Unreal Engine. Do not
rename or relocate that directory: `render_config.bat` refers to these package
paths directly. The scripts alone cannot recreate the render-pass settings.
Render a list of levels:
```bat
render\render_levels_windows.bat -f examples\level_list.txt
```
Render one level:
```bat
render\render_levels_windows.bat -l "/Game/PhysInOne/Scenes/Val/DoublePhysics/ExampleScene.ExampleScene"
```
The renderer writes `render/render_batch.log` and records successful levels in
`render/complete_render_list.log`. It skips paths already in the completion
file and returns a nonzero exit code if any level fails. It does not terminate
other Unreal Editor processes.
## 6. Convert one completed render directory
Preview-safe conversion keeps the source EXRs:
```bash
python postprocess/exr_to_dataset.py \
"D:/PhysicBenchmark/Rendered/Videos/Val/DoublePhysics/ExampleScene_trajectory"
```
Delete each source EXR only after its converted file is written and verified:
```bash
python postprocess/exr_to_dataset.py \
"D:/PhysicBenchmark/Rendered/Videos/Val/DoublePhysics/ExampleScene_trajectory" \
--delete-source-exr
```
Select passes or worker count when necessary:
```bash
python postprocess/exr_to_dataset.py RENDER_DIR \
--channels rgb,depth,seg \
--workers 8 \
--jpeg-quality 95
```
By default, conversion also creates `points3d.ply`. It back-projects the first
RGB/depth frame from **every static camera** listed by
`blender_CineCamera_<index>.json`, merges the views in world coordinates, and
uniformly samples at most 100,000 colored points. `CineCamera_Moving` is not
used. The default valid-depth range is `(0, 20)` meters.
Adjust the point-cloud limits when necessary:
```bash
python postprocess/exr_to_dataset.py RENDER_DIR \
--depth-threshold 20 \
--max-points 100000 \
--ply-seed 0
```
Regenerate only the point cloud from existing JPEG/NPZ outputs:
```bash
python postprocess/point_cloud.py RENDER_DIR \
--depth-threshold 20 \
--max-points 100000
```
Use `--skip-ply` only when intentionally converting a channel subset that does
not include both RGB and depth. In `render_processor.py`, `--force-ply`
replaces an existing valid PLY; otherwise a valid existing file is preserved.
Output format:
```text
ExampleScene_trajectory/
βββ CineCamera_0/
β βββ rgb/0000.jpg
β βββ depth/0000.npz # key: depth
β βββ seg/0000.npz # key: seg
βββ CineCamera_Moving/
β βββ rgb/
β βββ depth/
β βββ seg/
βββ blender_CineCamera_0.json
βββ points3d.ply # all static views, first frame only
βββ transforms_train.json
βββ transforms_val.json
βββ transforms_test.json
```
## 7. Monitor multiple scenes
Use canonical UE level paths and let the processor infer rendered directories:
```bash
python postprocess/render_processor.py \
--level-list examples/level_list.txt \
--project-root "D:/PhysicBenchmark" \
--watch \
--interval 60 \
--delete-source-exr \
--log-dir render_processor_logs
```
Alternatively, provide a text file containing one rendered directory per line:
```bash
python postprocess/render_processor.py \
--render-list rendered_directories.txt \
--watch
```
Without `--watch`, the processor performs one scan and exits. A pending render
produces exit code `2`. Progress is flushed to disk in real time:
```text
render_processor_logs/
βββ progress.log
βββ success_scenes.tsv
βββ failed_attempts.tsv
```
The success file is resumable: a later invocation with the same log directory
skips scenes already verified as complete.
## 8. Important safety behavior
- Camera scripts only delete specifically managed camera actors.
- Regenerating a sequence replaces only the inferred scene sequence asset.
- Camera metadata cleanup never deletes rendered media directories.
- EXRs are retained unless `--delete-source-exr` is explicitly supplied.
- Post-processing never samples views or rewrites `transforms_*.json`.
- A scene is not marked complete until `points3d.ply` is valid, unless
`--skip-ply` was explicitly supplied.
- No script contains or requests a Hugging Face or GitHub access token.
|