Fix missing normalization of the first plane vector after cross product

This commit is contained in:
Magnus Norddahl 2021-11-12 17:00:07 +01:00
parent 2a91f530c9
commit 6b4fef6a2b
2 changed files with 4 additions and 4 deletions

View file

@ -251,7 +251,7 @@ void CPURaytracer::RunLightTrace(CPUTraceState& state)
float attenuation = 0.0f;
if (state.PassType == 0 && surface)
{
Vec3 e0 = Vec3::Cross(normal, std::abs(normal.x) < std::abs(normal.y) ? Vec3(1.0f, 0.0f, 0.0f) : Vec3(0.0f, 1.0f, 0.0f));
Vec3 e0 = Vec3::Normalize(Vec3::Cross(normal, std::abs(normal.x) < std::abs(normal.y) ? Vec3(1.0f, 0.0f, 0.0f) : Vec3(0.0f, 1.0f, 0.0f)));
Vec3 e1 = Vec3::Cross(normal, e0);
e0 = Vec3::Cross(normal, e1);
@ -308,7 +308,7 @@ void CPURaytracer::RunLightTrace(CPUTraceState& state)
if (state.PassType == 0 && surface)
{
Vec3 e0 = Vec3::Cross(normal, std::abs(normal.x) < std::abs(normal.y) ? Vec3(1.0f, 0.0f, 0.0f) : Vec3(0.0f, 1.0f, 0.0f));
Vec3 e0 = Vec3::Normalize(Vec3::Cross(normal, std::abs(normal.x) < std::abs(normal.y) ? Vec3(1.0f, 0.0f, 0.0f) : Vec3(0.0f, 1.0f, 0.0f)));
Vec3 e1 = Vec3::Cross(normal, e0);
e0 = Vec3::Cross(normal, e1);
for (uint32_t i = 0; i < state.SampleCount; i++)

View file

@ -87,7 +87,7 @@ void main()
float attenuation = 0.0;
if (PassType == 0 && surfaceIndex >= 0)
{
vec3 e0 = cross(normal, abs(normal.x) < abs(normal.y) ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0));
vec3 e0 = normalize(cross(normal, abs(normal.x) < abs(normal.y) ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0)));
vec3 e1 = cross(normal, e0);
e0 = cross(normal, e1);
@ -139,7 +139,7 @@ void main()
if (PassType == 0 && surfaceIndex >= 0)
{
vec3 e0 = cross(normal, abs(normal.x) < abs(normal.y) ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0));
vec3 e0 = normalize(cross(normal, abs(normal.x) < abs(normal.y) ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0)));
vec3 e1 = cross(normal, e0);
e0 = cross(normal, e1);
for (uint i = 0; i < SampleCount; i++)