Simplify light strength ratio calculation

This commit is contained in:
Jarrod Doyle 2024-10-27 08:54:52 +00:00
parent ef95b07926
commit 3df1b728e6
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 1 additions and 6 deletions

View File

@ -260,12 +260,7 @@ public class WorldRep : IChunk
// the hue/saturation of coloured lights. Got to make sure we // the hue/saturation of coloured lights. Got to make sure we
// maintain the colour ratios. // maintain the colour ratios.
var c = color * strength; var c = color * strength;
var ratio = 0.0f; var ratio = Math.Max(Math.Max(Math.Max(0.0f, c.X), c.Y), c.Z) / 255.0f;
foreach (var e in new float[] { c.X, c.Y, c.Z })
{
ratio = Math.Max(ratio, e / 255.0f);
}
if (ratio > 1.0f) if (ratio > 1.0f)
{ {
c /= ratio; c /= ratio;