#include <PointLight.hpp>
Definition at line 15 of file PointLight.hpp.
◆ PointLight()
| RayTracer::PointLight::PointLight |
( |
const Math::Point3D & | pos, |
|
|
float | intensity ) |
◆ getPosition()
| const Math::Point3D & RayTracer::PointLight::getPosition |
( |
| ) |
const |
◆ illuminate()
Implements RayTracer::ILight.
Definition at line 12 of file PointLight.cpp.
13{
14 Color base = object.getBaseColor();
15 Math::Vector3D lightVec =
_position - point;
16 double distance = lightVec.
length();
17 double attenuation = 1.0 / (distance * distance);
18
19 return Color(
20 std::clamp(
static_cast<int>(base.
r *
_intensity * attenuation), 0, 255),
21 std::clamp(
static_cast<int>(base.
g *
_intensity * attenuation), 0, 255),
22 std::clamp(
static_cast<int>(base.
b *
_intensity * attenuation), 0, 255)
23 );
24}
References _intensity, _position, Color::b, Color::g, Math::Vector3D::length(), and Color::r.
◆ _intensity
| float RayTracer::PointLight::_intensity |
|
private |
◆ _position
The documentation for this class was generated from the following files: