Adding shadows!

This commit is contained in:
Godzil
2020-02-20 17:46:03 +00:00
parent 5198888df6
commit cf5597ad6d
11 changed files with 145 additions and 24 deletions

View File

@@ -16,11 +16,13 @@ class Shape;
struct Computation
{
Computation(Shape *object, double t, Tuple point, Tuple eyev, Tuple normalv, bool inside) :
object(object), t(t), hitPoint(point), eyeVector(eyev), normalVector(normalv), inside(inside) { };
Computation(Shape *object, double t, Tuple point, Tuple eyev, Tuple normalv, Tuple overHitP, bool inside) :
object(object), t(t), hitPoint(point), eyeVector(eyev), normalVector(normalv), inside(inside), overHitPoint(overHitP) { };
Shape *object;
double t;
Tuple hitPoint;
Tuple overHitPoint;
Tuple eyeVector;
Tuple normalVector;

View File

@@ -25,7 +25,7 @@ public:
public:
Material() : colour(Colour(1, 1, 1)), ambient(0.1), diffuse(0.9), specular(0.9), shininess(200) {};
Colour lighting(Light light, Tuple point, Tuple eyeVector, Tuple normalVector);
Colour lighting(Light light, Tuple point, Tuple eyeVector, Tuple normalVector, bool inShadow = false);
bool operator==(const Material &b) const { return double_equal(this->ambient, b.ambient) &&
double_equal(this->diffuse, b.diffuse) &&

View File

@@ -13,6 +13,7 @@
#include <math.h>
void set_equal_precision(double v);
double getEpsilon();
bool double_equal(double a, double b);
double deg_to_rad(double deg);

View File

@@ -43,6 +43,7 @@ public:
Tuple shadeHit(Computation comps);;
Tuple colourAt(Ray r);
bool isShadowed(Tuple point);
Intersect intersect(Ray r);