Material

Materials define the surface properties and specify how light rays get coloured and reflected. All materials are callables - they implement the __call__ method and can be used like functions.

class padvinder.material.Material(color=(0.5, 0.5, 0.5))[source]

An emission material consists of an emitted colour only. Without gradients, lighting or anything.

Parameters:color (numpy.ndarray_like) – of three dimensions and contains colors as (Red, Green, Blue) where (0,0,0) is black and (1,1,1) is white
Raises:ValueError – if the color contains any non-finite (inf, nan) values

Examples

>>> Material((0.8, 0.8, 0.8))
Material(color=[.8 .8 .8])
color

Returns the color of the material.

__call__(surface_normal, incoming_color, incoming_direction, outgoing_direction)[source]

Calculate light reflected from the material toward the outgoing direction. Keep in mind, while pathtracing starts at the camera and heads into the scene, the rays contribution is accumulated ‘backwards’. Therefore the incoming direction is further down the path and outgoing_direction is closer towards the camera.

Parameters:
  • surface_normal (numpy.ndarray_like) – normal vector at the geometries surface
  • incoming_color (numpy.ndarray_like) – the color the ray has accumulated up to this point
  • incoming_direction (numpy.ndarray_like) – the direction from where the ‘light shines’ onto the surface
  • outgoing_direction (numpy.ndarray_like) – the direction into which the ‘light gets reflected’ from the surface
Returns:

color – the light color ‘getting reflected’ from the surface

Return type:

numpy.ndarray_like

outgoing_direction(normal, incoming_direction)[source]

Given a surface normal and an incoming direction, determine the direction in which the path continues.

normal : numpy.ndarray_like of shape (3, )
the surface normal at the intersection point
incoming_direction : numpy.ndarray_like of shape (3, )
the direction from which light hits the surface
Returns:outgoing direction – the direction in which light is reflected from the surface
Return type:numpy.ndarray_like of shape (3, 0)
class padvinder.material.Emission(color=(10, 10, 10))[source]

Emission is equivalent to the abstract base class Material. Due to semantics this class exists and merely inherits without modifications.

Parameters:color (numpy.ndarray_like) – of three dimensions and contains colors as (Red, Green, Blue) where (0,0,0) is black and (1,1,1) is white
Raises:ValueError – if the color contains any non-finite (inf, nan) values

Examples

>>> Emission()
Emission(color=[10.0, 10.0, 10.0])
__call__(surface_normal, incoming_color, incoming_direction, outgoing_direction)

Calculate light reflected from the material toward the outgoing direction. Keep in mind, while pathtracing starts at the camera and heads into the scene, the rays contribution is accumulated ‘backwards’. Therefore the incoming direction is further down the path and outgoing_direction is closer towards the camera.

Parameters:
  • surface_normal (numpy.ndarray_like) – normal vector at the geometries surface
  • incoming_color (numpy.ndarray_like) – the color the ray has accumulated up to this point
  • incoming_direction (numpy.ndarray_like) – the direction from where the ‘light shines’ onto the surface
  • outgoing_direction (numpy.ndarray_like) – the direction into which the ‘light gets reflected’ from the surface
Returns:

color – the light color ‘getting reflected’ from the surface

Return type:

numpy.ndarray_like

color

Returns the color of the material.

outgoing_direction(normal, incoming_direction)

Given a surface normal and an incoming direction, determine the direction in which the path continues.

normal : numpy.ndarray_like of shape (3, )
the surface normal at the intersection point
incoming_direction : numpy.ndarray_like of shape (3, )
the direction from which light hits the surface
Returns:outgoing direction – the direction in which light is reflected from the surface
Return type:numpy.ndarray_like of shape (3, 0)
class padvinder.material.Lambert(color=(0.5, 0.5, 0.5), diffuse=1)[source]
diffuse

Returns the diffuse value of the material.

__call__(surface_normal, incoming_color, incoming_direction, outgoing_direction)

Calculate light reflected from the material toward the outgoing direction. Keep in mind, while pathtracing starts at the camera and heads into the scene, the rays contribution is accumulated ‘backwards’. Therefore the incoming direction is further down the path and outgoing_direction is closer towards the camera.

Parameters:
  • surface_normal (numpy.ndarray_like) – normal vector at the geometries surface
  • incoming_color (numpy.ndarray_like) – the color the ray has accumulated up to this point
  • incoming_direction (numpy.ndarray_like) – the direction from where the ‘light shines’ onto the surface
  • outgoing_direction (numpy.ndarray_like) – the direction into which the ‘light gets reflected’ from the surface
Returns:

color – the light color ‘getting reflected’ from the surface

Return type:

numpy.ndarray_like

color

Returns the color of the material.