scatter

Scatter Module

The scatter module is used to model the scattering of rays based on a Bidirectional Scattering Distribution Function (BSDF). The BSDF defines the probability distribution of the scattered ray direction based on the incident ray direction and the surface normal.

Kramer Harrison, 2024

Functions

func_wrapper(func, *args)

Classes

BaseBSDF()

Abstract base class for Bidirectional Scattering Distribution Function (BSDF).

GaussianBSDF(sigma)

Gaussian Bidirectional Scattering Distribution Function (BSDF) class.

LambertianBSDF()

Lambertian Bidirectional Scattering Distribution Function (BSDF) class.

class BaseBSDF[source]

Abstract base class for Bidirectional Scattering Distribution Function (BSDF).

scattering_function

The scattering function associated with the BSDF.

scatter(rays

RealRays, nx: be.ndarray, ny: be.ndarray, nz: be.ndarray): Scatters rays according to the BSDF.

classmethod from_dict(data)[source]

Create a BSDF object from a dictionary.

scatter(rays: RealRays, nx: np.ndarray, ny: np.ndarray, nz: np.ndarray)[source]

Scatter rays according to the BSDF.

Parameters:
  • rays (RealRays) – The rays to be scattered.

  • nx (np.ndarray) – The x-component of the surface normal vector.

  • ny (np.ndarray) – The y-component of the surface normal vector.

  • nz (np.ndarray) – The z-component of the surface normal vector.

Returns:

The updated rays after scattering is applied.

Return type:

RealRays

to_dict()[source]

Convert the BSDF to a dictionary.

Returns:

A dictionary representation of the BSDF.

Return type:

dict

class GaussianBSDF(sigma)[source]

Gaussian Bidirectional Scattering Distribution Function (BSDF) class.

This class represents a Gaussian BSDF, which models scattering based on a 2D Gaussian distribution.

classmethod from_dict(data)[source]

Create a GaussianBSDF object from a dictionary.

scatter(rays: RealRays, nx: np.ndarray, ny: np.ndarray, nz: np.ndarray)

Scatter rays according to the BSDF.

Parameters:
  • rays (RealRays) – The rays to be scattered.

  • nx (np.ndarray) – The x-component of the surface normal vector.

  • ny (np.ndarray) – The y-component of the surface normal vector.

  • nz (np.ndarray) – The z-component of the surface normal vector.

Returns:

The updated rays after scattering is applied.

Return type:

RealRays

to_dict()[source]

Convert the BSDF to a dictionary.

Returns:

A dictionary representation of the BSDF.

Return type:

dict

class LambertianBSDF[source]

Lambertian Bidirectional Scattering Distribution Function (BSDF) class.

This class represents a Lambertian BSDF, which is generally used to model diffuse scattering.

classmethod from_dict(data)[source]

Create a LambertianBSDF object from a dictionary.

scatter(rays: RealRays, nx: np.ndarray, ny: np.ndarray, nz: np.ndarray)

Scatter rays according to the BSDF.

Parameters:
  • rays (RealRays) – The rays to be scattered.

  • nx (np.ndarray) – The x-component of the surface normal vector.

  • ny (np.ndarray) – The y-component of the surface normal vector.

  • nz (np.ndarray) – The z-component of the surface normal vector.

Returns:

The updated rays after scattering is applied.

Return type:

RealRays

to_dict()[source]

Convert the BSDF to a dictionary.

Returns:

A dictionary representation of the BSDF.

Return type:

dict

func_wrapper(func, *args)[source]
get_point_gaussian(sigma)

Generates a random point from a 2D Gaussian distribution using the Box-Muller transform.

Returns:

A tuple containing the x, y coordinates of the generated point.

Return type:

tuple

get_point_lambertian()

Generates a random point on the 2D unit disk.

Returns:

A tuple containing the x, y coordinates of the generated point.

Return type:

tuple

scatter(L, M, N, nx, ny, nz, get_point)

Generate a scattered vector in the global coordinate system.

Parameters:
  • L (float) – x-component of ray direction cosines.

  • M (float) – y-component of ray direction cosines.

  • N (float) – z-component of ray direction cosines.

  • nx (float) – x-component of the normal vectors.

  • ny (float) – y-component of the normal vectors.

  • nz (float) – z-component of the normal vectors.

  • get_point (function) – Function that generates a point on the unit disk.

Returns:

Scattered vector in the global coordinate system.

Return type:

s (numpy.ndarray)

scatter_parallel(L, M, N, nx, ny, nz, get_point)

Perform scatter operation in parallel.

Parameters:
  • L (numpy.ndarray) – Array of L values.

  • M (numpy.ndarray) – Array of M values.

  • N (numpy.ndarray) – Array of N values.

  • nx (numpy.ndarray) – Array of nx values.

  • ny (numpy.ndarray) – Array of ny values.

  • nz (numpy.ndarray) – Array of nz values.

  • get_point (function) – Function to get point.

Returns:

Array of scattered vectors.

Return type:

numpy.ndarray