Initial commit: Synthetic Defect Factory digital twin & automated AOI pipeline

This commit is contained in:
om_karande
2026-10-26 11:36:16 +05:30
commit 99329b476f
2089 changed files with 28059 additions and 0 deletions
+161
View File
@@ -0,0 +1,161 @@
# Blender 5.2 API Discovery & System Compatibility Notes
**Generated At:** 2026-10-22
**Blender Binary:** `C:\Program Files\Blender Foundation\Blender 5.2\blender.exe`
**Host System:** Windows (AMD64), Intel Core i5-13420H, NVIDIA GeForce RTX 3050 6GB Laptop GPU
---
## 1. Blender Version & Build Metadata
Discovered via headless command `blender --background --version` and `bpy.app`:
| Property | Value |
| :--- | :--- |
| **Version** | `5.2.2 LTS` |
| **Version Tuple** | `(5, 2, 2)` |
| **Build Date** | `2026-09-15` |
| **Build Time** | `01:37:04` |
| **Build Hash** | `d13f752e3b9c` |
| **Build Branch** | `blender-v5.2-release` |
| **Platform** | Windows (MSVC 1938 64-bit) |
| **Embedded Python** | `Python 3.11` |
---
## 2. Valid Render Engine Identifiers
Discovered via querying `bpy.context.scene.render.engine` and testing engine assignments:
| Engine Identifier | Engine Name | Status in Blender 5.2 | Notes |
| :--- | :--- | :--- | :--- |
| `CYCLES` | Cycles | **VALID** | Full raytracing engine, supports CPU, CUDA, and OptiX GPU acceleration. |
| `BLENDER_EEVEE` | EEVEE | **VALID** | Real-time viewport and rasterized render engine. In Blender 4.2+ and 5.2, the redesigned next-generation EEVEE architecture uses the identifier `BLENDER_EEVEE`. |
| `BLENDER_WORKBENCH` | Workbench | **VALID** | Real-time preview/wireframe/technical renderer. |
| `BLENDER_EEVEE_NEXT` | EEVEE Next (Legacy Name) | **INVALID** | Explicitly raises `TypeError: enum "BLENDER_EEVEE_NEXT" not found in ('BLENDER_EEVEE', 'BLENDER_WORKBENCH', 'CYCLES')`. **Do not use** `BLENDER_EEVEE_NEXT`. |
---
## 3. Cycles GPU Acceleration & Device Assessment
Discovered by inspecting `bpy.context.preferences.addons['cycles'].preferences` and executing headless 1-sample verification renders:
### Supported Compute Device Types
Blender 5.2 Cycles reports the following device types:
- `NONE` (CPU only)
- `CUDA` (NVIDIA CUDA)
- `OPTIX` (NVIDIA OptiX hardware raytracing)
- `HIP` (AMD HIP)
- `ONEAPI` (Intel oneAPI)
### Hardware Detection on this Machine
- **GPU Device:** `NVIDIA GeForce RTX 3050 6GB Laptop GPU` (`0000:01:00`)
- **CPU Device:** `13th Gen Intel Core i5-13420H` (`CPU`)
### GPU Capability & Headless Render Tests
| Backend | Device Identified | Headless Render Test (1 Sample) | Recommendation |
| :--- | :--- | :--- | :--- |
| **OptiX** (`OPTIX`) | `NVIDIA GeForce RTX 3050 6GB Laptop GPU` | **PASS (SUCCESS)** | **Recommended primary backend**. Hardware raytracing via RT Cores delivers optimal rendering throughput. |
| **CUDA** (`CUDA`) | `NVIDIA GeForce RTX 3050 6GB Laptop GPU` | **PASS (SUCCESS)** | **PASS**. Fully operational fallback backend. |
| **HIP** (`HIP`) | No AMD GPU detected | N/A (Library initialization skipped) | Not applicable for this NVIDIA GPU. |
| **oneAPI** (`ONEAPI`) | CPU fallback | N/A | Not recommended over OptiX/CUDA. |
### Cycles GPU Headless Setup Pattern
To configure Cycles for GPU rendering in Python scripts:
```python
import bpy
# Set render engine
scene = bpy.context.scene
scene.render.engine = 'CYCLES'
# Configure GPU preferences
cpref = bpy.context.preferences.addons['cycles'].preferences
cpref.compute_device_type = 'OPTIX' # or 'CUDA'
cpref.get_devices()
for device in cpref.devices:
if device.type == 'OPTIX':
device.use = True
else:
device.use = False
scene.cycles.device = 'GPU'
```
---
## 4. USD Import Operator (`bpy.ops.wm.usd_import`) Parameter Reference
Discovered via RNA property introspection (`bpy.ops.wm.usd_import.get_rna_type().properties`). Total parameters: 61 (including file dialog filters).
### 4.1 Key Scene, Scaling & Units Parameters
| Parameter | Type | Default | Description & Project Relevance |
| :--- | :--- | :--- | :--- |
| `filepath` | `STRING` | `""` | Absolute or relative path to the USD/USDA file. |
| `scale` | `FLOAT` | `1.0` | Global scaling factor applied relative to the world origin. |
| `apply_unit_conversion_scale` | `BOOLEAN` | `True` | Scales objects by the USD stage's `metersPerUnit` value. Since USDA scenes are authored with `metersPerUnit = 1.0`, keeping this `True` preserves 1:1 scale in Blender (1 unit = 1 meter). |
| `set_frame_range` | `BOOLEAN` | `True` | Updates scene frame start/end to match the USD archive. |
| `support_scene_instancing` | `BOOLEAN` | `True` | Imports USD scene graph instances as collection instances. |
| `merge_parent_xform` | `BOOLEAN` | `True` | Merges USD primitives with their Xform parent if they are the only child in the hierarchy. |
### 4.2 Materials, Textures & Shading Parameters
| Parameter | Type | Default | Options / Description |
| :--- | :--- | :--- | :--- |
| `import_materials` | `BOOLEAN` | `True` | Imports materials defined in the USD file. |
| `import_usd_preview` | `BOOLEAN` | `True` | **Crucial:** Converts `UsdPreviewSurface` shader networks directly to Blender `Principled BSDF` node networks. |
| `set_material_blend` | `BOOLEAN` | `True` | Automatically sets material blend method based on opacity and opacityThreshold. |
| `mtl_purpose` | `ENUM` | `'MTL_FULL'` | `['MTL_ALL_PURPOSE', 'MTL_PREVIEW', 'MTL_FULL']`. Preferred material purpose binding. |
| `mtl_name_collision_mode` | `ENUM` | `'MAKE_UNIQUE'` | `['MAKE_UNIQUE', 'REFERENCE_EXISTING']`. Handles duplicate material naming. |
| `import_textures_mode` | `ENUM` | `'IMPORT_PACK'` | `['IMPORT_NONE', 'IMPORT_PACK', 'IMPORT_COPY']`. Handling of embedded textures. |
| `import_textures_dir` | `STRING` | `"//textures/"` | Directory where imported textures will be copied. |
| `tex_name_collision_mode` | `ENUM` | `'USE_EXISTING'` | `['USE_EXISTING', 'OVERWRITE']`. Handling of texture filename collisions. |
| `import_all_materials` | `BOOLEAN` | `False` | When False, only imports materials referenced by geometry. |
### 4.3 Primitives, Geometry & Hierarchy Parameters
| Parameter | Type | Default | Options / Description |
| :--- | :--- | :--- | :--- |
| `import_defined_only` | `BOOLEAN` | `True` | Import only defined USD primitives (ignores override specifiers if False). |
| `import_visible_only` | `BOOLEAN` | `True` | Skips primitives flagged as invisible in USD. |
| `create_collection` | `BOOLEAN` | `False` | Adds imported objects into a new collection. |
| `validate_meshes` | `BOOLEAN` | `False` | Validates mesh geometry data integrity. |
| `property_import_mode` | `ENUM` | `'ALL'` | `['NONE', 'USER', 'ALL']`. Imports USD attributes as Blender custom properties. |
| `prim_path_mask` | `STRING` | `""` | Imports only primitives at the given path and descendants (comma/semicolon delimited). |
| `import_meshes` | `BOOLEAN` | `True` | Imports polygonal mesh geometry. |
| `import_curves` | `BOOLEAN` | `True` | Imports curve geometry. |
| `import_points` | `BOOLEAN` | `True` | Imports point cloud primitives. |
| `read_mesh_uvs` | `BOOLEAN` | `True` | Imports UV coordinates. |
| `read_mesh_colors` | `BOOLEAN` | `True` | Imports color attributes. |
| `read_mesh_attributes` | `BOOLEAN` | `True` | Reads USD Primvars as mesh attributes. |
| `import_subdivision` | `BOOLEAN` | `False` | Creates subdivision surface modifiers based on `SubdivisionScheme`. |
| `import_guide` | `BOOLEAN` | `False` | Import guide geometry. |
| `import_proxy` | `BOOLEAN` | `False` | Import proxy geometry. |
| `import_render` | `BOOLEAN` | `True` | Import final render geometry. |
### 4.4 Lights, Cameras & Dome Lighting Parameters
| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `import_lights` | `BOOLEAN` | `True` | Imports USD lights (`DiskLight`, `SphereLight`, `RectLight`, etc.). |
| `light_intensity_scale` | `FLOAT` | `1.0` | Multiplier for the intensity of imported lights. |
| `create_world_material` | `BOOLEAN` | `True` | Converts the first discovered USD `DomeLight` to a world background environment shader. |
| `import_cameras` | `BOOLEAN` | `True` | Imports USD camera primitives (`/World/Camera`). |
| `import_volumes` | `BOOLEAN` | `True` | Imports OpenVDB / USD volume grids. |
| `import_shapes` | `BOOLEAN` | `True` | Imports USD shape primitives (Cylinder, Cube, Sphere). |
---
## 5. Recommended Headless Import & Render Invocation
Based on the discovered parameters, the standard operator invocation for headless USDA import in Blender 5.2 is:
```python
bpy.ops.wm.usd_import(
filepath="usd/scenes/scene_0001.usda",
import_usd_preview=True,
import_materials=True,
import_lights=True,
import_cameras=True,
apply_unit_conversion_scale=True,
create_world_material=True,
scale=1.0
)
```