SameBoy/Shaders/MasterShader.fsh

34 lines
822 B
Plaintext
Raw Normal View History

#version 150
uniform sampler2D image;
2018-06-15 15:08:54 +00:00
uniform sampler2D previous_image;
uniform bool mix_previous;
2018-06-15 15:08:54 +00:00
uniform vec2 output_resolution;
uniform vec2 origin;
const vec2 input_resolution = vec2(160, 144);
2018-06-15 16:11:06 +00:00
#define equal(x, y) ((x) == (y))
#define inequal(x, y) ((x) != (y))
#define STATIC
2018-06-15 16:11:06 +00:00
out vec4 frag_color;
#line 1
{filter}
2018-06-15 15:08:54 +00:00
void main()
{
vec2 position = gl_FragCoord.xy - origin;
position /= output_resolution;
position.y = 1 - position.y;
vec2 input_resolution = textureSize(image, 0);
2018-06-15 15:08:54 +00:00
if (mix_previous) {
2018-06-15 15:22:09 +00:00
frag_color = mix(scale(image, position, input_resolution, output_resolution),
scale(previous_image, position, input_resolution, output_resolution), 0.5);
}
else {
2018-06-15 15:22:09 +00:00
frag_color = scale(image, position, input_resolution, output_resolution);
}
2018-06-15 15:08:54 +00:00
}