Skip to content

Use Schlick's formula for metal reflections  #844

@Naturseptime

Description

@Naturseptime

Inside the metal class, the color of the reflected ray is attenuated by the constant albedo attribute.
attenuation = albedo;
This is an rather inprecise approximation for metal reflections at grazing angles and gives unnatural dark edges around the spheres (compare the original and corrected image). This issue can be easily fixed by replacing the constant albedo with Schlick's approximation

attenuation = metal_reflectance(cos_theta, albedo);
static color metal_reflectance(double cosine, const color& albedo) {
   const color white = color(1, 1, 1);
   // Schlick's approximation for metals
   return albedo + (white - albedo) * pow(1 - cosine, 5);
}

spheres
spheres_corrected

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions