# Materials module

BSDFs and phase functions attached to Surfaces to define how they interact with light.

## Classes

- class Material
- A base class used to represent surface material properties.
- class Dielectric
- A smooth dielectric surface that reflects and refracts light according to the specified index of refraction ior.
- class DiffuseLight
- A material that emits light equally in all directions from the front side of a surface.
- class Lambertian
- A perfectly diffuse (Lambertian) material.
- class Metal
- A metallic material that reflects light into the (potentially rough) mirror reflection direction.

## Functions

- auto fresnel_dielectric(float cos_theta_i, float ext_ior, float int_ior) -> float
- Calculates the unpolarized fresnel reflection coefficient for a dielectric material.
- auto refract(const Vec3f& v, const Vec3f& n, float eta, Vec3f& refracted) -> bool
- Generates a refracted direction, assuming refraction is possible based on the incident direction and refractive indices.
- auto reflect(const Vec3f& v, const Vec3f& n) -> Vec3f
- Reflects a vector,
`v`

, over another vector,`n`

.

## Function documentation

###
float fresnel_dielectric(float cos_theta_i,
float ext_ior,
float int_ior)
#include <darts/material.h>

Calculates the unpolarized fresnel reflection coefficient for a dielectric material.

Parameters | |
---|---|

cos_theta_i in | Cosine of the angle between the normal and the incident ray |

ext_ior in | Refractive index of the side that contains the surface normal |

int_ior in | Refractive index of the interior |

Returns | The Fresnel reflection coefficient. |

Handles incidence from either side (i.e. `cos_theta_i<0`

is allowed).

###
bool refract(const Vec3f& v,
const Vec3f& n,
float eta,
Vec3f& refracted)
#include <darts/material.h>

Generates a refracted direction, assuming refraction is possible based on the incident direction and refractive indices.

Parameters | |
---|---|

v in | The incident ray's direction (points at surface) |

n in | The surface normal of the incident ray |

eta in | The ratio of the index of refraction on the incident side to the index of refraction on the transmitted side |

refracted out | The returned, un-normalized, refracted direction |

Returns | True if refraction is possible, False if there is total internal reflection |

###
Vec3f reflect(const Vec3f& v,
const Vec3f& n)
#include <darts/material.h>

Reflects a vector, `v`

, over another vector, `n`

.

Parameters | |
---|---|

v in | The incident ray's direction (points at surface) |

n in | The surface normal at the hit point |

Returns | Vec3f The reflected vector |