mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 18:53:42 +00:00
feat: add post-processing pass and video settings menu
Enable glow/bloom, color adjustments, and MSAA+FXAA across all three arenas so emissive ship/station accents actually bleed light and edges read cleanly. Expose the player-facing knobs (anti-aliasing mode, glow intensity, brightness) through a new Settings screen off the main menu, persisted via a VideoSettings autoload that scales each arena's own tuned Environment values on load rather than overwriting them.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
extends Node
|
||||
|
||||
# Autoload: persisted player-facing video preferences (AA, glow, brightness).
|
||||
# AA is a Viewport-wide setting applied immediately via apply_aa(). Glow and
|
||||
# brightness instead scale each arena's own tuned Environment values (see
|
||||
# arena.gd's _ready(), which calls apply_to_environment() once per arena
|
||||
# load) rather than overwriting them outright, so the per-arena bloom tuning
|
||||
# in arena_01/02/03.tscn survives underneath the user's preference.
|
||||
|
||||
enum AAMode { OFF, FXAA, MSAA, MSAA_FXAA }
|
||||
|
||||
const SETTINGS_PATH := "user://settings.cfg"
|
||||
|
||||
var aa_mode: AAMode = AAMode.MSAA_FXAA
|
||||
var glow_scale: float = 1.0
|
||||
var brightness: float = 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load()
|
||||
apply_aa()
|
||||
|
||||
|
||||
func _load() -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
if cfg.load(SETTINGS_PATH) != OK:
|
||||
return
|
||||
aa_mode = cfg.get_value("video", "aa_mode", aa_mode) as AAMode
|
||||
glow_scale = cfg.get_value("video", "glow_scale", glow_scale)
|
||||
brightness = cfg.get_value("video", "brightness", brightness)
|
||||
|
||||
|
||||
func save() -> void:
|
||||
var cfg := ConfigFile.new()
|
||||
cfg.set_value("video", "aa_mode", aa_mode)
|
||||
cfg.set_value("video", "glow_scale", glow_scale)
|
||||
cfg.set_value("video", "brightness", brightness)
|
||||
cfg.save(SETTINGS_PATH)
|
||||
|
||||
|
||||
func apply_aa() -> void:
|
||||
var viewport := get_tree().root
|
||||
match aa_mode:
|
||||
AAMode.OFF:
|
||||
viewport.msaa_3d = Viewport.MSAA_DISABLED
|
||||
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED
|
||||
AAMode.FXAA:
|
||||
viewport.msaa_3d = Viewport.MSAA_DISABLED
|
||||
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_FXAA
|
||||
AAMode.MSAA:
|
||||
viewport.msaa_3d = Viewport.MSAA_4X
|
||||
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED
|
||||
AAMode.MSAA_FXAA:
|
||||
viewport.msaa_3d = Viewport.MSAA_4X
|
||||
viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_FXAA
|
||||
|
||||
|
||||
# Called once by each arena's _ready() to fold the user's glow/brightness
|
||||
# preference into that arena's own baked Environment tuning.
|
||||
func apply_to_environment(env: Environment) -> void:
|
||||
if env == null:
|
||||
return
|
||||
env.glow_enabled = glow_scale > 0.0
|
||||
env.glow_intensity *= glow_scale
|
||||
env.adjustment_brightness *= brightness
|
||||
Reference in New Issue
Block a user