T2 Texture Mapping (MS2)
Create class texture
#ifndef TEXTURE_H
#define TEXTURE_H
class texture {
public:
virtual ~texture() = default;
virtual color value(double u, double v, const point3& p) const = 0;
};
class solid_color : public texture {
public:
solid_color(const color& albedo) : albedo(albedo) {}
solid_color(double red, double green, double blue) : solid_color(color(red,green,blue)) {}
color value(double u, double v, const point3& p) const override {
return albedo;
}
private:
color albedo;
};
#endifAdd u, v in hit_record (hittable.h)
Checker Texture
Add texture to the lambertian class in material.h
Modify the scene in main.cpp to use the textured lambertian material
Build and Run

Last updated