Material class

A base class used to represent surface material properties.

Derived classes

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.

Constructors, destructors, conversion operators

Material(const json& j = json::object())
Default constructor which accepts a json object of named parameters.
~Material() defaulted virtual
Free all memory.

Public functions

auto scatter(const Ray3f& ray, const HitInfo& hit, Color3f& attenuation, Ray3f& scattered) const -> bool virtual
Compute the scattered direction scattered at a surface hitpoint.
auto emitted(const Ray3f& ray, const HitInfo& hit) const -> Color3f virtual
Compute the amount of emitted light at the surface hitpoint.

Function documentation

bool Material::scatter(const Ray3f& ray, const HitInfo& hit, Color3f& attenuation, Ray3f& scattered) const virtual

Compute the scattered direction scattered at a surface hitpoint.

Parameters
ray in incoming ray
hit in the ray's intersection with the surface
attenuation in how much the light should be attenuated
scattered in the direction light should be scattered
Returns bool True if the surface scatters light

The base Material does not scatter any light, so it simply returns false.

Color3f Material::emitted(const Ray3f& ray, const HitInfo& hit) const virtual

Compute the amount of emitted light at the surface hitpoint.

Parameters
ray in the incoming ray
hit in the ray's intersection with the surface
Returns the emitted color

The base Material class does not emit light, so it simply returns black.