From e2ad593e883d6f220309a5a090aa0f4147337d2f Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Thu, 7 May 2020 19:34:22 +0000 Subject: [PATCH] When the translator map is enabled the colour values seem to use 4 bits, 0-16. Why not 0-31 I don't know. Anyway virtua on is overflowing these values for some of the smoke effects. For us the numbers were wrapping around. Clamping is enough to fix this. (Thanks model123) --- Src/Graphics/New3D/New3D.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 395bf75..1e5535a 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -1141,9 +1141,9 @@ void CNew3D::CacheModel(Model *m, const UINT32 *data) p.faceColour[2] = ((ph.header[4] >> 8) & 0xFF); if (ph.TranslatorMap()) { - p.faceColour[0] = (p.faceColour[0] * 255) / 16; // When the translator map is enabled, max colour seems - p.faceColour[1] = (p.faceColour[1] * 255) / 16; // to be 16. Scaling these up gives the correct colours. - p.faceColour[2] = (p.faceColour[2] * 255) / 16; // Not sure why didn't allow 32 colours with 4 bits? + p.faceColour[0] = std::min((p.faceColour[0] * 255) / 16, 255); // When the translator map is enabled, max colour seems to be 16. Why not 4 bits? + p.faceColour[1] = std::min((p.faceColour[1] * 255) / 16, 255); // We clamp the result because virtua on will overflow for only the smoke effects + p.faceColour[2] = std::min((p.faceColour[2] * 255) / 16, 255); // It's passing 33 instead of a max of 16. } }