Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Night Vision Light Sensetivity #5486

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Robust.Client/Graphics/Clyde/Clyde.LightRendering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ private void DrawLightsAndFov(Viewport viewport, Box2Rotated worldBounds, Box2 w
var lastSoftness = float.NaN;
Texture? lastMask = null;

if (_lightManager.NightVision)
{
GLClearColor(_lightManager.NightVisionColor);
GL.Clear(ClearBufferMask.ColorBufferBit);
}

Rinary1 marked this conversation as resolved.
Show resolved Hide resolved
using (_prof.Group("Draw Lights"))
{
for (var i = 0; i < count; i++)
Expand Down Expand Up @@ -475,7 +481,18 @@ private void DrawLightsAndFov(Viewport viewport, Box2Rotated worldBounds, Box2 w

if (lastColor != component.Color)
{
lastColor = component.Color;
if (_lightManager.LightSensitivity != 0)
{
lastColor = new Color(component.Color.R * _lightManager.LightSensitivity,
component.Color.G * _lightManager.LightSensitivity,
component.Color.B * _lightManager.LightSensitivity,
component.Color.A);
}
else
{
lastColor = component.Color;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than baking this in this is better done on the content side or alternatively via event.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than baking this in this is better done on the content side or alternatively via event.

wdym?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than baking this in this is better done on the content side or alternatively via event.

Could you explain how you see this? Sending an event here would be incredibly inefficient.

Copy link
Contributor

@metalgearsloth metalgearsloth Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As opposed to calling GL.ClearColor twice in a row...?

The lighting cap is incredibly small anyway. Again, there's no reason you can't just update the lighting render target from content with this.

lightShader.SetUniformMaybe("lightColor", lastColor);
}

Expand Down
12 changes: 12 additions & 0 deletions Robust.Client/Graphics/Lighting/ILightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,17 @@ public interface ILightManager
/// This is useful to prevent players messing with lighting setup when they shouldn't.
/// </summary>
bool LockConsoleAccess { get; set; }
/// <summary>
///
/// </summary>
bool NightVision { get; set; }
/// <summary>
///
/// </summary>
float LightSensitivity { get; set; }
/// <summary>
///
/// </summary>
Color NightVisionColor { get; set; }
}
}
3 changes: 3 additions & 0 deletions Robust.Client/Graphics/Lighting/LightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ public sealed class LightManager : ILightManager
public bool DrawLighting { get; set; } = true;
public bool LockConsoleAccess { get; set; } = false;
public Color AmbientLightColor { get; set; } = Color.FromSrgb(Color.Black);
public bool NightVision { get; set; } = false;
public float LightSensitivity { get; set; } = 0f;
public Color NightVisionColor { get; set; } = new(0.1f, 0.1f, 0.1f);
}
}
Loading