Add material support
This commit is contained in:
parent
6d98c22890
commit
58ffcff459
7 changed files with 112 additions and 36 deletions
|
|
@ -33,5 +33,25 @@ inline double clamp(double v, double min, double max)
|
|||
#include "ray.hpp"
|
||||
#include "vec3.hpp"
|
||||
|
||||
struct material;
|
||||
|
||||
/* Common data structures */
|
||||
|
||||
struct hit_record {
|
||||
point3 p;
|
||||
vec3 normal;
|
||||
std::shared_ptr<material> mat_ptr;
|
||||
double t;
|
||||
bool front_face;
|
||||
|
||||
inline void set_face_normal(const ray& r, const vec3& outward_normal)
|
||||
{
|
||||
front_face = dot(r.direction, outward_normal) < 0;
|
||||
normal = front_face ? outward_normal : -outward_normal;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue