Blender addon - #34
Open
SakuraEntropia wants to merge 25 commits into
Open
Conversation
- blender_addon/: Blender render-engine integration that exports scenes to MoonRay RDLA, renders with the moonray CLI, loads the result into the Render Result, and optionally denoises with OIDN. - Full Blender shader-node graph compilation: Principled/Diffuse/Glossy/ Glass/Transparent/Emission, Mix/Add Shader, image textures, normal maps, and static baking of color/scalar node subgraphs. - RDLA intermediate scene is optional (Save RDLA Scene setting). - Direct Render Image button in the MoonRay render panel. - COMPATIBILITY.md: fixes required to build MoonRay on macOS 27 / Apple Silicon / AppleClang 21 (generator mismatch, Qt skip, memory-bounded parallelism, Xcode-generator avoidance, git clone hardening, Blender 5.2 RenderEngine API workarounds). - patches/: the openmoonray superbuild/preset changes used for the build. - Helper scripts: build_moonray.sh, verify_moonray.sh, finish_build_and_test.sh, install_addon.sh.
- ShaderNodeTexNoise now exports as MoonRay NoiseMap_v2 (color mode) with scale/detail/distortion/seed mapped from the Blender node. - Value model extended with generic map references so more procedural nodes can be added the same way. - test_materials.py: noise-driven material coverage (9 checks).
- World Environment Texture nodes now export as EnvLight with a texture (HDRI lighting), alongside the constant-color fallback. - test_full_scene.py: env_texture check (16 checks total). - README: full feature matrix, usage, and test instructions.
|
- Camera shutter attributes (mb_shutter_open/close, one Blender frame). - Per-vertex velocity export from Blender's 'velocity' attribute when available (Blender 4.x); Blender 5.x no longer generates it, so object motion blur is skipped there. Frame-sampling was removed after it proved to crash Blender 5.2 alpha (render depsgraph invalidation). - test_motion_blur.py coverage.
- ShaderNodeMapping (location/scale, approximate rotation) now exports as ImageMap/ImageNormalMap offset/scale/rotation attributes, with the V-flip mirror applied to the Y components. - Camera shift_x/shift_y export as MoonRay film offsets. - test_materials.py: mapping checks (11 total).
- Materials with Backface Culling export geometry side_type=single-sided. - World Mapping-node rotation orients the EnvLight via node_xform. - test_full_scene.py: side_type + env rotation checks (18 total).
- Wire the auto_detect preference: the engine now searches candidate install roots (workspace default, /Applications/MoonRay, ~/moonray, $MOONRAY_ROOT) when the configured path has no moonray binary. - resolve_moonray_root also honors the MOONRAY_ROOT environment variable. - Remove dead code (unused constants/imports).
CMake derives search prefixes from PATH entries; Anaconda's bin on PATH made OpenColorIO link Anaconda yaml-cpp 0.8 headers against its own yaml-cpp 0.6.3 (via the expat imported target) - undefined symbols. Fixed by scrubbing anaconda/conda env vars for the dependency build.
- Remove the bare __init__(*args) on the RenderEngine: it swallowed Blender's struct-creation call, leaving every engine method (report/ update_stats/begin_result/...) raising ReferenceError and the render silently black. Helper logic now lives in module-level functions. - Pass -out to the moonray CLI so the output path is explicit (mock renderer test relies on the same contract); mock now reads image_width/ image_height from the RDLA. - Rename MoonRay beauty channels R/G/B/A to Combined.* via oiiotool so RenderLayer.load_from_file() maps them into the render result (was producing black with "expected channel Combined.R not found"). - Fix RDLA object emission: use Lua variable assignments for geometry, lights, materials and GeometrySet blocks; keep GeometrySet registration per mesh/instancer while the Layer references the raw geometry. - Add ispc-ninja and codesign CMake patches; enable DEPS_ROOT/TBB_ROOT/ MOONRAY_USE_METAL=OFF in the macos-release-ninja preset. - E2E render test now aims the camera at the origin and asserts non-black output (mean > 0.01).
_default_moonray_root() used os.path.abspath(__file__), which keeps the symlink path (~/Library/.../addons/moonray_blender) and misses the real workspace, falling back to /Applications/MoonRay/... and making Blender report 'MoonRay not found'. Use os.path.realpath() so the install root is found even when the add-on is symlinked into Blender's add-ons directory.
MoonRay only prints 'Rendering [ N%]' progress when -info is passed; without it the status bar stayed stuck on 'writing scene' for the whole render (which takes ~30s even for a small scene) and update_progress never advanced. Also set the status to Rendering immediately after launch.
Blender auto-names duplicates as 'Sphere.001'; sanitize_name kept the '.', so the RDLA emitted 'mesh_Sphere.001_6 = RdlMeshGeometry(...)' and Lua parsed 'mesh_Sphere.001' as table index + malformed number, aborting with 'RDLA Error: malformed number near .001_'. Keep only alphanumerics and underscore in exported names.
The user's saved prefs had installs_root empty, so _to_combined_channels
skipped the R/G/B/A -> Combined.* channel rename and
RenderLayer.load_from_file() silently produced an empty render result
('expected channel Combined.R not found'), leaving the viewer blank even
though moonray wrote a valid EXR. Derive <installs> from the MoonRay root
(<installs>/openmoonray) and also search for oiiotool next to the MoonRay
install so the channel rename always runs.
- Exporter: when "Progressive Preview" is on, emit SceneVariables checkpoint settings (checkpoint_active/mode/quality_steps/overwrite) and a RenderOutput carrying the checkpoint file name (MoonRay only writes checkpoints when at least one RenderOutput exists). - Engine: pass -checkpoint, poll the checkpoint EXR while moonray runs, and push each new snapshot into the render result with update_result so the image refines live instead of appearing only at the end. Checkpoint images are 3-channel, so a constant Combined.A is appended. - Add MoonRayRenderSettings.use_progressive (default on). - Fix stale test_materials assertion for the DwaMixMaterial variable ref.
Materials: - Principled BSDF now maps all inputs to DwaBaseMaterial: IOR (refractive_index), Diffuse Roughness, Anisotropic + Rotation (anisotropy/shading_tangent), Coat Weight/Roughness/IOR/Tint (clearcoat lobes), Sheen Weight/Roughness/Tint (fuzz lobes), Subsurface Weight/Radius/Scale (bssrdf/scattering_color/scattering_radius), Thin Wall (thin_geometry), and transmission tint via Base Color. - Emission Strength is now multiplied into the emission color (previously ignored). - Added BSDF_ANISOTROPIC, BSDF_REFRACTION, BSDF_TRANSLUCENT, BSDF_VELVET, BSDF_TOON and SUBSURFACE_SCATTERING; Blender >= 5.x reports the Anisotropic node as BSDF_GLOSSY, so Glossy now also reads its Anisotropy/Rotation sockets. Lights: - AREA DISK/ELLIPSE shape -> DiskLight (with radius and area-normalized intensity), SQUARE/RECTANGLE -> RectLight. - Area spread -> RectLight/DiskLight "spread". - Honored use_temperature via light.temperature_color. Tests: - New test_cycles_parity.py (22 checks) covering lights and full Principled BSDF + extra BSDF node mappings. - Fix test_export.py FakeSettings mis-indented use_motion_blur attribute.
The user's MoonRay.blend Cornell box rendered black because it uses an emissive mesh (the Cycles way to make an area light) whose emission went through a Blackbody node the compiler did not understand. - Add ShaderNodeBlackbody support (Planckian-locus approximation). - Emissive meshes now become a MeshLight (a real directional area light that casts shadows) instead of a bare emissive material that floods the scene uniformly. Geometry referenced by a MeshLight is excluded from the Layer (MoonRay forbids layering it); intensity uses the Lambertian strength/pi conversion from Cycles emission strength to radiance. - Fix geometry_xform: it was A@M@A^-1 with untouched local vertex data, which left meshes in Blender's Z-up orientation inside MoonRay's Y-up world (rotation-invariant test shapes masked this). Now A@M, so vertex and normal data stay in local space and node_xform maps them correctly. - No EnvLight is emitted when the scene world is None, matching Cycles. - Reorder RDLA emission: geometry -> light set -> layer, so MeshLight and Layer can reference already-declared objects. Tests updated for MeshLight-based emission and the no-world EnvLight rule.
- New tests/compare_cycles.py defines a multi-term loss (MSE, MAE, luminance MSE, chroma angular error, per-channel MAE) between a Cycles reference EXR and a MoonRay render, so renderer differences are measured instead of eyeballed. - Export meshes split by material slot: multi-material objects (e.g. a Cornell box with separate red/green/white walls) now emit one geometry + material per slot and one Layer entry each, instead of collapsing everything to obj.active_material. Verified the sun-lit geometry path now matches Cycles with near-zero loss.
fmt_mat4 wrote Blender's matrix unchanged, leaving the translation in the last COLUMN while MoonRay's row-vector Mat4 expects it in the last ROW. Every node_xform (geometry, camera, lights) was therefore mis-read: the scene rendered black or scrambled (the user saw "a black square in the corner, not a Cornell box"). Transpose on output. Also: DistantLight applies an internal 180-degree X rotation, so the Sun must not get the local-Z flip that area/spot lights need; and emissive MeshLight intensity now uses strength directly. Result on the Cornell box: chroma error 24.9deg -> 2.3deg (colors/geometry align with Cycles).
- Root README now describes the MoonRay fork + Blender add-on (feature highlights, install, build-compat pointer) instead of the upstream text. - blender_addon README: bump feature table (full Principled BSDF, more Cycles BSDFs, Blackbody, emissive MeshLights, multi-material split, progressive preview) and test counts. - Bump add-on version to 0.2.0 and ship moonray_blender-v0.2.0.zip.
Step-by-step guide: checkout, apply macOS patches, dependency superbuild, main build, verify, shell env, and Blender add-on install.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compatibility:
Issues/Tickets:
Release notes comment:
Comments for the reviewer:
Look or scene setup change:
Special notes for production:
Attention/Reviewers:
AI Assisted Development:
Checklist: