Merge pull request #2822 from wwylele/sw_lighting-2

Implement fragment lighting in the sw renderer (take 2)
This commit is contained in:
Weiyi Wang 2017-08-09 18:54:29 +03:00 committed by GitHub
commit 792dee47a7
8 changed files with 316 additions and 10 deletions

View file

@ -30,6 +30,11 @@ public:
return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz),
w * other.w - Dot(xyz, other.xyz)};
}
Quaternion<T> Normalized() const {
T length = std::sqrt(xyz.Length2() + w * w);
return {xyz / length, w / length};
}
};
template <typename T>

View file

@ -31,7 +31,6 @@
#pragma once
#include <cmath>
#include <type_traits>
namespace Math {
@ -90,7 +89,7 @@ public:
x -= other.x;
y -= other.y;
}
template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type>
Vec2<decltype(-T{})> operator-() const {
return MakeVec(-x, -y);
}
@ -247,7 +246,7 @@ public:
y -= other.y;
z -= other.z;
}
template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type>
Vec3<decltype(-T{})> operator-() const {
return MakeVec(-x, -y, -z);
}
@ -462,7 +461,7 @@ public:
z -= other.z;
w -= other.w;
}
template <typename Q = T, class = typename std::enable_if<std::is_signed<Q>::value>::type>
Vec4<decltype(-T{})> operator-() const {
return MakeVec(-x, -y, -z, -w);
}