summaryrefslogtreecommitdiffhomepage
path: root/src/light.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-05-26 15:48:45 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-05-26 15:48:45 +0200
commit0e3c3cb0ebdb641f71d356aab98b8f2aca675d2a (patch)
treee2cdde63c31d171f4f5f3cc918a52657b4d37815 /src/light.cpp
parent7d421d0069dbc8bcf948a29d39c3f8e65de19b33 (diff)
light: intensity should be a 2d vector
It's a vector in order to provide an approximation of area lighting without actually implementing them.
Diffstat (limited to 'src/light.cpp')
-rw-r--r--src/light.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/light.cpp b/src/light.cpp
index ed7c4ae1..ed9469f2 100644
--- a/src/light.cpp
+++ b/src/light.cpp
@@ -43,14 +43,19 @@ bool light::update(size_t, float) { return false; }
bool light::is_dynamic() const { return true; }
bool light::is_virtual() const { return true; }
-float light::calc_intensity(float half_dist, light_falloff falloff)
+Vector2 light::intensity(Vector2 half_dist, light_falloff falloff)
{
switch (falloff)
{
case light_falloff::linear: return 2 * half_dist;
- case light_falloff::quadratic: return std::sqrt(2 * half_dist);
- default: case light_falloff::constant: return 1;
+ case light_falloff::quadratic: return Vector2{std::sqrt(2 * half_dist.x()), std::sqrt(2 * half_dist.y())};
+ default: case light_falloff::constant: return Vector2{1, 1};
}
}
+Vector2 light::intensity() const
+{
+ return intensity(half_dist, falloff);
+}
+
} // namespace floormat