Lights

Light shading mode

Two shading modes are available: plotoptix.enums.LightShading.Hard for best caustics or plotoptix.enums.LightShading.Soft for fast convergence. Use plotoptix.NpOptiX.get_param() to setup the mode. Note, it shuld be set before lights are added to the scene.

Deprecated methods to configure shading (we’ll remove them at some point):

NpOptiX.set_light_shading(mode: Union[plotoptix.enums.LightShading, str]) → None[source]

Set light shading mode.

Deprecated, use set_param(light_shading=mode) instead.

NpOptiX.get_light_shading() → Optional[plotoptix.enums.LightShading][source]

Get light shading mode.

Deprecated, use get_param("light_shading") instead.

Returns

out – Light shading mode. None is returned if function could not read the mode from the raytracer.

Return type

LightShading or None

Setup and update lighting

NpOptiX.get_light_names() → list[source]

Return list of lights’ names.

NpOptiX.setup_light(name: str, light_type: Union[plotoptix.enums.Light, str] = <Light.Spherical: 1>, pos: Optional[Any] = None, autofit_camera: Optional[str] = None, color: Any = array([10., 10., 10.], dtype=float32), u: Any = array([0., 1., 0.], dtype=float32), v: Any = array([-1., 0., 0.], dtype=float32), radius: float = 1.0, in_geometry: bool = True) → None[source]

Setup new light.

Note, the parallelogram light direction is UxV, the back side is black.

Parameters
  • name (string) – Name of the new light.

  • light_type (Light enum or string) – Light type (parallelogram, spherical, …), see plotoptix.enums.Light enum.

  • pos (array_like, optional) – 3D position.

  • autofit_camera (string, optional) – Name of the camera used to compute light position automatically.

  • color (Any, optional) – RGB color of the light; single value is gray, array_like is RGB color components. Color value range is (0; inf) as it means the light intensity.

  • u (array_like, optional) – Parallelogram U vector.

  • v (array_like, optional) – Parallelogram V vector.

  • radius (float, optional) – Sphere radius.

  • in_geometry (bool, optional) – Visible in the scene if set to True.

NpOptiX.setup_spherical_light(name: str, pos: Optional[Any] = None, autofit_camera: Optional[str] = None, color: Any = array([10., 10., 10.], dtype=float32), radius: float = 1.0, in_geometry: bool = True) → None[source]

Setup new spherical light.

Parameters
  • name (string) – Name of the new light.

  • pos (array_like, optional) – 3D position.

  • autofit_camera (string, optional) – Name of the camera used to compute light position automatically.

  • color (Any, optional) – RGB color of the light; single value is gray, array_like is RGB color components. Color value range is (0; inf) as it means the light intensity.

  • radius (float, optional) – Sphere radius.

  • in_geometry (bool, optional) – Visible in the scene if set to True.

NpOptiX.setup_parallelogram_light(name: str, pos: Optional[Any] = None, autofit_camera: Optional[str] = None, color: Any = array([10., 10., 10.], dtype=float32), u: Any = array([0., 1., 0.], dtype=float32), v: Any = array([-1., 0., 0.], dtype=float32), in_geometry: bool = True) → None[source]

Setup new parallelogram light.

Note, the light direction is UxV, the back side is black.

Parameters
  • name (string) – Name of the new light.

  • pos (array_like, optional) – 3D position.

  • autofit_camera (string, optional) – Name of the camera used to compute light position automatically.

  • color (Any, optional) – RGB color of the light; single value is gray, array_like is RGB color components. Color value range is (0; inf) as it means the light intensity.

  • u (array_like, optional) – Parallelogram U vector.

  • v (array_like, optional) – Parallelogram V vector.

  • in_geometry (bool, optional) – Visible in the scene if set to True.

NpOptiX.update_light(name: str, pos: Optional[Any] = None, color: Optional[Any] = None, radius: float = -1, u: Optional[Any] = None, v: Optional[Any] = None) → None[source]

Update light parameters.

Note, the parallelogram light direction is UxV, the back side is black.

Parameters
  • name (string, optional) – Name of the light.

  • pos (array_like, optional) – 3D position.

  • color (Any, optional) – RGB color of the light; single value is gray, array_like is RGB color components. Color value range is (0; inf) as it means the light intensity.

  • radius (float, optional) – Sphere radius.

  • u (array_like, optional) – Parallelogram U vector.

  • v (array_like, optional) – Parallelogram V vector.

NpOptiX.light_fit(light: str, camera: Optional[str] = None, horizontal_rot: float = 45, vertical_rot: float = 25, dist_scale: float = 1.5) → None[source]

Fit light position and direction to the camera.

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

  • camera (string, optional) – Name of the camera; current camera is used if not provided.

  • horizontal_rot (float, optional) – Angle: eye - target - light in the camera horizontal plane.

  • vertical_rot (float, optional) – Angle: eye - target - light in the camera vertical plane.

  • dist_scale (float, optional) – Light to target distance with reespect to the eye to target distance.

Read back light properties

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

Get light source parameters.

Parameters

name (string) – Name of the light source.

Returns

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

Return type

dict, optional

NpOptiX.get_light_color(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get light color.

Parameters

name (string, optional) – Name of the light (last added light if None).

Returns

out – Light color RGB or None if failed on accessing light data.

Return type

np.ndarray, optional

NpOptiX.get_light_pos(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get light 3D position.

Parameters

name (string, optional) – Name of the light (last added light if None).

Returns

out – 3D of the light or None if failed on accessing light data.

Return type

np.ndarray, optional

NpOptiX.get_light_r(name: Optional[str] = None) → Optional[float][source]

Get spherical light radius.

Parameters

name (string, optional) – Name of the light (last added light if None).

Returns

out – Light readius or None if failed on accessing light data.

Return type

float, optional

NpOptiX.get_light_u(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get parallelogram light U vector.

Parameters

name (string, optional) – Name of the light (last added light if None).

Returns

out – Light U vector or None if failed on accessing light data.

Return type

np.ndarray, optional

NpOptiX.get_light_v(name: Optional[str] = None) → Optional[numpy.ndarray][source]

Get parallelogram light V vector.

Parameters

name (string, optional) – Name of the light (last added light if None).

Returns

out – Light V vector or None if failed on accessing light data.

Return type

np.ndarray, optional