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[LightShading, str]) None[source]

Set light shading mode.

Deprecated, use set_param(light_shading=mode) instead.

NpOptiX.get_light_shading() Optional[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[Light, str] = Light.Spherical, pos: Optional[Any] = None, autofit_camera: Optional[str] = None, color: Optional[Any] = None, u: Optional[Any] = None, v: Optional[Any] = None, radius: float = -1, in_geometry: bool = True) None[source]

Setup a new light or update an existing light.

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

Updating an existing light with this method will not change the type of light, nor its visibility. Only pos, color, radius, u, and v values can be updated.

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: Optional[Any] = None, radius: float = -1, in_geometry: bool = True) None[source]

Setup new or update existing spherical light.

Updating an existing light with this method will not change its visibility. Only pos, color, and radius values can be updated.

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: Optional[Any] = None, u: Optional[Any] = None, v: Optional[Any] = None, in_geometry: bool = True) None[source]

Setup new or update existing parallelogram light.

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

Properties that can be updated: pos, color, u, v.

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.setup_area_light(name: str, center: Optional[Any] = None, target: Optional[Any] = None, u: Optional[float] = None, v: Optional[float] = None, color: Optional[Any] = None, in_geometry: bool = True) None[source]

Setup new or update existing area (parallelogram) light.

Convenience method to setup parallelogram light with center and target 3D points, and scalar lengths of sides u and v.

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

  • center (array_like) – 3D position of the light center.

  • target (array_like) – 3D position of the light target.

  • u (float) – Horizontal side length.

  • v (float) – Vertical side length.

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

  • 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) – 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.update_area_light(name: str, center: Optional[Any] = None, target: Optional[Any] = None, u: Optional[float] = None, v: Optional[float] = None, color: Optional[Any] = None) None[source]

Update area (parallelogram) light.

Convenience method to update parallelogram light with center and target 3D points, and scalar lengths of sides u and v.

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

  • center (array_like, optional) – 3D position of the light center.

  • target (array_like, optional) – 3D position of the light target.

  • u (float, optional) – Horizontal side length.

  • v (float, optional) – Vertical side length.

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

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[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[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[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[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