Adds concept of distance to illumination
This commit is contained in:
parent
17fd35fe76
commit
5db502d77a
5 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
#include "light/ambientlight.h"
|
||||
|
||||
Light::Illumination AmbientLight::illuminate(Scene const &scene, Ray const &ray) const {
|
||||
return {this->color * this->intensity, -ray.normal};
|
||||
return {this->color * this->intensity, -ray.normal, 0};
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
struct Illumination {
|
||||
Color color;
|
||||
Vector3d direction;
|
||||
float distance;
|
||||
};
|
||||
|
||||
// Constructor / Destructor
|
||||
|
|
|
@ -12,6 +12,7 @@ Light::Illumination PointLight::illuminate(Scene const &scene, Ray const &ray) c
|
|||
|
||||
// Precompute the distance from the light source
|
||||
float const distance = length(target - this->position);
|
||||
illum.distance = distance;
|
||||
|
||||
// Define a secondary ray from the surface point to the light source.
|
||||
Ray lightRay;
|
||||
|
|
|
@ -13,6 +13,7 @@ Light::Illumination SpotLight::illuminate(Scene const &scene, Ray const &ray) co
|
|||
|
||||
// Precompute the distance from the light source
|
||||
float const distance = length(target - this->position);
|
||||
illum.distance = distance;
|
||||
|
||||
// Define a secondary ray from the surface point to the light source
|
||||
Ray lightRay;
|
||||
|
|
|
@ -12,6 +12,7 @@ Light::Illumination SunLight::illuminate(Scene const &scene, Ray const &ray) con
|
|||
// Illumination object
|
||||
Illumination illum;
|
||||
illum.direction = this->direction;
|
||||
illum.distance = INFINITY;
|
||||
|
||||
// Define a secondary ray from the surface point to the light source.
|
||||
Ray lightRay;
|
||||
|
|
Loading…
Reference in a new issue