forked from jaildesigner-jailgames/jaildoctors_dilemma
postfx subpixel
This commit is contained in:
@@ -338,9 +338,10 @@ auto OpenGLShader::init(SDL_Window* window,
|
||||
}
|
||||
|
||||
// Uniforms PostFX
|
||||
vignette_location_ = glGetUniformLocation(program_id_, "uVignette");
|
||||
scanlines_location_ = glGetUniformLocation(program_id_, "uScanlines");
|
||||
chroma_location_ = glGetUniformLocation(program_id_, "uChroma");
|
||||
vignette_location_ = glGetUniformLocation(program_id_, "uVignette");
|
||||
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_); }
|
||||
@@ -446,6 +447,10 @@ void OpenGLShader::render() {
|
||||
glViewport(viewport_x, viewport_y, viewport_w, viewport_h);
|
||||
checkGLError("glViewport");
|
||||
|
||||
if (output_height_location_ != -1) {
|
||||
glUniform1f(output_height_location_, static_cast<float>(viewport_h));
|
||||
}
|
||||
|
||||
// Dibujar quad usando VAO
|
||||
glBindVertexArray(vao_);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
|
||||
|
||||
@@ -59,6 +59,7 @@ class OpenGLShader : public ShaderBackend {
|
||||
GLint vignette_location_ = -1;
|
||||
GLint scanlines_location_ = -1;
|
||||
GLint chroma_location_ = -1;
|
||||
GLint output_height_location_ = -1;
|
||||
|
||||
// Valores cacheados de PostFX
|
||||
float postfx_vignette_ = 0.6F;
|
||||
|
||||
@@ -61,7 +61,12 @@ fragment float4 postfx_fs(PostVOut in [[stage_in]],
|
||||
color.b = scene.sample(samp, in.uv - float2( ca, 0.0)).b;
|
||||
color.a = scene.sample(samp, in.uv).a;
|
||||
|
||||
float scan = 0.85 + 0.15 * sin(in.uv.y * 3.14159265 * u.screen_height);
|
||||
float texHeight = float(scene.get_height());
|
||||
float scaleY = u.screen_height / texHeight;
|
||||
float screenY = in.uv.y * u.screen_height;
|
||||
float posInRow = fmod(screenY, scaleY);
|
||||
float scanLineDY = posInRow / scaleY - 0.5;
|
||||
float scan = max(1.0 - scanLineDY * scanLineDY * 6.0, 0.12) * 3.5;
|
||||
color.rgb *= mix(1.0, scan, u.scanline_strength);
|
||||
|
||||
float2 d = in.uv - float2(0.5, 0.5);
|
||||
@@ -312,6 +317,8 @@ void SDL3GPUShader::render() {
|
||||
return;
|
||||
}
|
||||
|
||||
uniforms_.screen_height = static_cast<float>(sh);
|
||||
|
||||
// ---- Render pass: PostFX → swapchain ----
|
||||
SDL_GPUColorTargetInfo color_target = {};
|
||||
color_target.texture = swapchain;
|
||||
|
||||
Reference in New Issue
Block a user