Stop normalizing light directions

This normalization was added in 02ac5e95c8 (and changed to use floats in 4bf031c064).  However, this normalization introduces NaN values in some cases, which is causing problems for the version of Mesa in use on FifoCI (currently 20.3.5).  Although Mesa's NaN behavior is corrected by b3f3287eac (21.2.0), FifoCI is currently stuck with the older version.
This commit is contained in:
Pokechu22 2022-02-24 17:10:17 -08:00
parent ceae42b754
commit 63e299e1a1
1 changed files with 3 additions and 16 deletions

View File

@ -172,22 +172,9 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
dstlight.pos[1] = light.dpos[1];
dstlight.pos[2] = light.dpos[2];
// TODO: Hardware testing is needed to confirm that this normalization is correct
auto sanitize = [](float f) {
if (std::isnan(f))
return 0.0f;
else if (std::isinf(f))
return f > 0.0f ? 1.0f : -1.0f;
else
return f;
};
double norm = double(light.ddir[0]) * double(light.ddir[0]) +
double(light.ddir[1]) * double(light.ddir[1]) +
double(light.ddir[2]) * double(light.ddir[2]);
norm = 1.0 / sqrt(norm);
dstlight.dir[0] = sanitize(static_cast<float>(light.ddir[0] * norm));
dstlight.dir[1] = sanitize(static_cast<float>(light.ddir[1] * norm));
dstlight.dir[2] = sanitize(static_cast<float>(light.ddir[2] * norm));
dstlight.dir[0] = light.ddir[0];
dstlight.dir[1] = light.ddir[1];
dstlight.dir[2] = light.ddir[2];
}
dirty = true;