2016-07-15 00:46:04 +10:00
|
|
|
#version 450
|
|
|
|
|
2016-08-03 04:16:51 +10:00
|
|
|
layout(push_constant) uniform Push
|
|
|
|
{
|
|
|
|
vec4 OutputSize;
|
|
|
|
vec4 OriginalSize;
|
|
|
|
vec4 SourceSize;
|
|
|
|
uint FrameCount;
|
|
|
|
float percent;
|
|
|
|
float enable_480i;
|
|
|
|
float top_field_first;
|
|
|
|
} registers;
|
|
|
|
|
2016-07-15 00:46:04 +10:00
|
|
|
layout(std140, set = 0, binding = 0) uniform UBO
|
|
|
|
{
|
|
|
|
mat4 MVP;
|
|
|
|
} global;
|
|
|
|
|
2016-08-03 04:16:51 +10:00
|
|
|
#pragma parameter percent "Interlacing Scanline Bright %" 0.0 0.0 1.0 0.05
|
|
|
|
#pragma parameter enable_480i "Enable 480i Mode" 1.0 0.0 1.0 1.0
|
|
|
|
#pragma parameter top_field_first "Top Field First Enable" 0.0 0.0 1.0 1.0
|
2016-07-15 00:46:04 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
Interlacing
|
|
|
|
Author: hunterk
|
|
|
|
License: Public domain
|
|
|
|
|
|
|
|
Note: This shader is designed to work with the typical interlaced output from an emulator, which displays both even and odd fields twice.
|
|
|
|
This shader will un-weave the image, resulting in a standard, alternating-field interlacing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma stage vertex
|
|
|
|
layout(location = 0) in vec4 Position;
|
|
|
|
layout(location = 1) in vec2 TexCoord;
|
|
|
|
layout(location = 0) out vec2 vTexCoord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = global.MVP * Position;
|
|
|
|
vTexCoord = TexCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma stage fragment
|
|
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 FragColor;
|
|
|
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 res = texture(Source, vTexCoord).rgba;
|
|
|
|
float y = 0.0;
|
2016-08-03 04:16:51 +10:00
|
|
|
float tick = registers.FrameCount;
|
2016-07-15 00:46:04 +10:00
|
|
|
|
|
|
|
// assume anything with a vertical resolution greater than 400 lines is interlaced
|
2016-08-03 04:16:51 +10:00
|
|
|
if (registers.SourceSize.y > 400.0)
|
|
|
|
{y = registers.SourceSize.y * vTexCoord.y + (tick * registers.enable_480i) + registers.top_field_first;}
|
2016-07-15 00:46:04 +10:00
|
|
|
else
|
2018-03-21 12:28:08 +11:00
|
|
|
{y = 2.000001 * registers.SourceSize.y * vTexCoord.y + registers.top_field_first;}
|
2016-07-15 00:46:04 +10:00
|
|
|
|
2016-07-20 07:18:36 +10:00
|
|
|
if (mod(y, 1.99999) > 0.99999)
|
|
|
|
{res = res;}
|
2016-07-15 00:46:04 +10:00
|
|
|
else
|
2016-08-03 04:16:51 +10:00
|
|
|
{res = vec4(registers.percent) * res;}
|
2016-07-20 07:18:36 +10:00
|
|
|
FragColor = res;
|
2018-03-21 12:28:08 +11:00
|
|
|
}
|