Starting working on area lights.
This commit is contained in:
@@ -14,9 +14,13 @@
|
||||
#include <renderstat.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class World;
|
||||
|
||||
enum LightType
|
||||
{
|
||||
POINT_LIGHT = 0,
|
||||
AREA_LIGHT,
|
||||
|
||||
};
|
||||
|
||||
class Light
|
||||
@@ -26,15 +30,34 @@ public:
|
||||
Tuple position;
|
||||
LightType type;
|
||||
|
||||
/* For area light */
|
||||
Tuple corner;
|
||||
Tuple uVec;
|
||||
Tuple vVec;
|
||||
uint32_t samples;
|
||||
uint32_t uSteps;
|
||||
uint32_t vSteps;
|
||||
|
||||
public:
|
||||
Light(LightType type = POINT_LIGHT, Tuple position=Point(0, 0, 0),
|
||||
Colour intensity=Colour(1, 1, 1)) : type(type), position(position), intensity(intensity)
|
||||
{ stats.addLight(); };
|
||||
Light(LightType type, Tuple corner, Tuple fullUVec, uint32_t uSteps, Tuple fullVVec, uint32_t vSteps,
|
||||
Colour intensity, bool jitter = false): type(type), corner(corner), uVec(fullUVec / uSteps), uSteps(uSteps),
|
||||
vVec(fullVVec / vSteps), vSteps(vSteps), intensity(intensity)
|
||||
{
|
||||
this->samples = this->vSteps * this->uSteps;
|
||||
this->position = this->corner + ((fullUVec + fullVVec) / 2);
|
||||
stats.addLight();
|
||||
};
|
||||
double intensityAt(World &w, Tuple point);
|
||||
|
||||
bool operator==(const Light &b) const { return this->intensity == b.intensity &&
|
||||
this->position == b.position &&
|
||||
this->type == b.type; };
|
||||
|
||||
Tuple pointOnLight(uint32_t u, uint32_t v);
|
||||
|
||||
void dumpMe(FILE *fp);
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
Material() : colour(Colour(1, 1, 1)), ambient(0.1), diffuse(0.9), specular(0.9), shininess(200),
|
||||
reflective(0.0), transparency(0.0), emissive(0), refractiveIndex(1.0), pattern(nullptr) {};
|
||||
|
||||
Colour lighting(Light light, Tuple point, Tuple eyeVector, Tuple normalVector, Shape *hitObject, bool inShadow = false);
|
||||
Colour lighting(Light light, Tuple point, Tuple eyeVector, Tuple normalVector, Shape *hitObject,
|
||||
double lightIntensity = 1.0);
|
||||
|
||||
bool operator==(const Material &b) const { return double_equal(this->ambient, b.ambient) &&
|
||||
double_equal(this->diffuse, b.diffuse) &&
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
|
||||
Tuple shadeHit(Computation comps, uint32_t depthCount = 4);
|
||||
Tuple colourAt(Ray r, uint32_t depthCount = 4);
|
||||
bool isShadowed(Tuple point, uint32_t light = 0);
|
||||
bool isShadowed(Tuple point, Tuple lightPosition);
|
||||
|
||||
Colour reflectColour(Computation comps, uint32_t depthCount = 4);
|
||||
Colour refractedColour(Computation comps, uint32_t depthCount = 4);
|
||||
|
||||
Reference in New Issue
Block a user