nous postfx

This commit is contained in:
2026-03-21 15:14:31 +01:00
parent 06457654f4
commit aa292dcd92
13 changed files with 583 additions and 258 deletions

View File

@@ -342,9 +342,17 @@ auto OpenGLShader::init(SDL_Window* window,
scanlines_location_ = glGetUniformLocation(program_id_, "uScanlines");
chroma_location_ = glGetUniformLocation(program_id_, "uChroma");
output_height_location_ = glGetUniformLocation(program_id_, "uOutputHeight");
if (vignette_location_ != -1) { glUniform1f(vignette_location_, postfx_vignette_); }
if (scanlines_location_ != -1) { glUniform1f(scanlines_location_, postfx_scanlines_); }
if (chroma_location_ != -1) { glUniform1f(chroma_location_, postfx_chroma_); }
mask_location_ = glGetUniformLocation(program_id_, "uMask");
gamma_location_ = glGetUniformLocation(program_id_, "uGamma");
curvature_location_ = glGetUniformLocation(program_id_, "uCurvature");
bleeding_location_ = glGetUniformLocation(program_id_, "uBleeding");
if (vignette_location_ != -1) { glUniform1f(vignette_location_, postfx_vignette_); }
if (scanlines_location_ != -1) { glUniform1f(scanlines_location_, postfx_scanlines_); }
if (chroma_location_ != -1) { glUniform1f(chroma_location_, postfx_chroma_); }
if (mask_location_ != -1) { glUniform1f(mask_location_, postfx_mask_); }
if (gamma_location_ != -1) { glUniform1f(gamma_location_, postfx_gamma_); }
if (curvature_location_ != -1) { glUniform1f(curvature_location_, postfx_curvature_); }
if (bleeding_location_ != -1) { glUniform1f(bleeding_location_, postfx_bleeding_); }
glUseProgram(0);
is_initialized_ = true;
@@ -400,9 +408,13 @@ void OpenGLShader::render() {
checkGLError("glUseProgram");
// Pasar uniforms PostFX
if (vignette_location_ != -1) { glUniform1f(vignette_location_, postfx_vignette_); }
if (scanlines_location_ != -1) { glUniform1f(scanlines_location_, postfx_scanlines_); }
if (chroma_location_ != -1) { glUniform1f(chroma_location_, postfx_chroma_); }
if (vignette_location_ != -1) { glUniform1f(vignette_location_, postfx_vignette_); }
if (scanlines_location_ != -1) { glUniform1f(scanlines_location_, postfx_scanlines_); }
if (chroma_location_ != -1) { glUniform1f(chroma_location_, postfx_chroma_); }
if (mask_location_ != -1) { glUniform1f(mask_location_, postfx_mask_); }
if (gamma_location_ != -1) { glUniform1f(gamma_location_, postfx_gamma_); }
if (curvature_location_ != -1) { glUniform1f(curvature_location_, postfx_curvature_); }
if (bleeding_location_ != -1) { glUniform1f(bleeding_location_, postfx_bleeding_); }
// Configurar viewport (obtener tamaño lógico de SDL)
int logical_w;
@@ -469,10 +481,14 @@ void OpenGLShader::render() {
glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);
}
void OpenGLShader::setPostFXParams(float vignette, float scanlines, float chroma) {
postfx_vignette_ = vignette;
postfx_scanlines_ = scanlines;
postfx_chroma_ = chroma;
void OpenGLShader::setPostFXParams(const PostFXParams& p) {
postfx_vignette_ = p.vignette;
postfx_scanlines_ = p.scanlines;
postfx_chroma_ = p.chroma;
postfx_mask_ = p.mask;
postfx_gamma_ = p.gamma;
postfx_curvature_ = p.curvature;
postfx_bleeding_ = p.bleeding;
}
void OpenGLShader::setTextureSize(float width, float height) {

View File

@@ -30,7 +30,7 @@ class OpenGLShader : public ShaderBackend {
void render() override;
void setTextureSize(float width, float height) override;
void setPostFXParams(float vignette, float scanlines, float chroma) override;
void setPostFXParams(const PostFXParams& p) override;
void cleanup() final;
[[nodiscard]] auto isHardwareAccelerated() const -> bool override { return is_initialized_; }
@@ -60,11 +60,19 @@ class OpenGLShader : public ShaderBackend {
GLint scanlines_location_ = -1;
GLint chroma_location_ = -1;
GLint output_height_location_ = -1;
GLint mask_location_ = -1;
GLint gamma_location_ = -1;
GLint curvature_location_ = -1;
GLint bleeding_location_ = -1;
// Valores cacheados de PostFX
float postfx_vignette_ = 0.6F;
float postfx_scanlines_ = 0.7F;
float postfx_chroma_ = 0.15F;
float postfx_mask_ = 0.0F;
float postfx_gamma_ = 0.0F;
float postfx_curvature_ = 0.0F;
float postfx_bleeding_ = 0.0F;
// Tamaños
int window_width_ = 0;