elimina supersampling (Lanczos downscale, keybinding, menu, locale)

This commit is contained in:
2026-05-17 15:07:28 +02:00
parent 96763847fb
commit b0c95111a2
13 changed files with 12 additions and 4339 deletions
-2
View File
@@ -153,14 +153,12 @@ if(NOT APPLE AND NOT EMSCRIPTEN)
"${HEADERS_DIR}/postfx_vert_spv.h" "${HEADERS_DIR}/postfx_vert_spv.h"
"${HEADERS_DIR}/postfx_frag_spv.h" "${HEADERS_DIR}/postfx_frag_spv.h"
"${HEADERS_DIR}/upscale_frag_spv.h" "${HEADERS_DIR}/upscale_frag_spv.h"
"${HEADERS_DIR}/downscale_frag_spv.h"
"${HEADERS_DIR}/crtpi_frag_spv.h" "${HEADERS_DIR}/crtpi_frag_spv.h"
) )
set(ALL_SHADER_SOURCES set(ALL_SHADER_SOURCES
"${SHADERS_DIR}/postfx.vert" "${SHADERS_DIR}/postfx.vert"
"${SHADERS_DIR}/postfx.frag" "${SHADERS_DIR}/postfx.frag"
"${SHADERS_DIR}/upscale.frag" "${SHADERS_DIR}/upscale.frag"
"${SHADERS_DIR}/downscale.frag"
"${SHADERS_DIR}/crtpi_frag.glsl" "${SHADERS_DIR}/crtpi_frag.glsl"
) )
+1 -1
View File
@@ -9,7 +9,7 @@ BUILDDIR := build
# ============================================================================== # ==============================================================================
SHADER_CMAKE := $(DIR_ROOT)tools/shaders/compile_spirv.cmake SHADER_CMAKE := $(DIR_ROOT)tools/shaders/compile_spirv.cmake
SHADERS_DIR := $(DIR_ROOT)data/shaders SHADERS_DIR := $(DIR_ROOT)data/shaders
HEADERS_DIR := $(DIR_ROOT)source/core/rendering/sdl3gpu HEADERS_DIR := $(DIR_ROOT)source/core/rendering/sdl3gpu/spv
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
GLSLC := $(shell where glslc 2>NUL) GLSLC := $(shell where glslc 2>NUL)
else else
-3
View File
@@ -27,9 +27,6 @@ keys:
- id: toggle_aspect_ratio - id: toggle_aspect_ratio
code: "F5" code: "F5"
desc: "Aspecte 4:3 / pixels quadrats" desc: "Aspecte 4:3 / pixels quadrats"
- id: toggle_supersampling
code: "F6"
desc: "Activa/desactiva supersampling"
- id: next_shader - id: next_shader
code: "F7" code: "F7"
desc: "Tipus de shader (PostFX / CRT-Pi)" desc: "Tipus de shader (PostFX / CRT-Pi)"
-3
View File
@@ -26,7 +26,6 @@ menu:
screen: "Pantalla" screen: "Pantalla"
shader: "Shader" shader: "Shader"
aspect_4_3: "Aspecte 4:3" aspect_4_3: "Aspecte 4:3"
supersampling: "Supersampling"
vsync: "Vsync" vsync: "Vsync"
scaling_mode: "Escala" scaling_mode: "Escala"
shader_type: "Tipus shader" shader_type: "Tipus shader"
@@ -79,8 +78,6 @@ notifications:
shader_off: "Shader off" shader_off: "Shader off"
aspect_43: "4:3 CRT" aspect_43: "4:3 CRT"
aspect_square: "Píxels quadrats" aspect_square: "Píxels quadrats"
ss_on: "Supersampling on"
ss_off: "Supersampling off"
preset_fmt: "Preset: %s" preset_fmt: "Preset: %s"
filter_linear: "Filtre: linear" filter_linear: "Filtre: linear"
filter_nearest: "Filtre: nearest" filter_nearest: "Filtre: nearest"
-48
View File
@@ -1,48 +0,0 @@
#version 450
layout(location = 0) in vec2 v_uv;
layout(location = 0) out vec4 out_color;
layout(set = 2, binding = 0) uniform sampler2D source;
layout(set = 3, binding = 0) uniform DownscaleUniforms {
int algorithm; // 0 = Lanczos2 (ventana 2, ±2 taps), 1 = Lanczos3 (ventana 3, ±3 taps)
float pad0;
float pad1;
float pad2;
} u;
// Kernel Lanczos normalizado: sinc(t) * sinc(t/a) para |t| < a, 0 fuera.
float lanczos(float t, float a) {
t = abs(t);
if (t < 0.0001) { return 1.0; }
if (t >= a) { return 0.0; }
const float PI = 3.14159265358979;
float pt = PI * t;
return (a * sin(pt) * sin(pt / a)) / (pt * pt);
}
void main() {
vec2 src_size = vec2(textureSize(source, 0));
// Posición en coordenadas de texel (centros de texel en N+0.5)
vec2 p = v_uv * src_size;
vec2 p_floor = floor(p);
float a = (u.algorithm == 0) ? 2.0 : 3.0;
int win = int(a);
vec4 color = vec4(0.0);
float weight_sum = 0.0;
for (int j = -win; j <= win; j++) {
for (int i = -win; i <= win; i++) {
// Centro del texel (i,j) relativo a p_floor
vec2 tap_center = p_floor + vec2(float(i), float(j)) + 0.5;
vec2 offset = tap_center - p;
float w = lanczos(offset.x, a) * lanczos(offset.y, a);
color += texture(source, tap_center / src_size) * w;
weight_sum += w;
}
}
out_color = (weight_sum > 0.0) ? (color / weight_sum) : vec4(0.0, 0.0, 0.0, 1.0);
}
+9 -9
View File
@@ -49,17 +49,17 @@ class Audio {
static void update(); // Actualización del sistema de audio static void update(); // Actualización del sistema de audio
// --- Control de música --- // --- Control de música ---
void playMusic(const std::string& name, int loop = -1, int crossfade_ms = 0); // Reproducir música por nombre (con crossfade opcional) void playMusic(const std::string& name, int loop = -1, int crossfade_ms = 0); // Reproducir música por nombre (con crossfade opcional)
void playMusic(Ja::Music* music, int loop = -1, int crossfade_ms = 0); // Reproducir música por puntero (con crossfade opcional) void playMusic(Ja::Music* music, int loop = -1, int crossfade_ms = 0); // Reproducir música por puntero (con crossfade opcional)
void pauseMusic(); // Pausar reproducción de música void pauseMusic(); // Pausar reproducción de música
void resumeMusic(); // Continua la música pausada void resumeMusic(); // Continua la música pausada
void stopMusic(); // Detener completamente la música void stopMusic(); // Detener completamente la música
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
// --- Control de sonidos --- // --- Control de sonidos ---
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual por nombre void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual por nombre
void playSound(Ja::Sound* sound, Group group = Group::GAME) const; // Reproducir sonido puntual por puntero void playSound(Ja::Sound* sound, Group group = Group::GAME) const; // Reproducir sonido puntual por puntero
void stopAllSounds() const; // Detener todos los sonidos void stopAllSounds() const; // Detener todos los sonidos
// --- Control de volumen (API interna: float 0.0..1.0) --- // --- Control de volumen (API interna: float 0.0..1.0) ---
void setSoundVolume(float volume, Group group = Group::ALL) const; // Ajustar volumen de efectos void setSoundVolume(float volume, Group group = Group::ALL) const; // Ajustar volumen de efectos
-6
View File
@@ -18,7 +18,6 @@ namespace GlobalInputs {
static bool fullscreen_prev = false; static bool fullscreen_prev = false;
static bool shader_prev = false; static bool shader_prev = false;
static bool aspect_prev = false; static bool aspect_prev = false;
static bool ss_prev = false;
static bool next_shader_prev = false; static bool next_shader_prev = false;
static bool next_preset_prev = false; static bool next_preset_prev = false;
static bool texture_filter_prev = false; static bool texture_filter_prev = false;
@@ -61,11 +60,6 @@ namespace GlobalInputs {
Screen::get()->toggleAspectRatio(); Screen::get()->toggleAspectRatio();
Overlay::showNotification(Options::video.aspect_ratio_4_3 ? Locale::get("notifications.aspect_43") : Locale::get("notifications.aspect_square")); Overlay::showNotification(Options::video.aspect_ratio_4_3 ? Locale::get("notifications.aspect_43") : Locale::get("notifications.aspect_square"));
}); });
consumed |= edgeTrigger("toggle_supersampling", ss_prev, [] {
if (Screen::get()->toggleSupersampling()) {
Overlay::showNotification(Options::video.supersampling ? Locale::get("notifications.ss_on") : Locale::get("notifications.ss_off"));
}
});
consumed |= edgeTrigger("next_shader", next_shader_prev, [] { consumed |= edgeTrigger("next_shader", next_shader_prev, [] {
if (Screen::get()->nextShaderType()) { if (Screen::get()->nextShaderType()) {
char msg[64]; char msg[64];
-5
View File
@@ -200,11 +200,6 @@ namespace Menu {
} else { Screen::get()->nextPreset(); } else { Screen::get()->nextPreset();
} }, nullptr, nullptr, [] { return Options::video.shader_enabled; }}); } }, nullptr, nullptr, [] { return Options::video.shader_enabled; }});
p.items.push_back({Locale::get("menu.items.supersampling"), ItemKind::TOGGLE, [] { return onOff(Options::video.supersampling); }, [](int) { Screen::get()->toggleSupersampling(); }, nullptr, nullptr, [] {
if (!Options::video.shader_enabled) { return false;
}
const char* name = Screen::get()->getActiveShaderName();
return name && std::string(name) == "POSTFX"; }});
#endif #endif
// Informació de render // Informació de render
-1
View File
@@ -30,7 +30,6 @@ class Screen {
// no es complia. Els callers (F-keys, menú) poden suprimir notificacions // no es complia. Els callers (F-keys, menú) poden suprimir notificacions
// o feedback quan la crida no ha tingut efecte. // o feedback quan la crida no ha tingut efecte.
void toggleShaders(); void toggleShaders();
auto toggleSupersampling() -> bool; // false si GPU off / shaders off / actiu != POSTFX
void toggleAspectRatio(); void toggleAspectRatio();
void cycleScalingMode(int dir); // Cicla DISABLED/STRETCH/LETTERBOX/OVERSCAN/INTEGER void cycleScalingMode(int dir); // Cicla DISABLED/STRETCH/LETTERBOX/OVERSCAN/INTEGER
void toggleVSync(); void toggleVSync();
File diff suppressed because it is too large Load Diff
-2
View File
@@ -16,10 +16,8 @@ namespace Defaults::KeysGame {
namespace Defaults::Video { namespace Defaults::Video {
constexpr bool GPU_ACCELERATION = true; constexpr bool GPU_ACCELERATION = true;
constexpr bool SHADER_ENABLED = false; constexpr bool SHADER_ENABLED = false;
constexpr bool SUPERSAMPLING = false;
constexpr bool VSYNC = true; constexpr bool VSYNC = true;
constexpr bool ASPECT_RATIO_4_3 = false; // CRT original estira 200→240 constexpr bool ASPECT_RATIO_4_3 = false; // CRT original estira 200→240
constexpr int DOWNSCALE_ALGO = 1; // 0=bilinear, 1=Lanczos2, 2=Lanczos3
constexpr int INTERNAL_RESOLUTION = 1; // Multiplicador enter de la textura font abans del pipeline constexpr int INTERNAL_RESOLUTION = 1; // Multiplicador enter de la textura font abans del pipeline
// TextureFilter i ScalingMode viuen a Options (requereixen #include, evitem dependència circular). // TextureFilter i ScalingMode viuen a Options (requereixen #include, evitem dependència circular).
} // namespace Defaults::Video } // namespace Defaults::Video
+2 -2
View File
@@ -43,10 +43,10 @@ namespace Scenes {
private: private:
enum class Phase : std::uint8_t { enum class Phase : std::uint8_t {
INITIAL_WAIT, // 1000 ms pantalla negra INITIAL_WAIT, // 1000 ms pantalla negra
REVEAL, // 15 passos del wordmark REVEAL, // 15 passos del wordmark
PALETTE_CYCLE, // 256 × 20 ms mutant pal[16..31] PALETTE_CYCLE, // 256 × 20 ms mutant pal[16..31]
FINAL_WAIT, // 200 ms abans de la sub-escena de sprites FINAL_WAIT, // 200 ms abans de la sub-escena de sprites
SPRITES, // tick delegat a IntroSpritesScene fins que acaba SPRITES, // tick delegat a IntroSpritesScene fins que acaba
DONE, DONE,
}; };
-3
View File
@@ -16,7 +16,6 @@ set(SHADER_SOURCES
"postfx.vert" "postfx.vert"
"postfx.frag" "postfx.frag"
"upscale.frag" "upscale.frag"
"downscale.frag"
"crtpi_frag.glsl" "crtpi_frag.glsl"
) )
@@ -25,7 +24,6 @@ set(SHADER_VARS
"kpostfx_vert_spv" "kpostfx_vert_spv"
"kpostfx_frag_spv" "kpostfx_frag_spv"
"kupscale_frag_spv" "kupscale_frag_spv"
"kdownscale_frag_spv"
"kcrtpi_frag_spv" "kcrtpi_frag_spv"
) )
@@ -34,7 +32,6 @@ set(SHADER_FLAGS
"" ""
"" ""
"" ""
""
"-fshader-stage=frag" "-fshader-stage=frag"
) )