Skip to content

Commit 7b2b37d

Browse files
committed
Fix extra light not getting applied to remap
1 parent 3724cd5 commit 7b2b37d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/TSMapEditor/Rendering/ObjectRenderers/ObjectRenderer.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,12 @@ protected void DrawShapeImage(T gameObject, ShapeImage image, int frameIndex, Co
420420
if (affectedByLighting && image.SubjectToLighting)
421421
{
422422
lighting = mapCell.CellLighting.ToXNAVector4(extraLight);
423-
remapColor = ScaleColorToAmbient(remapColor, mapCell.CellLighting);
423+
remapColor = ScaleColorToAmbient(remapColor, lighting);
424424
}
425425
else if (affectedByAmbient)
426426
{
427427
lighting = mapCell.CellLighting.ToXNAVector4Ambient(extraLight);
428-
remapColor = ScaleColorToAmbient(remapColor, mapCell.CellLighting);
428+
remapColor = ScaleColorToAmbient(remapColor, lighting);
429429
}
430430
}
431431

@@ -473,7 +473,7 @@ protected void DrawVoxelModel(T gameObject, VoxelModel model, byte facing, RampT
473473
depthAddition += GetDepthFromPosition(gameObject, drawingBounds);
474474
depthAddition += GetDepthAddition(gameObject);
475475

476-
remapColor = ScaleColorToAmbient(remapColor, mapCell.CellLighting);
476+
remapColor = ScaleColorToAmbient(remapColor, lighting);
477477

478478
// Shader scales lighting by 2x
479479
remapColor = new Color(remapColor.R / 2, remapColor.G / 2, remapColor.B / 2, remapColor.A);
@@ -536,5 +536,15 @@ protected Color ScaleColorToAmbient(Color color, MapColor mapColor)
536536
(int)(color.B * highestComponent),
537537
color.A);
538538
}
539+
540+
protected Color ScaleColorToAmbient(Color color, Vector4 vector)
541+
{
542+
double highestComponent = Math.Max(vector.X, Math.Max(vector.Y, vector.Z));
543+
544+
return new Color((int)(color.R * highestComponent),
545+
(int)(color.G * highestComponent),
546+
(int)(color.B * highestComponent),
547+
color.A);
548+
}
539549
}
540550
}

0 commit comments

Comments
 (0)