Files
nunuhara_xsystem4/shaders/effects/crossfade_down_up.f.glsl
T
Nunuhara Cabbage e76762d11d Implement EFFECT_DOWN_UP_CROSSFADE
Used in Rance 9 (when Hunty disappears).
2026-08-14 21:51:11 -07:00

37 lines
1.4 KiB
GLSL

/* Copyright (C) 2026 Nunuhara Cabbage <nunuhara@haniwa.technology>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
uniform sampler2D tex; // the new scene
uniform sampler2D old; // the old scene
uniform vec2 resolution; // the screen resolution
uniform float progress; // effect progress (0..1)
in vec2 tex_coord;
out vec4 frag_color;
#define EFFECT_HEIGHT 210.0
void main() {
// start position of effect
float top = ((resolution.y + EFFECT_HEIGHT) * (1.0 - progress)) - EFFECT_HEIGHT;
// current pixel y-coordinate
float p = tex_coord.y * resolution.y;
// calculate alpha value
float alpha = 1.0 - clamp((p - top) / EFFECT_HEIGHT, 0.0, 1.0);
vec3 col = mix(texture(tex, tex_coord).rgb, texture(old, tex_coord).rgb, alpha);
frag_color = vec4(col, 1.0);
}