Skip to content

Add shader presets (CRT/Scanlines) and a functional screenshot hotkey - #3

Merged
mstan merged 1 commit into
mstan:mainfrom
ClaudioVarandas:feat/shaders-screenshot-16x9
Sep 13, 2026
Merged

Add shader presets (CRT/Scanlines) and a functional screenshot hotkey#3
mstan merged 1 commit into
mstan:mainfrom
ClaudioVarandas:feat/shaders-screenshot-16x9

Conversation

@ClaudioVarandas

Copy link
Copy Markdown
Contributor

Summary

Adds GLSL shader presets (CRT + Scanlines, 3 strength tiers each) to the
existing but unused shader preset loader, and a functional player-facing
screenshot hotkey (F12). Also fixes the launcher round-trip that was
silently dropping the selected shader instead of persisting/applying it.

What changed

  • Shader presets: assets/shaders/{crt,scanlines}{,-light,-strong}.glslp
    for src/glsl_shader.c's existing RetroArch-style preset loader, which
    had zero presets shipped. GameInfo.has_shader = 1 turns on the
    launcher's Settings → Video → Shader dropdown (already implemented in
    the shared launcher, just never enabled for this game).
  • Shader persistence fix: the launcher's selection now round-trips
    through RecompLauncherCSettings.shader_path into g_config.shader
    and gets written back via WriteConfigFile's new OutputMethod/
    Shader keys — previously the picker showed a choice but it never
    reached config.ini or the renderer.
  • Screenshot hotkey: new Screenshot command (F12 default,
    OpenGL backend only — same limitation the shader path already has).
    Captures the fully composited framebuffer via glReadPixels (custom
    widescreen renderer + any active shader included), writes a timestamped
    BMP to screenshots/, with a 0.5s debounce against SDL key auto-repeat
    and a brief time-based flash for feedback in fullscreen.
  • Build robustness: CMakeLists.txt gains a shader-asset staging
    target that removes+recopies assets/shaders/ on every build (a plain
    POST_BUILD copy only ran when the executable itself relinked, leaving
    stale files behind after a rename/delete).

Testing

  • ctest 5/5 on both Debug and Release builds.
  • Manual: shader selection persists across relaunch and renders visually;
    F12 saves a valid BMP and shows the flash; verified with a diagnostic
    solid-color shader that the full launcher → config.ini → OpenGL
    pipeline works end to end.
  • Investigated a widescreen-looks-4:3 report during testing: traced it to
    the attract demo's game_state (30) falling outside
    sm_renderer.c's room_state() allowlist — a pre-existing, documented
    renderer limitation for the demo/menu path, unrelated to this change.
    Confirmed widescreen renders correctly in real gameplay.

Notes

  • No snesrecomp or recomp-ui (submodule) changes — everything is
    scoped to this repo.
  • Raw .glsl shader sources live under assets/shaders/.src/ (dot-, not
    underscore-, prefixed) so the launcher's picker treats them as private
    without colliding with this repo's _* scratch-file .gitignore rule.

Note: this code was made with AI assistance, tested and validated by me.

Shaders: bundle CRT and Scanlines presets (3 strength tiers each) for the
existing GLSL preset loader (src/glsl_shader.c), which had zero presets
shipped. GameInfo.has_shader now enables the launcher's shader dropdown
(previously wired but never turned on for SM), and CMakeLists.txt gains a
robust asset-staging target that removes+recopies assets/shaders/ so
renamed/deleted sources never leave stale duplicates behind. Raw .glsl
sources live in a shaders/.src/ subdirectory (dot-prefixed, not
underscore) so the launcher's "private path" filter hides them from the
picker without colliding with this repo's root _* scratch-file gitignore
rule.

Also closes the loop the launcher's Settings screen needed to actually
persist a shader choice: the selected path/backend now round-trips
through RecompLauncherCSettings.shader_path into g_config.shader (backed
by static storage, since g_config.shader normally points into the parsed
config.ini buffer) and gets written back via WriteConfigFile's OutputMethod
and Shader keys, which weren't in its persisted-fields table before.

Screenshot: new Screenshot hotkey (F12 by default), OpenGL backend only
(matches the existing shader limitation and warns the same way). Captures
the final composited framebuffer via glReadPixels -- includes the custom
widescreen renderer and any active GLSL shader, not just the native SNES
raster -- and writes a timestamped BMP to screenshots/. A 0.5s debounce
guards against SDL's key auto-repeat (the input loop doesn't check
event.key.repeat), and a brief time-based white flash gives feedback in
fullscreen where the terminal isn't visible.

Verified: ctest 5/5 on both Debug and Release builds; manual launcher
round-trip (shader selection persists and renders, F12 saves + flashes);
confirmed via sm_render_capture + a game_state trace that stock-fallback
during the attract demo (state 30, outside sm_renderer.c's room_state()
allowlist) is a pre-existing, documented renderer limitation unrelated to
this change -- widescreen renders correctly once in real gameplay.
@mstan
mstan force-pushed the feat/shaders-screenshot-16x9 branch from beff7ed to cb131e8 Compare September 13, 2026 03:02
@mstan
mstan merged commit 32085c5 into mstan:main Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants