toytracer/material.h
2020-06-06 23:28:33 +02:00

35 lines
747 B
C++

#ifndef MATERIAL_H
#define MATERIAL_H
#include "hittable.h"
#include "vec3.h"
struct hit_record;
class Material {
public:
virtual bool scatter(const Ray& r_in, const hit_record& rec, Color& attenuation, Ray& scattered) const = 0;
};
class Lambertian : public Material {
public:
Lambertian(const Color& a) : albedo(a) {}
virtual bool scatter(const Ray& r_in, const hit_record& rec, Color& attenuation, Ray& scattered) const;
private:
Color albedo;
};
class Metal : public Material {
public:
Metal(const Color& a, double f) : albedo(a), fuzz(f < 1 ? f : 1) {}
virtual bool scatter(const Ray& r_in, const hit_record& rec, Color& attenuation, Ray& scattered) const;
private:
Color albedo;
double fuzz;
};
#endif // MATERIAL_H