material#

Module for creating various materials used in 3D rendering.

VectorFieldThinLineMaterial(cross_section, *)

Material for VectorFieldActor.

VectorFieldLineMaterial(cross_section, *[, ...])

Material for VectorFieldActor.

VectorFieldArrowMaterial(cross_section, *[, ...])

Material for VectorFieldActor.

SphGlyphMaterial([n_coeffs, scale, ...])

Initialize the Spherical Glyph Material.

StreamlinesMaterial([outline_thickness, ...])

Initialize the Streamlines Material.

BillboardMaterial(**kwargs)

Billboard material for creating quads that always face the camera.

StreamtubeMaterial(**kwargs)

Material for GPU-generated streamtubes.

BillboardSphereMaterial(**material_kwargs)

Phong-lit material for billboard-based impostor spheres.

validate_opacity(opacity)

Ensure opacity is between 0 and 1.

validate_color(color, opacity, mode)

Validate and modify color based on opacity and mode.

VectorFieldThinLineMaterial#

class fury.material.VectorFieldThinLineMaterial(cross_section, *, visibility=None, **kwargs)[source]#

Bases: LineMaterial

Material for VectorFieldActor.

Parameters:
  • cross_section ({list, tuple, ndarray}) – A list or tuple or ndarray representing the cross section dimensions.

  • visibility ({list, tuple, ndarray}, optional) – A list or tuple or ndarray representing the visibility in the 3D. If None, the visibility will be set to (-1, -1, -1) to show the complete field.

  • **kwargs (dict) – Additional keyword arguments for the material.

__init__(cross_section, *, visibility=None, **kwargs)[source]#

Initialize the VectorFieldMaterial.

Parameters:
  • cross_section ({list, tuple, ndarray}) – A list or tuple or ndarray representing the cross section dimensions.

  • visibility ({list, tuple, ndarray}, optional) – A list or tuple or ndarray representing the visibility in the 3D. If None, the visibility will be set to (-1, -1, -1) to show the complete field.

  • **kwargs (dict) – Additional keyword arguments for the material.

property cross_section#

Get the cross section of the vector field.

Returns:

A list representing the cross section dimensions.

Return type:

list

uniform_type: ClassVar[dict[str, str]] = {'alpha_test': 'f4', 'clipping_planes': '0*4xf4', 'color': '4xf4', 'cross_section': '4xf4', 'dash_offset': 'f4', 'maprange': '2xf4', 'opacity': 'f4', 'thickness': 'f4', 'visibility': '4xi4'}#
property visibility#

Get the visibility of the vector field in each dimension.

Returns:

A list representing the visibility in the x, y, and z dimensions.

Return type:

list

VectorFieldLineMaterial#

class fury.material.VectorFieldLineMaterial(cross_section, *, visibility=None, **kwargs)[source]#

Bases: VectorFieldThinLineMaterial

Material for VectorFieldActor.

This class provides a way to distinguish the usage of right shader for creating a vector field.

__init__(cross_section, *, visibility=None, **kwargs)#

Initialize the VectorFieldMaterial.

Parameters:
  • cross_section ({list, tuple, ndarray}) – A list or tuple or ndarray representing the cross section dimensions.

  • visibility ({list, tuple, ndarray}, optional) – A list or tuple or ndarray representing the visibility in the 3D. If None, the visibility will be set to (-1, -1, -1) to show the complete field.

  • **kwargs (dict) – Additional keyword arguments for the material.

VectorFieldArrowMaterial#

class fury.material.VectorFieldArrowMaterial(cross_section, *, visibility=None, **kwargs)[source]#

Bases: VectorFieldThinLineMaterial

Material for VectorFieldActor.

This class provides a way to distinguish the usage of right shader for creating a vector field.

__init__(cross_section, *, visibility=None, **kwargs)#

Initialize the VectorFieldMaterial.

Parameters:
  • cross_section ({list, tuple, ndarray}) – A list or tuple or ndarray representing the cross section dimensions.

  • visibility ({list, tuple, ndarray}, optional) – A list or tuple or ndarray representing the visibility in the 3D. If None, the visibility will be set to (-1, -1, -1) to show the complete field.

  • **kwargs (dict) – Additional keyword arguments for the material.

SphGlyphMaterial#

class fury.material.SphGlyphMaterial(n_coeffs=-1, scale=1, shininess=30, emissive='#000', specular='#494949', **kwargs)[source]#

Bases: MeshPhongMaterial

Initialize the Spherical Glyph Material.

Parameters:
  • n_coeffs (int, optional) – The maximum spherical harmonic degree.

  • scale (int, optional) – The scale factor.

  • shininess (int, optional) – The shininess factor.

  • emissive (str, optional) – The emissive color.

  • specular (str, optional) – The specular color.

  • **kwargs (dict) – Additional keyword arguments for the material.

__init__(n_coeffs=-1, scale=1, shininess=30, emissive='#000', specular='#494949', **kwargs)[source]#

Initialize the Spherical Glyph Material.

Parameters:
  • n_coeffs (int, optional) – The maximum spherical harmonic degree. This value will limit the number of spherical harmonic coefficients that can be used from the data. If -1, no limit is applied.

  • scale (int, optional) – The scale factor.

  • shininess (int, optional) – The shininess factor.

  • emissive (str, optional) – The emissive color.

  • specular (str, optional) – The specular color.

  • **kwargs (dict) – Additional keyword arguments for the material.

property n_coeffs#

Get the maximum number of spherical harmonic coefficients.

Returns:

The maximum number of spherical harmonic coefficients.

Return type:

int

property scale#

Get the scale factor.

Returns:

The scale factor.

Return type:

float

uniform_type: ClassVar[dict[str, str]] = {'alpha_test': 'f4', 'ao_map_intensity': 'f4', 'clipping_planes': '0*4xf4', 'color': '4xf4', 'emissive_color': '4xf4', 'emissive_intensity': 'f4', 'light_map_intensity': 'f4', 'maprange': '2xf4', 'n_coeffs': 'i4', 'normal_scale': '2xf4', 'opacity': 'f4', 'reflectivity': 'f4', 'refraction_ratio': 'f4', 'scale': 'f4', 'shininess': 'f4', 'specular_color': '4xf4', 'wireframe': 'f4'}#

StreamlinesMaterial#

class fury.material.StreamlinesMaterial(outline_thickness=0.0, outline_color=(0, 0, 0), roi_enabled=None, roi_dim=(0, 0, 0), **kwargs)[source]#

Bases: LineMaterial

Initialize the Streamlines Material.

Parameters:
  • outline_thickness (float, optional) – The thickness of the outline.

  • outline_color (tuple, optional) – The color of the outline as an RGBA tuple.

  • roi_enabled (bool, optional) – Whether ROI culling is active. This is typically driven by the presence of an ROI mask on the actor.

  • roi_dim (tuple, optional) – 3D integer dimensions (nx, ny, nz) of a mask grid when a volumetric ROI is used in the shader.

  • **kwargs (dict) – Additional keyword arguments for the material.

__init__(outline_thickness=0.0, outline_color=(0, 0, 0), roi_enabled=None, roi_dim=(0, 0, 0), **kwargs)[source]#

Initialize the Streamline Material.

Parameters:
  • outline_thickness (float, optional) – The thickness of the outline.

  • outline_color (tuple, optional) – The color of the outline as an RGBA tuple.

  • roi_enabled (bool, optional) – Whether ROI culling is active. If None, ROI culling defaults to False until an ROI mask is attached by the actor.

  • roi_dim (tuple, optional) – 3D integer dimensions (nx, ny, nz) of a mask grid when a volumetric ROI is used in the shader.

  • **kwargs (dict) – Additional keyword arguments for the material.

property outline_color#

Get the outline color.

Returns:

The color of the outline as an RGBA tuple.

Return type:

tuple

property outline_thickness#

Get the outline thickness.

Returns:

The thickness of the outline.

Return type:

float

property roi_dim#

ROI grid dimensions as (nx, ny, nz).

Returns:

A tuple of three integers representing the ROI grid dimensions.

Return type:

tuple

property roi_enabled#

Return True when ROI-based culling is active.

Returns:

True if ROI-based culling is enabled, False otherwise.

Return type:

bool

uniform_type: ClassVar[dict[str, str]] = {'alpha_test': 'f4', 'clipping_planes': '0*4xf4', 'color': '4xf4', 'dash_offset': 'f4', 'maprange': '2xf4', 'opacity': 'f4', 'outline_color': '4xf4', 'outline_thickness': 'f4', 'roi_dim': '4xi4', 'roi_enabled': 'i4', 'thickness': 'f4'}#

BillboardMaterial#

class fury.material.BillboardMaterial(**kwargs)[source]#

Bases: MeshBasicMaterial

Billboard material for creating quads that always face the camera.

This material is designed to work with the BillboardShader to create rectangles that automatically rotate to face the camera while maintaining their 3D position.

Parameters:

**kwargs (dict) – Additional keyword arguments forwarded to MeshBasicMaterial.

__init__(**kwargs)[source]#

Initialize the material and forward arguments to the base class.

Parameters:

**kwargs (dict) – Additional keyword arguments forwarded to MeshBasicMaterial.

StreamtubeMaterial#

class fury.material.StreamtubeMaterial(**kwargs)[source]#

Bases: MeshPhongMaterial

Material for GPU-generated streamtubes.

Parameters:

**kwargs (dict, optional) – Arguments forwarded to MeshPhongMaterial.

__init__(**kwargs)[source]#

Initialise the material with MeshPhongMaterial keyword arguments.

Parameters:

**kwargs (dict, optional) – Arguments forwarded to MeshPhongMaterial.

BillboardSphereMaterial#

class fury.material.BillboardSphereMaterial(**material_kwargs)[source]#

Bases: MeshPhongMaterial

Phong-lit material for billboard-based impostor spheres.

Parameters:

**material_kwargs (dict) – Keyword arguments propagated to MeshPhongMaterial.

__init__(**material_kwargs)[source]#

Initialize the sphere impostor material.

Parameters:

**material_kwargs (dict) – Keyword arguments propagated to MeshPhongMaterial.

validate_opacity#

fury.material.validate_opacity(opacity)[source]#

Ensure opacity is between 0 and 1.

Parameters:

opacity (float) – Opacity value to validate.

Returns:

Validated opacity value.

Return type:

float

Raises:

ValueError – If opacity is not between 0 and 1.

validate_color#

fury.material.validate_color(color, opacity, mode)[source]#

Validate and modify color based on opacity and mode.

Parameters:
  • color (tuple or None) – RGB or RGBA color tuple.

  • opacity (float) – Opacity value between 0 and 1.

  • mode (str) – Color mode, either ‘auto’ or ‘vertex’.

Returns:

Modified color tuple with opacity applied.

Return type:

tuple or None

Raises:

ValueError – If color is None when mode is ‘auto’ or if color has invalid length.