Skip to content

feat(rm): allow registering custom radio mat. prior to loading scenes - #71

Open
jeertmans wants to merge 1 commit into
NVlabs:mainfrom
jeertmans:add-register-radio-material
Open

feat(rm): allow registering custom radio mat. prior to loading scenes#71
jeertmans wants to merge 1 commit into
NVlabs:mainfrom
jeertmans:add-register-radio-material

Conversation

@jeertmans

Copy link
Copy Markdown
Contributor

Hi!

While this PR is linked to #70, it does not depend on #70 and should not cause any conflicts.

Currently, loading a scene file containing unknown radio material names or unlisted ITU radio materials raises an error. This presents a challenge in two common scenarios:

  1. Users want to specify new radio material names inside Blender and define their electromagnetic properties in Python code.
  2. The list of ITU materials evolves (e.g., recommendation updates as in feat(radio-materials): update ITU materials to version 4 #70), but Sionna RT's internal list is not yet updated, requiring manual patching of internal dictionaries.

Currently, custom radio materials can only be assigned after loading the scene, which I believe can be error-prone and time-consuming for large scenes.

This PR introduces two helper functions, register_itu_radio_material and register_radio_material, to make registering custom radio materials idiomatic before calling load_scene.

Summary of changes:

  • register_itu_radio_material: Adds register_itu_radio_material(name, parameters, color=None) to allow registering custom ITU materials or updating existing parameters and visual colors in ITU_MATERIALS_PROPERTIES and ITU_MATERIAL_COLORS. If color is omitted or set to None, a random color is generated upon material instantiation, matching RadioMaterial. This changes the previous behavior, which required a color even though it could eventually be overridden.
  • register_radio_material: Adds register_radio_material(rm) and radio_material_registry to register RadioMaterialBase instances prior to scene loading.
  • Scene Preprocessing & Attribute Overrides: Updated process_xml and Scene._load_scene_objects to handle both explicit XML plugin syntax (<bsdf type="itu-radio-material"...> and <bsdf type="radio-material"...>) as well as legacy/Blender syntax (id="itu_..." or id="mat-itu_..."). Any attribute specified in the XML file (such as thickness and color) correctly overrides default or pre-registered material attributes.
  • Multiple Material Customizations: Supports declaring multiple BSDF nodes with distinct IDs (e.g. my_custom_thick_wood and my_custom_thin_wood) referencing the same underlying ITU material type while specifying different property overrides (e.g. thickness).
  • Documentation: Added API documentation for both functions in doc/source/api/radio_materials.rst and comprehensive developer guide examples in doc/source/developer/dev_custom_radio_materials.rst demonstrating explicit XML syntax, material reuse, and attribute overrides.
  • Unit Tests: Added test08_register_itu_radio_material and test09_register_radio_material in test_scene_utils.py covering prefix error validation, explicit vs legacy XML syntax, optional color generation, multiple material IDs referencing the same ITU type, and XML thickness/color overrides.

Let me know if you'd like any adjustments! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant