2016-06-14 11:11:37 +00:00
|
|
|
#version 150
|
2016-04-28 20:07:05 +00:00
|
|
|
uniform sampler2D image;
|
2018-06-15 15:08:54 +00:00
|
|
|
uniform sampler2D previous_image;
|
2020-03-26 18:54:18 +00:00
|
|
|
uniform int frame_blending_mode;
|
2016-04-28 20:07:05 +00:00
|
|
|
|
2018-06-15 15:08:54 +00:00
|
|
|
uniform vec2 output_resolution;
|
|
|
|
uniform vec2 origin;
|
2016-04-28 20:07:05 +00:00
|
|
|
|
2018-06-15 16:11:06 +00:00
|
|
|
#define equal(x, y) ((x) == (y))
|
|
|
|
#define inequal(x, y) ((x) != (y))
|
2018-06-15 16:18:30 +00:00
|
|
|
#define STATIC
|
2020-06-19 20:18:38 +00:00
|
|
|
#define GAMMA (2.2)
|
2018-06-15 16:11:06 +00:00
|
|
|
|
2016-06-14 11:11:37 +00:00
|
|
|
out vec4 frag_color;
|
|
|
|
|
2020-06-19 20:18:38 +00:00
|
|
|
vec4 _texture(sampler2D t, vec2 pos)
|
|
|
|
{
|
|
|
|
return pow(texture(t, pos), vec4(GAMMA));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define texture _texture
|
|
|
|
|
2016-06-08 21:06:55 +00:00
|
|
|
#line 1
|
2016-04-28 20:07:05 +00:00
|
|
|
{filter}
|
|
|
|
|
2020-03-26 18:54:18 +00:00
|
|
|
|
2020-06-19 20:18:38 +00:00
|
|
|
#define BLEND_BIAS (2.0/5.0)
|
2020-03-26 18:54:18 +00:00
|
|
|
|
|
|
|
#define DISABLED 0
|
|
|
|
#define SIMPLE 1
|
|
|
|
#define ACCURATE 2
|
|
|
|
#define ACCURATE_EVEN ACCURATE
|
|
|
|
#define ACCURATE_ODD 3
|
|
|
|
|
2018-06-15 15:08:54 +00:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec2 position = gl_FragCoord.xy - origin;
|
|
|
|
position /= output_resolution;
|
|
|
|
position.y = 1 - position.y;
|
2018-11-14 22:21:21 +00:00
|
|
|
vec2 input_resolution = textureSize(image, 0);
|
|
|
|
|
2020-03-26 18:54:18 +00:00
|
|
|
float ratio;
|
|
|
|
switch (frame_blending_mode) {
|
|
|
|
default:
|
|
|
|
case DISABLED:
|
|
|
|
frag_color = scale(image, position, input_resolution, output_resolution);
|
|
|
|
return;
|
|
|
|
case SIMPLE:
|
|
|
|
ratio = 0.5;
|
|
|
|
break;
|
|
|
|
case ACCURATE_EVEN:
|
|
|
|
if ((int(position.y * input_resolution.y) & 1) == 0) {
|
|
|
|
ratio = BLEND_BIAS;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ratio = 1 - BLEND_BIAS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACCURATE_ODD:
|
|
|
|
if ((int(position.y * input_resolution.y) & 1) == 0) {
|
|
|
|
ratio = 1 - BLEND_BIAS;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ratio = BLEND_BIAS;
|
|
|
|
}
|
|
|
|
break;
|
2016-04-28 20:07:05 +00:00
|
|
|
}
|
2020-03-26 18:54:18 +00:00
|
|
|
|
2020-06-19 20:18:38 +00:00
|
|
|
frag_color = pow(mix(scale(image, position, input_resolution, output_resolution),
|
|
|
|
scale(previous_image, position, input_resolution, output_resolution), ratio), vec4(1.0 / GAMMA));
|
2020-03-26 18:54:18 +00:00
|
|
|
|
2018-06-15 15:08:54 +00:00
|
|
|
}
|