Material class
#include <darts/material.h>
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 Diffuse
- A perfectly diffuse material.
- class Emission
- A material that emits light equally in all directions from the front side of a surface.
- class Metal
- A metallic material that reflects light into the (potentially rough) mirror reflection direction.
Constructors, destructors, conversion operators
Public functions
- auto scatter(const Ray3f& ray, const HitRecord& hit, Color3f& attenuation, Ray3f& scattered) const -> bool virtual
- Compute the scattered direction scattered at a surface hitpoint.
- auto emitted(const Ray3f& ray, const HitRecord& hit) const -> Color3f virtual
- Compute the amount of emitted light at the surface hitpoint.
- auto sample(const Ray3f& ray, const HitRecord& hit, ScatterRecord& srec, const Vec2f& rv, float rv1) const -> bool virtual
- Sample a scattered direction at the surface hitpoint
hit
. - auto eval(const Ray3f& ray, const Vec3f& scattered, const HitRecord& hit) const -> Color3f virtual
- Evaluate the material response for the given pair of directions.
- auto pdf(const Ray3f& ray, const Vec3f& scattered, const HitRecord& hit) const -> float virtual
- Compute the probability density that sample() will generate
scattered
(givenwi
).
Function documentation
bool Material:: scatter(const Ray3f& ray,
const HitRecord& 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 HitRecord& 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.
bool Material:: sample(const Ray3f& ray,
const HitRecord& hit,
ScatterRecord& srec,
const Vec2f& rv,
float rv1) const virtual
Sample a scattered direction at the surface hitpoint hit
.
Parameters | |
---|---|
ray in | The incoming ray (points at surface) |
hit in | The incoming ray's intersection with the surface |
srec out | Populate srec.wo , srec.is_specular , and srec.attenuation |
rv in | A 2D random variables in to use when generating the sample |
rv1 in | A 1D random variable in to use when generating the sample |
Returns | bool True if the surface scatters light |
If it is not possible to evaluate the pdf of the material (e.g. it is specular or unknown), then set srec.is_specular
to true, and populate srec.wo
and srec.attenuation
just like we did previously in the scatter() function. This allows you to fall back to the way we did things with the scatter() function, i.e. bypassing pdf() evaluations needed for explicit Monte Carlo integration in your #Integrator, but this also precludes the use of MIS or mixture sampling since the pdf is unknown.
Color3f Material:: eval(const Ray3f& ray,
const Vec3f& scattered,
const HitRecord& hit) const virtual
Evaluate the material response for the given pair of directions.
Parameters | |
---|---|
ray in | The incoming ray (points at surface) |
scattered in | The outgoing ray direction (points out of surface) |
hit in | The shading hit point |
Returns | Color3f The evaluated color |
For non-specular materials, this should be the BSDF multiplied by the cosine foreshortening term.
Specular contributions should be excluded.
float Material:: pdf(const Ray3f& ray,
const Vec3f& scattered,
const HitRecord& hit) const virtual
Compute the probability density that sample() will generate scattered
(given wi
).
Parameters | |
---|---|
ray in | The incoming ray |
scattered in | The outgoing ray direction |
hit in | The shading hit point |
Returns | float A probability density value in solid angle measure around hit.p . |