feat(postfx): toggle F6 per activar/desactivar el postprocessat
This commit is contained in:
@@ -40,6 +40,7 @@ Input::Input(std::string game_controller_db_path)
|
|||||||
{Action::TOGGLE_FULLSCREEN, KeyState{.scancode = SDL_SCANCODE_F3}},
|
{Action::TOGGLE_FULLSCREEN, KeyState{.scancode = SDL_SCANCODE_F3}},
|
||||||
{Action::TOGGLE_VSYNC, KeyState{.scancode = SDL_SCANCODE_F4}},
|
{Action::TOGGLE_VSYNC, KeyState{.scancode = SDL_SCANCODE_F4}},
|
||||||
{Action::TOGGLE_ANTIALIAS, KeyState{.scancode = SDL_SCANCODE_F5}},
|
{Action::TOGGLE_ANTIALIAS, KeyState{.scancode = SDL_SCANCODE_F5}},
|
||||||
|
{Action::TOGGLE_POSTFX, KeyState{.scancode = SDL_SCANCODE_F6}},
|
||||||
{Action::EXIT, KeyState{.scancode = SDL_SCANCODE_ESCAPE}}};
|
{Action::EXIT, KeyState{.scancode = SDL_SCANCODE_ESCAPE}}};
|
||||||
|
|
||||||
initSDLGamePad(); // Inicializa el subsistema SDL_INIT_GAMEPAD
|
initSDLGamePad(); // Inicializa el subsistema SDL_INIT_GAMEPAD
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ enum class InputAction : std::uint8_t { // Acciones de entrada posibles en el j
|
|||||||
TOGGLE_FULLSCREEN, // F3
|
TOGGLE_FULLSCREEN, // F3
|
||||||
TOGGLE_VSYNC, // F4
|
TOGGLE_VSYNC, // F4
|
||||||
TOGGLE_ANTIALIAS, // F5
|
TOGGLE_ANTIALIAS, // F5
|
||||||
|
TOGGLE_POSTFX, // F6
|
||||||
EXIT, // ESC
|
EXIT, // ESC
|
||||||
|
|
||||||
// Input obligatorio
|
// Input obligatorio
|
||||||
|
|||||||
@@ -425,10 +425,10 @@ namespace Rendering::GPU {
|
|||||||
render_pass_ = nullptr;
|
render_pass_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si el bloom està desactivat, fem clear a negre sobre bloom_b perquè
|
// Si el bloom està desactivat (per config o per l'interruptor mestre
|
||||||
// el composite el samplegi com a "sense bloom" sense haver de tenir un
|
// F6), fem clear a negre sobre bloom_b perquè el composite el samplegi
|
||||||
// path alternatiu al shader.
|
// com a "sense bloom" sense haver de tenir un path alternatiu al shader.
|
||||||
const bool BLOOM_ON = postfx_params_.bloom_enabled;
|
const bool BLOOM_ON = postfx_enabled_ && postfx_params_.bloom_enabled;
|
||||||
const float TEXEL_X = 1.0F / render_w_;
|
const float TEXEL_X = 1.0F / render_w_;
|
||||||
const float TEXEL_Y = 1.0F / render_h_;
|
const float TEXEL_Y = 1.0F / render_h_;
|
||||||
const float SIGMA = postfx_params_.bloom_sigma_px;
|
const float SIGMA = postfx_params_.bloom_sigma_px;
|
||||||
@@ -561,18 +561,20 @@ namespace Rendering::GPU {
|
|||||||
// Uniforms del postpro. Si una sección está desactivada, anulamos sus
|
// Uniforms del postpro. Si una sección está desactivada, anulamos sus
|
||||||
// contribuciones (intensidad / amplitud / max=min) en lugar de tener
|
// contribuciones (intensidad / amplitud / max=min) en lugar de tener
|
||||||
// un branch en el shader.
|
// un branch en el shader.
|
||||||
const float BLOOM_INTENSITY = postfx_params_.bloom_enabled
|
// L'interruptor mestre (postfx_enabled_) gateja totes les seccions: si
|
||||||
? postfx_params_.bloom_intensity
|
// està OFF (F6), tot queda anul·lat i el composite és passthrough de
|
||||||
: 0.0F;
|
// l'escena offscreen.
|
||||||
const float FLICKER_AMPLITUDE = postfx_params_.flicker_enabled
|
const bool BLOOM_ON = postfx_enabled_ && postfx_params_.bloom_enabled;
|
||||||
? postfx_params_.flicker_amplitude
|
const bool FLICKER_ON = postfx_enabled_ && postfx_params_.flicker_enabled;
|
||||||
: 0.0F;
|
const bool BG_ON = postfx_enabled_ && postfx_params_.background_enabled;
|
||||||
const float BG_MIN_R = postfx_params_.background_enabled ? postfx_params_.background_min_r : 0.0F;
|
const float BLOOM_INTENSITY = BLOOM_ON ? postfx_params_.bloom_intensity : 0.0F;
|
||||||
const float BG_MIN_G = postfx_params_.background_enabled ? postfx_params_.background_min_g : 0.0F;
|
const float FLICKER_AMPLITUDE = FLICKER_ON ? postfx_params_.flicker_amplitude : 0.0F;
|
||||||
const float BG_MIN_B = postfx_params_.background_enabled ? postfx_params_.background_min_b : 0.0F;
|
const float BG_MIN_R = BG_ON ? postfx_params_.background_min_r : 0.0F;
|
||||||
const float BG_MAX_R = postfx_params_.background_enabled ? postfx_params_.background_max_r : 0.0F;
|
const float BG_MIN_G = BG_ON ? postfx_params_.background_min_g : 0.0F;
|
||||||
const float BG_MAX_G = postfx_params_.background_enabled ? postfx_params_.background_max_g : 0.0F;
|
const float BG_MIN_B = BG_ON ? postfx_params_.background_min_b : 0.0F;
|
||||||
const float BG_MAX_B = postfx_params_.background_enabled ? postfx_params_.background_max_b : 0.0F;
|
const float BG_MAX_R = BG_ON ? postfx_params_.background_max_r : 0.0F;
|
||||||
|
const float BG_MAX_G = BG_ON ? postfx_params_.background_max_g : 0.0F;
|
||||||
|
const float BG_MAX_B = BG_ON ? postfx_params_.background_max_b : 0.0F;
|
||||||
|
|
||||||
// Tiempo en segundos desde el inicio de SDL (wall-clock real, robusto a FPS variables).
|
// Tiempo en segundos desde el inicio de SDL (wall-clock real, robusto a FPS variables).
|
||||||
const float TIME_SECONDS = static_cast<float>(SDL_GetTicks()) / 1000.0F;
|
const float TIME_SECONDS = static_cast<float>(SDL_GetTicks()) / 1000.0F;
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ namespace Rendering::GPU {
|
|||||||
void setPostFx(const PostFxParams& params) { postfx_params_ = params; }
|
void setPostFx(const PostFxParams& params) { postfx_params_ = params; }
|
||||||
[[nodiscard]] auto postfx() const -> const PostFxParams& { return postfx_params_; }
|
[[nodiscard]] auto postfx() const -> const PostFxParams& { return postfx_params_; }
|
||||||
|
|
||||||
|
// Interruptor mestre del postpro (F6). Quan està OFF, ni bloom ni
|
||||||
|
// flicker ni background pulse afecten el frame — l'escena offscreen
|
||||||
|
// surt tal com s'ha renderitzat (passthrough). Útil per A/B testing.
|
||||||
|
void setPostFxEnabled(bool enabled) { postfx_enabled_ = enabled; }
|
||||||
|
[[nodiscard]] auto isPostFxEnabled() const -> bool { return postfx_enabled_; }
|
||||||
|
|
||||||
// Acceso a internals.
|
// Acceso a internals.
|
||||||
[[nodiscard]] auto device() -> GpuDevice& { return device_; }
|
[[nodiscard]] auto device() -> GpuDevice& { return device_; }
|
||||||
[[nodiscard]] auto isInsideFrame() const -> bool { return cmd_buffer_ != nullptr; }
|
[[nodiscard]] auto isInsideFrame() const -> bool { return cmd_buffer_ != nullptr; }
|
||||||
@@ -173,6 +179,10 @@ namespace Rendering::GPU {
|
|||||||
// Estat de l'antialias geomètric a les línies (toggle F5).
|
// Estat de l'antialias geomètric a les línies (toggle F5).
|
||||||
bool antialias_enabled_{true};
|
bool antialias_enabled_{true};
|
||||||
|
|
||||||
|
// Interruptor mestre del postpro (toggle F6). Quan és false, bloom +
|
||||||
|
// flicker + background pulse queden anul·lats (passthrough de l'escena).
|
||||||
|
bool postfx_enabled_{true};
|
||||||
|
|
||||||
// Helpers internos.
|
// Helpers internos.
|
||||||
[[nodiscard]] auto createOffscreen() -> bool;
|
[[nodiscard]] auto createOffscreen() -> bool;
|
||||||
void destroyOffscreen();
|
void destroyOffscreen();
|
||||||
|
|||||||
@@ -377,3 +377,13 @@ void SDLManager::toggleAntialias() {
|
|||||||
notifier->notifyInfo(cfg_->rendering.antialias != 0 ? "AA ACTIU" : "AA INACTIU");
|
notifier->notifyInfo(cfg_->rendering.antialias != 0 ? "AA ACTIU" : "AA INACTIU");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLManager::togglePostFx() {
|
||||||
|
const bool NEW_STATE = !gpu_renderer_.isPostFxEnabled();
|
||||||
|
gpu_renderer_.setPostFxEnabled(NEW_STATE);
|
||||||
|
// No persistim: el toggle és per A/B testing visual, l'estat per defecte
|
||||||
|
// del joc continua sent "postfx ON" segons defaults/YAML.
|
||||||
|
if (auto* notifier = System::Notifier::get(); notifier != nullptr) {
|
||||||
|
notifier->notifyInfo(NEW_STATE ? "POSTPROCESSAT ACTIU" : "POSTPROCESSAT INACTIU");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class SDLManager {
|
|||||||
void toggleFullscreen(); // F3
|
void toggleFullscreen(); // F3
|
||||||
void toggleVSync(); // F4
|
void toggleVSync(); // F4
|
||||||
void toggleAntialias(); // F5
|
void toggleAntialias(); // F5
|
||||||
|
void togglePostFx(); // F6
|
||||||
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
||||||
|
|
||||||
// Funciones principals (renderizado).
|
// Funciones principals (renderizado).
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ namespace GlobalEvents {
|
|||||||
sdl.toggleAntialias();
|
sdl.toggleAntialias();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_F6:
|
||||||
|
sdl.togglePostFx();
|
||||||
|
return true;
|
||||||
|
|
||||||
case SDL_SCANCODE_ESCAPE: {
|
case SDL_SCANCODE_ESCAPE: {
|
||||||
// Doble pulsació per confirmar sortida: la primera ESC
|
// Doble pulsació per confirmar sortida: la primera ESC
|
||||||
// dispara un toast d'avís; només si aquest toast concret
|
// dispara un toast d'avís; només si aquest toast concret
|
||||||
|
|||||||
Reference in New Issue
Block a user