raytracer
Parallel Ray Tracer written from scratch (no graphics API).
Loading...
Searching...
No Matches
raytracer::raytracer::Material Class Referenceabstract

#include <material.h>

Inheritance diagram for raytracer::raytracer::Material:

Public Member Functions

virtual ~Material ()=default
virtual Ray get_scattered (const Ray &ray_in, const common::Vec3 &intersection, const common::Vec3 &normal) const =0
virtual common::Vec3 get_color (const Ray &ray_in, const common::Vec3 &intersection, const common::Vec3 &normal) const =0
virtual MaterialType get_type () const =0

Static Public Member Functions

static common::Vec3 reflect (const common::Vec3 &dir_in, const common::Vec3 &normal)
static common::Vec3 refract (const common::Vec3 &dir_in, const common::Vec3 &normal, double refractive_index)

Detailed Description

The surface of an object, which determines how rays bounce off of it and which color they pick up.

Constructor & Destructor Documentation

◆ ~Material()

virtual raytracer::raytracer::Material::~Material ( )
virtualdefault

Member Function Documentation

◆ get_color()

virtual common::Vec3 raytracer::raytracer::Material::get_color ( const Ray & ray_in,
const common::Vec3 & intersection,
const common::Vec3 & normal ) const
nodiscardpure virtual

Computes the color the surface contributes to a ray that hits it, which is multiplied with the color of the scattered ray.

Parameters
ray_inThe incoming ray.
intersectionThe point where the incoming ray hits the surface.
normalThe normal to the surface at the intersection point.
Returns
The color of the surface at the intersection point.

Implemented in raytracer::raytracer::Dielectric, raytracer::raytracer::Lambertian, raytracer::raytracer::LambertianTexture, and raytracer::raytracer::Metal.

◆ get_scattered()

virtual Ray raytracer::raytracer::Material::get_scattered ( const Ray & ray_in,
const common::Vec3 & intersection,
const common::Vec3 & normal ) const
nodiscardpure virtual

Computes the ray that leaves the surface after an incoming ray hits it.

Parameters
ray_inThe incoming ray.
intersectionThe point where the incoming ray hits the surface.
normalThe normal to the surface at the intersection point.
Returns
The scattered ray, starting at the intersection point.

Implemented in raytracer::raytracer::Dielectric, raytracer::raytracer::Lambertian, and raytracer::raytracer::Metal.

◆ get_type()

virtual MaterialType raytracer::raytracer::Material::get_type ( ) const
nodiscardpure virtual

Returns the type of the material, used to identify the concrete class.

Returns
The type of the material.

Implemented in raytracer::raytracer::Dielectric, raytracer::raytracer::Lambertian, raytracer::raytracer::LambertianTexture, and raytracer::raytracer::Metal.

◆ reflect()

common::Vec3 raytracer::raytracer::Material::reflect ( const common::Vec3 & dir_in,
const common::Vec3 & normal )
static

Reflects a direction vector about a surface normal, like a mirror.

Parameters
dir_inThe direction of the incoming ray.
normalThe normal to the surface at the point of reflection.
Returns
The normalized direction of the reflected ray.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refract()

common::Vec3 raytracer::raytracer::Material::refract ( const common::Vec3 & dir_in,
const common::Vec3 & normal,
double refractive_index )
static

Refracts a direction vector through a surface, according to Snell's law.

Parameters
dir_inThe direction of the incoming ray.
normalThe normal to the surface at the point of refraction.
refractive_indexThe ratio between the refractive index of the medium the ray leaves and that of the medium it enters.
Returns
The normalized direction of the refracted ray.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: