From 03a5d691ee1028cc2a8bffcab5b3b07a9bfd6d20 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 11 Jun 2026 15:27:56 -0700 Subject: [PATCH] Add white glow behind hovered player's name The hovered player (tile owner under the cursor, already tracked via uHighlightOwnerID for cull bypass) now gets a soft white glow behind their name. The glow is derived from the MSDF distance field: a white band past the outline with quadratic falloff, composited behind the glyph and clamped to the SDF margin so it never clips at quad edges. Glow size and strength are tunable via hoverGlowWidth/hoverGlowAlpha in render-settings.json, exposed as sliders in the graphics settings modal (persisted as graphics overrides) and in the debug GUI. Includes schema and apply tests for the new override fields, covering the 0 edge case (0 disables the glow, not "unset"). --- resources/lang/en.json | 4 + .../hud/layers/GraphicsSettingsModal.ts | 84 +++++++++++++++++++ src/client/render/gl/GraphicsOverrides.ts | 2 + src/client/render/gl/RenderOverrides.ts | 6 ++ src/client/render/gl/RenderSettings.ts | 4 + src/client/render/gl/debug/Layout.ts | 2 + .../render/gl/passes/name-pass/TextProgram.ts | 12 +++ src/client/render/gl/render-settings.json | 4 +- .../render/gl/shaders/name/name.frag.glsl | 39 +++++++-- .../render/gl/shaders/name/name.vert.glsl | 7 ++ tests/GraphicsOverrides.test.ts | 33 ++++++++ 11 files changed, 188 insertions(+), 9 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index 46e49b848..664828bf9 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -944,6 +944,10 @@ "name_cull_desc": "Hide names smaller than this size", "hover_fade_label": "Name opacity under cursor", "hover_fade_desc": "How visible names are while your cursor is over them (1 to disable fading)", + "hover_glow_width_label": "Hover glow size", + "hover_glow_width_desc": "How far the white glow extends behind the hovered player's name", + "hover_glow_alpha_label": "Hover glow strength", + "hover_glow_alpha_desc": "How bright the white glow behind the hovered player's name is (0 to disable)", "colored_names_label": "Name color", "colored_names_desc": "Show player names in their player color or in black", "colored": "Colored", diff --git a/src/client/hud/layers/GraphicsSettingsModal.ts b/src/client/hud/layers/GraphicsSettingsModal.ts index c5aff6ae9..b41842be6 100644 --- a/src/client/hud/layers/GraphicsSettingsModal.ts +++ b/src/client/hud/layers/GraphicsSettingsModal.ts @@ -24,6 +24,14 @@ const HOVER_FADE_MIN = 0; const HOVER_FADE_MAX = 1; const HOVER_FADE_STEP = 0.05; +const HOVER_GLOW_WIDTH_MIN = 0; +const HOVER_GLOW_WIDTH_MAX = 8; +const HOVER_GLOW_WIDTH_STEP = 0.5; + +const HOVER_GLOW_ALPHA_MIN = 0; +const HOVER_GLOW_ALPHA_MAX = 1; +const HOVER_GLOW_ALPHA_STEP = 0.05; + const HIGHLIGHT_FILL_MIN = 0; const HIGHLIGHT_FILL_MAX = 1; const HIGHLIGHT_FILL_STEP = 0.01; @@ -159,6 +167,20 @@ export class GraphicsSettingsModal extends LitElement implements Controller { ); } + private currentHoverGlowWidth(): number { + return ( + this.userSettings.graphicsOverrides().name?.hoverGlowWidth ?? + renderDefaults.name.hoverGlowWidth + ); + } + + private currentHoverGlowAlpha(): number { + return ( + this.userSettings.graphicsOverrides().name?.hoverGlowAlpha ?? + renderDefaults.name.hoverGlowAlpha + ); + } + private patchName(patch: Partial) { const current = this.userSettings.graphicsOverrides(); this.userSettings.setGraphicsOverrides({ @@ -349,6 +371,16 @@ export class GraphicsSettingsModal extends LitElement implements Controller { this.patchName({ hoverFadeAlpha: value }); } + private onHoverGlowWidthChange(event: Event) { + const value = parseFloat((event.target as HTMLInputElement).value); + this.patchName({ hoverGlowWidth: value }); + } + + private onHoverGlowAlphaChange(event: Event) { + const value = parseFloat((event.target as HTMLInputElement).value); + this.patchName({ hoverGlowAlpha: value }); + } + private currentDarkNames(): boolean { return ( this.userSettings.graphicsOverrides().name?.darkNames ?? @@ -371,6 +403,8 @@ export class GraphicsSettingsModal extends LitElement implements Controller { const nameScale = this.currentNameScale(); const nameCull = this.currentNameCull(); const hoverFade = this.currentHoverFade(); + const hoverGlowWidth = this.currentHoverGlowWidth(); + const hoverGlowAlpha = this.currentHoverGlowAlpha(); const namesColored = !this.currentDarkNames(); const classicIcons = this.currentClassicIcons(); const highlightFill = this.currentHighlightFill(); @@ -492,6 +526,56 @@ export class GraphicsSettingsModal extends LitElement implements Controller { +
+
+
+ ${translateText("graphics_setting.hover_glow_width_label")} +
+
+ ${translateText("graphics_setting.hover_glow_width_desc")} +
+ +
+
+ ${hoverGlowWidth.toFixed(1)} +
+
+ +
+
+
+ ${translateText("graphics_setting.hover_glow_alpha_label")} +
+
+ ${translateText("graphics_setting.hover_glow_alpha_desc")} +
+ +
+
+ ${hoverGlowAlpha.toFixed(2)} +
+
+