mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-27 10:38:02 +03:00
will do map refactor tomorrow, for now, planet lighting 🆑 * add: Ported planet lighting for indoor / outdoor areas. * add: Ported day-night cycle functionality. * add: Ported some Storage UI v2 fixes. --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: DoutorWhite <thedoctorwhite@gmail.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> (cherry picked from commit 4efb0b3b328dd4eba3095cc3f0a95fad88b49661)
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using System.Numerics;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Enums;
|
|
|
|
namespace Content.Client.Light;
|
|
|
|
/// <summary>
|
|
/// This exists just to copy <see cref="BeforeLightTargetOverlay"/> to the light render target
|
|
/// </summary>
|
|
public sealed class AfterLightTargetOverlay : Overlay
|
|
{
|
|
public override OverlaySpace Space => OverlaySpace.BeforeLighting;
|
|
|
|
[Dependency] private readonly IOverlayManager _overlay = default!;
|
|
|
|
public const int ContentZIndex = LightBlurOverlay.ContentZIndex + 1;
|
|
|
|
public AfterLightTargetOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
ZIndex = ContentZIndex;
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
var viewport = args.Viewport;
|
|
var worldHandle = args.WorldHandle;
|
|
|
|
if (viewport.Eye == null)
|
|
return;
|
|
|
|
var lightOverlay = _overlay.GetOverlay<BeforeLightTargetOverlay>();
|
|
var bounds = args.WorldBounds;
|
|
|
|
// at 1-1 render scale it's mostly fine but at 4x4 it's way too fkn big
|
|
var newScale = viewport.RenderScale / 2f;
|
|
|
|
var localMatrix =
|
|
viewport.LightRenderTarget.GetWorldToLocalMatrix(viewport.Eye, newScale);
|
|
var diff = (lightOverlay.EnlargedLightTarget.Size - viewport.LightRenderTarget.Size);
|
|
var halfDiff = diff / 2;
|
|
|
|
// Pixels -> Metres -> Half distance.
|
|
// If we're zoomed in need to enlarge the bounds further.
|
|
args.WorldHandle.RenderInRenderTarget(viewport.LightRenderTarget,
|
|
() =>
|
|
{
|
|
// We essentially need to draw the cropped version onto the lightrendertarget.
|
|
var subRegion = new UIBox2i(halfDiff.X,
|
|
halfDiff.Y,
|
|
viewport.LightRenderTarget.Size.X + halfDiff.X,
|
|
viewport.LightRenderTarget.Size.Y + halfDiff.Y);
|
|
|
|
worldHandle.SetTransform(localMatrix);
|
|
worldHandle.DrawTextureRectRegion(lightOverlay.EnlargedLightTarget.Texture, bounds, subRegion: subRegion);
|
|
}, null);
|
|
}
|
|
}
|