Implement effect number 60

Used in Rance Quest.
This commit is contained in:
kichikuou
2025-03-23 08:22:16 +09:00
parent 33403cbd3d
commit 7ff5ec89e7
3 changed files with 51 additions and 2 deletions
+1
View File
@@ -72,6 +72,7 @@ enum effect {
EFFECT_BLUR_FADEOUT = 50,
EFFECT_BLUR_CROSSFADE = 51,
EFFECT_2ROT_ZOOM_BLEND_BLUR = 52,
EFFECT_VWAVE_CROSSFADE = 60,
NR_EFFECTS
};
+39
View File
@@ -0,0 +1,39 @@
/* Copyright (C) 2019 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;
vec3 get_pixel(vec2 xy) {
return mix(texture(old, xy).rgb, texture(tex, xy).rgb, progress);
}
float triangle(float f) {
return 1.0 - abs(f * 2.0 - 1.0);
}
void main() {
vec2 p = tex_coord * resolution;
float scale = triangle(progress) * 80.0; // (0..0.5..1) -> (0..80..0);
float wobble = progress * 24.0;
float offset = sin((p.y / 100.0) - wobble) * scale;
frag_color = vec4(get_pixel(fract(vec2(p.x + offset, p.y) / resolution)), 1.0);
}
+11 -2
View File
@@ -75,6 +75,7 @@ const char *effect_names[NR_EFFECTS] = {
[EFFECT_BLUR_FADEOUT] = "EFFECT_BLUR_FADEOUT",
[EFFECT_BLUR_CROSSFADE] = "EFFECT_BLUR_CROSSFADE",
[EFFECT_2ROT_ZOOM_BLEND_BLUR] = "EFFECT_2ROT_ZOOM_BLEND_BLUR",
[EFFECT_VWAVE_CROSSFADE] = "EFFECT_VWAVE_CROSSFADE",
};
struct effect_shader {
@@ -153,6 +154,7 @@ static struct effect_shader turn_page_shader = EFFECT_SHADER("shaders/effects/tu
static struct effect_shader sepia_noise_crossfade_shader = EFFECT_SHADER("shaders/effects/sepia_noise_crossfade.f.glsl");
static struct effect_shader blur_fadeout_shader = EFFECT_SHADER("shaders/effects/blur_fadeout.f.glsl");
static struct effect_shader blur_crossfade_shader = EFFECT_SHADER("shaders/effects/blur_crossfade.f.glsl");
static struct effect_shader vwave_crossfade_shader = EFFECT_SHADER("shaders/effects/vwave_crossfade.f.glsl");
static struct effect_shader *effect_shaders[NR_EFFECTS] = {
[EFFECT_CROSSFADE] = &crossfade_shader,
@@ -168,6 +170,7 @@ static struct effect_shader *effect_shaders[NR_EFFECTS] = {
[EFFECT_SEPIA_NOISE_CROSSFADE] = &sepia_noise_crossfade_shader,
[EFFECT_BLUR_FADEOUT] = &blur_fadeout_shader,
[EFFECT_BLUR_CROSSFADE] = &blur_crossfade_shader,
[EFFECT_VWAVE_CROSSFADE] = &vwave_crossfade_shader,
};
static void effect_fadeout(Texture *dst, Texture *old, Texture *new, float rate)
@@ -274,7 +277,10 @@ void effect_update_texture(int type, Texture *dst, Texture *old, Texture *new, f
} else {
struct effect_shader *s = effect_shaders[type];
if (!s) {
WARNING("Unimplemented effect: %s", effect_names[type]);
if (effect_names[type])
WARNING("Unimplemented effect: %s", effect_names[type]);
else
WARNING("Unimplemented effect: %d", type);
s = effect_shaders[EFFECT_BLUR_CROSSFADE];
}
if (!s->s.program)
@@ -296,7 +302,10 @@ int effect_init(enum effect type)
else {
struct effect_shader *s = effect_shaders[type];
if (!s) {
WARNING("Unimplemented effect: %s", effect_names[type]);
if (effect_names[type])
WARNING("Unimplemented effect: %s", effect_names[type]);
else
WARNING("Unimplemented effect: %d", type);
type = EFFECT_BLUR_CROSSFADE;
s = effect_shaders[type];
}