Implement emissive materials
This commit is contained in:
17
material.h
17
material.h
@@ -10,6 +10,10 @@ class material {
|
||||
public:
|
||||
virtual ~material() = default;
|
||||
|
||||
virtual colour emitted(double u, double v, const point3& p) const {
|
||||
return colour(0,0,0);
|
||||
}
|
||||
|
||||
virtual bool scatter(const ray& rIn, const hitRecord& rec, colour& attenuation, ray& scattered) const {
|
||||
return false;
|
||||
}
|
||||
@@ -88,4 +92,17 @@ class dielectric : public material {
|
||||
}
|
||||
};
|
||||
|
||||
class diffuseLight : public material {
|
||||
public:
|
||||
diffuseLight(shared_ptr<texture> tex) : tex(tex) {}
|
||||
diffuseLight(const colour& emit) : tex(make_shared<solidColour>(emit)) {}
|
||||
|
||||
colour emitted(double u, double v, const point3& p) const override {
|
||||
return tex->value(u, v, p);
|
||||
}
|
||||
|
||||
private:
|
||||
shared_ptr<texture> tex;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user