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 or update existing 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.set_normal_tilt(name: str, data: Any, mapping: Union[TextureMapping, str] = TextureMapping.Flat, addr_mode: Union[TextureAddressMode, str] = TextureAddressMode.Wrap, filter_mode: Union[TextureFilterMode, str] = TextureFilterMode.Trilinear, keep_on_host: bool = False, refresh: bool = False) None[source]

Set normal tilt data.

Set shading normal tilt according to displacement data for the material name. The data has to be a 2D array containing displacement mapping. mapping determines how the normal tilt is calculated from the displacement map (see plotoptix.enums.TextureMapping).

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) arrays are going to be saved to JSON description of the scene.

Parameters
  • name (string) – Object name.

  • data (array_like) – Displacement map data.

  • mapping (TextureMapping or string, optional) – Mapping mode (see plotoptix.enums.TextureMapping).

  • addr_mode (TextureAddressMode or string, optional) – Texture addressing mode on edge crossing.

  • filter_mode (TextureFilterMode or string, optional) – Texture interpolation mode: nearest neighbor or trilinear.

  • 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.

NpOptiX.load_normal_tilt(name: str, file_name: str, mapping: Union[TextureMapping, str] = TextureMapping.Flat, addr_mode: Union[TextureAddressMode, str] = TextureAddressMode.Wrap, filter_mode: Union[TextureFilterMode, str] = TextureFilterMode.Trilinear, prescale: float = 1.0, baseline: float = 0.0, refresh: bool = False) None[source]

Set normal tilt data.

Set shading normal tilt according to displacement map loaded from an image file. mapping determines how the normal tilt is calculated from the displacement data (see plotoptix.enums.TextureMapping). Tilt data is stored in the device memory only (there is no host copy).

Parameters
  • name (string) – Material name.

  • file_name (string) – Image file name with the displacement data.

  • mapping (TextureMapping or string, optional) – Mapping mode (see plotoptix.enums.TextureMapping).

  • addr_mode (TextureAddressMode or string, optional) – Texture addressing mode on edge crossing.

  • filter_mode (TextureFilterMode or string, optional) – Texture interpolation mode: nearest neighbor or trilinear.

  • prescale (float, optional) – Scaling factor for displacement values.

  • baseline (float, optional) – Baseline added to displacement values.

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