diff --git a/shaders/effects/noise_crossfade.f.glsl b/shaders/effects/noise_crossfade.f.glsl new file mode 100644 index 0000000..903e332 --- /dev/null +++ b/shaders/effects/noise_crossfade.f.glsl @@ -0,0 +1,35 @@ +/* Copyright (C) 2022 kichikuou + * + * 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 . + */ + +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; + +void main() { + float rand = fract(sin(dot(vec3(tex_coord, progress), vec3(12.9898, 78.233, 81.2463))) * 43758.5453); + + vec3 col; + if (progress < 0.5) { + col = mix(texture(old, tex_coord).rgb, vec3(rand), progress * 2.0); + } else { + col = mix(texture(tex, tex_coord).rgb, vec3(rand), (1.0 - progress) * 2.0); + } + frag_color = vec4(col, 1.0); +} diff --git a/shaders/effects/sepia_noise_crossfade.f.glsl b/shaders/effects/sepia_noise_crossfade.f.glsl new file mode 100644 index 0000000..cbc8307 --- /dev/null +++ b/shaders/effects/sepia_noise_crossfade.f.glsl @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 kichikuou + * + * 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 . + */ + +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; + +void main() { + float rand = fract(sin(dot(vec3(tex_coord, progress), vec3(12.9898, 78.233, 81.2463))) * 43758.5453); + vec3 sepia = rand * vec3(1.0, 0.888, 0.691); + + vec3 col; + if (progress < 0.5) { + col = mix(texture(old, tex_coord).rgb, sepia, progress * 2.0); + } else { + col = mix(texture(tex, tex_coord).rgb, sepia, (1.0 - progress) * 2.0); + } + frag_color = vec4(col, 1.0); +} diff --git a/src/effect.c b/src/effect.c index fdf5bf1..ba49b95 100644 --- a/src/effect.c +++ b/src/effect.c @@ -138,7 +138,9 @@ static struct effect_shader blind_down_shader = EFFECT_SHADER("shaders/effects/b static struct effect_shader blind_lr_shader = EFFECT_SHADER("shaders/effects/blind_lr.f.glsl"); static struct effect_shader linear_blur_shader = EFFECT_SHADER("shaders/effects/linear_blur.f.glsl"); static struct effect_shader zigzag_crossfade_shader = EFFECT_SHADER("shaders/effects/zigzag_crossfade.f.glsl"); +static struct effect_shader noise_crossfade_shader = EFFECT_SHADER("shaders/effects/noise_crossfade.f.glsl"); static struct effect_shader turn_page_shader = EFFECT_SHADER("shaders/effects/turn_page.f.glsl"); +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"); @@ -153,7 +155,9 @@ static struct effect_shader *effect_shaders[NR_EFFECTS] = { [EFFECT_BLIND_LR] = &blind_lr_shader, [EFFECT_LINEAR_BLUR] = &linear_blur_shader, [EFFECT_ZIGZAG_CROSSFADE] = &zigzag_crossfade_shader, + [EFFECT_NOISE_CROSSFADE] = &noise_crossfade_shader, [EFFECT_TURN_PAGE] = &turn_page_shader, + [EFFECT_SEPIA_NOISE_CROSSFADE] = &sepia_noise_crossfade_shader, [EFFECT_BLUR_FADEOUT] = &blur_fadeout_shader, [EFFECT_BLUR_CROSSFADE] = &blur_crossfade_shader, };