Materials

Methods to setup and read back material properties. See also Predefined materials section.

NpOptiX.setup_material(name: str, data: dict) → None[source]

Setup new material.

Note: for maximum performance, setup only those materials you need in the scene.

Parameters
  • name (string) – Name of the material.

  • data (dict) – Parameters of the material.

NpOptiX.get_material(name: str) → Optional[dict][source]

Get material parameters.

Parameters

name (string) – Name of the material.

Returns

out – Dictionary of the material parameters or None if failed on accessing material data.

Return type

dict, optional

NpOptiX.update_material(name: str, data: dict, refresh: bool = False) → None[source]

Update material properties.

Update material properties and optionally refresh the scene.

Parameters
  • name (string) – Name of the material.

  • data (dict) – Parameters of the material.

  • refresh (bool, optional) – Set to True if the image should be re-computed.

NpOptiX.update_material_texture(name: str, data: Any, idx: int = 0, keep_on_host: bool = False, refresh: bool = False) → None[source]

Update material texture data.

Update texture content/size for material name data. Texture format has to be RGBA, width/height are deduced from the data array shape. Use keep_on_host=True to make a copy of data in the host memory (in addition to GPU memory), this option is required when (small) textures are going to be saved to JSON description of the scene.

Parameters
  • name (string) – Material name.

  • data (array_like) – Texture data.

  • idx (int, optional) – Texture index, the first texture if the default is left.

  • keep_on_host (bool, optional) – Store texture data copy in the host memory.

  • refresh (bool, optional) – Set to True if the image should be re-computed.