2023-04-29 13:20:58 +10:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
// Simple scanlines with curvature and mask effects lifted from crt-geom
|
|
|
|
// original by hunterk, edited by DariusG
|
|
|
|
|
|
|
|
layout(push_constant) uniform Push
|
|
|
|
{
|
|
|
|
vec4 SourceSize;
|
|
|
|
vec4 OriginalSize;
|
|
|
|
vec4 OutputSize;
|
|
|
|
uint FrameCount;
|
|
|
|
float SCANLINE;
|
|
|
|
float cgwg;
|
|
|
|
float boost;
|
|
|
|
} params;
|
|
|
|
|
|
|
|
// Parameter lines go here:
|
|
|
|
|
|
|
|
#pragma parameter boost "Bright boost " 1.00 1.00 2.00 0.02
|
|
|
|
#define boost params.boost
|
|
|
|
|
2023-05-13 12:42:31 +10:00
|
|
|
#pragma parameter SCANLINE "Scanline Intensity" 0.70 0.0 1.0 0.05
|
2023-04-29 13:20:58 +10:00
|
|
|
#define SCANLINE params.SCANLINE
|
|
|
|
|
2023-05-13 12:42:31 +10:00
|
|
|
#pragma parameter cgwg "Mask Intensity " 0.8 0.0 1.0 0.05
|
2023-04-29 13:20:58 +10:00
|
|
|
#define cgwg params.cgwg
|
|
|
|
|
2023-05-13 12:42:31 +10:00
|
|
|
|
2023-04-29 13:20:58 +10:00
|
|
|
#define pi 3.141592654
|
|
|
|
|
|
|
|
layout(std140, set = 0, binding = 0) uniform UBO
|
|
|
|
{
|
|
|
|
mat4 MVP;
|
|
|
|
} global;
|
|
|
|
|
|
|
|
#pragma stage vertex
|
|
|
|
layout(location = 0) in vec4 Position;
|
|
|
|
layout(location = 1) in vec2 TexCoord;
|
|
|
|
layout(location = 0) out vec2 vTexCoord;
|
2023-05-13 12:42:31 +10:00
|
|
|
layout(location = 1) out vec2 p;
|
2023-04-29 13:20:58 +10:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
gl_Position = global.MVP * Position;
|
|
|
|
vTexCoord = TexCoord * 1.0001;
|
2023-05-13 12:42:31 +10:00
|
|
|
p = vTexCoord * params.SourceSize.xy;
|
2023-04-29 13:20:58 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma stage fragment
|
|
|
|
layout(location = 0) in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 FragColor;
|
2023-05-13 12:42:31 +10:00
|
|
|
layout(location = 1) in vec2 p;
|
|
|
|
|
2023-04-29 13:20:58 +10:00
|
|
|
layout(set = 0, binding = 1) uniform sampler2D Source;
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec2 pos = vTexCoord.xy;
|
2023-05-13 12:42:31 +10:00
|
|
|
|
2023-04-29 13:20:58 +10:00
|
|
|
vec3 res = texture(Source, pos).rgb;
|
|
|
|
|
2023-05-13 12:42:31 +10:00
|
|
|
res *=res;
|
|
|
|
res *= SCANLINE * sin(fract(p.y)*pi) +(1.0-SCANLINE);
|
2023-04-29 13:20:58 +10:00
|
|
|
|
|
|
|
// apply the mask
|
2023-05-13 12:42:31 +10:00
|
|
|
res *= cgwg * sin(fract(pos.x*0.5*params.OutputSize.x)*pi) +(1.0-cgwg);
|
|
|
|
res = sqrt(res);
|
2023-04-29 13:20:58 +10:00
|
|
|
res *= boost;
|
|
|
|
|
|
|
|
FragColor = vec4(res,1.0);
|
|
|
|
}
|