diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs
index d9c1f5fdef..ffaf987d64 100644
--- a/Utilities/CalamityUtils.cs
+++ b/Utilities/CalamityUtils.cs
@@ -3803,10 +3803,17 @@ namespace CalamityMod
return Color.Lerp(currentColor, nextColor, increment * colors.Length % 1f);
}
- // TODO: Find some way to speed this up.
+ // Cached for efficiency purposes.
+ internal static readonly FieldInfo UImageField = typeof(MiscShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance);
+
+ ///
+ /// Manually sets the texture of a instance, since vanilla's implementation only supports strings that access vanilla textures.
+ ///
+ /// The shader to bind the texture to.
+ /// The texture to bind.
public static void SetShaderTexture(this MiscShaderData shader, Texture2D texture)
{
- typeof(MiscShaderData).GetField("_uImage", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(shader, new Ref(texture));
+ UImageField.SetValue(shader, new Ref(texture));
}
#endregion