diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index 8c78d8b70..2f3331654 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -514,10 +514,9 @@ async function createClientGame( const regenerateRenderSettings = (): void => { deepAssign(view.getSettings(), resolveRenderSettings()); }; - // Re-apply render settings, then re-theme and recolor players, on a - // graphics-override change (covers a theme switch such as colorblind mode). - const onGraphicsChanged = (): void => { - regenerateRenderSettings(); + // Rebuild the GPU-derived graphics state that the per-frame passes don't + // pick up from the live settings object on their own. + const refreshDerivedGraphics = (): void => { // Terrain is baked into a GPU texture rather than read per-frame, so a // terrain-color override (e.g. ocean) needs an explicit texture rebuild. view.rebuildTerrain(); @@ -527,6 +526,12 @@ async function createClientGame( gameView.refreshPlayerColors(); webglBuilder.refreshPalette(gameView); }; + // Re-apply render settings, then re-theme and recolor players, on a + // graphics-override change (covers a theme switch such as colorblind mode). + const onGraphicsChanged = (): void => { + regenerateRenderSettings(); + refreshDerivedGraphics(); + }; // No initial regenerate or terrain rebuild needed — the renderer was // constructed with the resolved settings above, so the terrain texture // already bakes any saved ocean-color override. @@ -545,7 +550,11 @@ async function createClientGame( debugGuiLoading = true; import("./render/gl/debug/index") .then(({ createDebugGui }) => { - debugGui = createDebugGui(view.getSettings()); + debugGui = createDebugGui( + view.getSettings(), + resolveRenderSettings, + refreshDerivedGraphics, + ); debugGui.open(); }) .finally(() => { diff --git a/src/client/render/gl/debug/Wiring.ts b/src/client/render/gl/debug/Wiring.ts index 9511ac9c4..866be2b5e 100644 --- a/src/client/render/gl/debug/Wiring.ts +++ b/src/client/render/gl/debug/Wiring.ts @@ -1,6 +1,6 @@ import GUI, { FunctionController } from "lil-gui"; import type { RenderSettings } from "../RenderSettings"; -import { createRenderSettings, dumpSettings } from "../RenderSettings"; +import { dumpSettings } from "../RenderSettings"; import { deepAssign } from "../SettingsUtils"; import type { ConfigProp } from "./ConfigProp"; @@ -66,6 +66,7 @@ export function wireActions( gui: GUI, settings: RenderSettings, props: ConfigProp[], + resolveDefaults: () => RenderSettings, onSettingsChanged?: () => void, ): void { gui.add({ dump: () => dumpSettings(settings) }, "dump").name("Download JSON"); @@ -99,7 +100,7 @@ export function wireActions( .add( { reset: () => { - deepAssign(settings, createRenderSettings()); + deepAssign(settings, resolveDefaults()); props.forEach((p) => p.resetToDefault()); onSettingsChanged?.(); }, diff --git a/src/client/render/gl/debug/index.ts b/src/client/render/gl/debug/index.ts index 7a414c464..4401c7404 100644 --- a/src/client/render/gl/debug/index.ts +++ b/src/client/render/gl/debug/index.ts @@ -7,6 +7,7 @@ import { makeDraggable, wireActions, wireModifiedIndicators } from "./Wiring"; export function createDebugGui( settings: RenderSettings, + resolveDefaults: () => RenderSettings = createRenderSettings, onSettingsChanged?: () => void, ): GUI { const gui = new GUI({ title: "Render Settings", width: 320 }); @@ -17,10 +18,13 @@ export function createDebugGui( makeDraggable(gui); - const defaults = createRenderSettings(); + // Defaults include the user's graphics overrides so "Reset to Defaults" + // (and the per-prop reset / modified indicators) restore the same settings + // the renderer was built with — not bare defaults that drop the overrides. + const defaults = resolveDefaults(); const props = walkTree(buildTree(settings, defaults), gui); - wireActions(gui, settings, props, onSettingsChanged); + wireActions(gui, settings, props, resolveDefaults, onSettingsChanged); wireModifiedIndicators(gui, props, onSettingsChanged); gui.close();