(crtglow) Translated the glow set of shaders and their associated

presets.
This commit is contained in:
Arzed Five 2016-07-21 03:01:53 +01:00
parent 41769642e4
commit efd79721cb
12 changed files with 535 additions and 0 deletions

View File

@ -0,0 +1,38 @@
shaders = 7
shader0 = shaders/glow/linearize.slang
filter_linear0 = false
srgb_framebuffer0 = true
shader1 = shaders/glow/gauss_horiz.slang
filter_linear1 = false
scale_type_x1 = viewport
scale_type_y1 = source
scale_x0 = 1.0
scale_y0 = 1.0
srgb_framebuffer1 = true
shader2 = shaders/glow/gauss_vert.slang
filter_linear2 = false
scale_type2 = viewport
scale2 = 1.0
srgb_framebuffer2 = true
shader3 = shaders/glow/threshold.slang
filter_linear3 = false
srgb_framebuffer3 = true
shader4 = shaders/glow/blur_horiz.slang
mipmap_input4 = true
filter_linear4 = true
scale_type4 = source
scale4 = 0.25
srgb_framebuffer4 = true
shader5 = shaders/glow/blur_vert.slang
filter_linear5 = true
srgb_framebuffer5 = true
shader6 = shaders/glow/resolve.slang
filter_linear6 = true

View File

@ -0,0 +1,49 @@
shaders = 8
shader0 = ../ntsc/shaders/ntsc-pass1-composite-3phase.slang
filter_linear0 = false
scale_type0 = source
scale_x0 = 4.0
scale_y0 = 1.0
frame_count_mod0 = 2
float_framebuffer0 = true
shader1 = ../ntsc/shaders/ntsc-pass2-3phase-linear.slang
scale_type1 = source
scale_x1 = 0.5
scale_y1 = 1.0
filter_linear1 = false
srgb_framebuffer1 = true
shader2 = shaders/glow/gauss_horiz.slang
filter_linear2 = false
scale_type_x2 = viewport
scale_type_y2 = source
scale_x = 1.0
scale_y = 1.0
srgb_framebuffer2 = true
shader3 = shaders/glow/gauss_vert.slang
filter_linear3 = false
scale_type3 = viewport
scale3 = 1.0
srgb_framebuffer3 = true
shader4 = shaders/glow/threshold.slang
filter_linear4 = false
srgb_framebuffer4 = true
shader5 = shaders/glow/blur_horiz.slang
mipmap_input5 = true
filter_linear5 = true
scale_type5 = source
scale5 = 0.25
srgb_framebuffer5 = true
shader6 = shaders/glow/blur_vert.slang
filter_linear6 = true
srgb_framebuffer6 = true
shader7 = shaders/glow/resolve.slang
filter_linear7 = true

View File

@ -0,0 +1,38 @@
shaders = 7
shader0 = shaders/glow/linearize.slang
filter_linear0 = false
srgb_framebuffer0 = true
shader1 = shaders/glow/lanczos_horiz.slang
filter_linear1 = false
scale_type_x1 = viewport
scale_type_y1 = source
scale_x = 1.0
scale_y = 1.0
srgb_framebuffer1 = true
shader2 = shaders/glow/gauss_vert.slang
filter_linear2 = false
scale_type2 = viewport
scale2 = 1.0
srgb_framebuffer2 = true
shader3 = shaders/glow/threshold.slang
filter_linear3 = false
srgb_framebuffer3 = true
shader4 = shaders/glow/blur_horiz.slang
mipmap_input4 = true
filter_linear4 = true
scale_type4 = source
scale4 = 0.25
srgb_framebuffer4 = true
shader5 = shaders/glow/blur_vert.slang
filter_linear5 = true
srgb_framebuffer5 = true
shader6 = shaders/glow/resolve.slang
filter_linear6 = true

View File

@ -0,0 +1,45 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#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;
#include "blur_params.inc"
#define kernel(x) exp(-GLOW_FALLOFF * (x) * (x))
void main()
{
vec3 col = vec3(0.0);
float dx = 4.0 * global.SourceSize.z; // Mipmapped
float k_total = 0.0;
for (int i = -TAPS; i <= TAPS; i++)
{
float k = kernel(i);
k_total += k;
col += k * texture(Source, vTexCoord + vec2(float(i) * dx, 0.0)).rgb;
}
FragColor = vec4(col / k_total, 1.0);
}

View File

@ -0,0 +1,5 @@
// Higher value, more centered glow.
// Lower values might need more taps.
#define GLOW_FALLOFF 0.35
#define TAPS 4

View File

@ -0,0 +1,45 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#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;
#include "blur_params.inc"
#define kernel(x) exp(-GLOW_FALLOFF * (x) * (x))
void main()
{
vec3 col = vec3(0.0);
float dy = global.SourceSize.w;
float k_total = 0.0;
for (int i = -TAPS; i <= TAPS; i++)
{
float k = kernel(i);
k_total += k;
col += k * texture(Source, vTexCoord + vec2(0.0, float(i) * dy)).rgb;
}
FragColor = vec4(col / k_total, 1.0);
}

View File

@ -0,0 +1,54 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out float data_pix_no;
layout(location = 2) out float data_one;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
data_pix_no = vTexCoord.x * global.SourceSize.x;
data_one = global.SourceSize.z;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in float data_pix_no;
layout(location = 2) in float data_one;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define INV_SQRT_2_PI 0.38 // Doesn't have to be accurate.
#define HORIZ_GAUSS_WIDTH 0.5
void main()
{
float texel = floor(data_pix_no);
float phase = data_pix_no - texel;
float base_phase = phase.x - 0.5;
vec2 tex = vec2((texel + 0.5) * global.SourceSize.z, vTexCoord.y);
vec3 col = vec3(0.0);
for (int i = -2; i <= 2; i++)
{
float phase = base_phase - float(i);
float g = INV_SQRT_2_PI * exp(-0.5 * phase * phase / (HORIZ_GAUSS_WIDTH * HORIZ_GAUSS_WIDTH)) / HORIZ_GAUSS_WIDTH;
col += texture(Source, tex + vec2(float(i) * data_one, 0.0)).rgb * g;
}
FragColor = vec4(col, 1.0);
}

View File

@ -0,0 +1,72 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 data_pix_no;
layout(location = 2) out float data_one;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
data_pix_no = vTexCoord * global.SourceSize.xy - vec2(0.0, 0.5);
data_one = global.SourceSize.w;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in vec2 data_pix_no;
layout(location = 2) in float data_one;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define CRT_GEOM_BEAM 1
vec3 beam(vec3 color, float dist)
{
#if CRT_GEOM_BEAM
vec3 wid = 2.0 + 2.0 * pow(color, vec3(4.0));
vec3 weights = vec3(abs(dist) * 3.333333333);
return 2.0 * color * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);
#else
float reciprocal_width = 4.0;
vec3 x = dist * reciprocal_width;
return 2.0 * color * exp(-0.5 * x * x) * reciprocal_width;
#endif
}
#define COLOR_BOOST 1.0
void main()
{
vec2 texel = floor(data_pix_no);
float phase = data_pix_no.y - texel.y;
vec2 tex = vec2(texel + 0.5) * global.SourceSize.zw;
vec3 top = texture(Source, tex + vec2(0.0, 0 * data_one)).rgb;
vec3 bottom = texture(Source, tex + vec2(0.0, 1 * data_one)).rgb;
float dist0 = phase;
float dist1 = 1.0 - phase;
vec3 scanline = vec3(0.0);
scanline += beam(top, dist0);
scanline += beam(bottom, dist1);
FragColor = vec4(COLOR_BOOST * scanline * 0.869565217391304, 1.0);
}

View File

@ -0,0 +1,66 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out float data_pix_no;
layout(location = 2) out float data_one;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
data_pix_no = vTexCoord.x * global.SourceSize.x;
data_one = global.SourceSize.z;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in float data_pix_no;
layout(location = 2) in float data_one;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#define PI 3.14159265359
float sinc(float x)
{
if (abs(x) < 0.001)
return 1.0;
x *= PI;
return sin(x) / x;
}
#define BOOST 1.0
void main()
{
float texel = floor(data_pix_no);
float phase = data_pix_no - texel;
float base_phase = phase - 0.5;
vec2 tex = vec2((texel + 0.5) * global.SourceSize.z, vTexCoord.y);
vec3 col = vec3(0.0);
for (int i = -2; i <= 2; i++)
{
float phase = base_phase - float(i);
if (abs(phase) < 2.0)
{
float g = BOOST * sinc(phase) * sinc(0.5 * phase);
col += texture(Source, tex + vec2(float(i) * data_one, 0.0)).rgb * g;
}
}
FragColor = vec4(col, 1.0);
}

View File

@ -0,0 +1,34 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#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;
#define INPUT_GAMMA 2.4
void main()
{
vec3 color = texture(Source, vTexCoord).rgb;
FragColor = vec4(pow(color, vec3(INPUT_GAMMA)), 1.0);
}

View File

@ -0,0 +1,53 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
vec4 PassOutputSize4;
} global;
#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 = 1) uniform sampler2D Source;
layout(set = 0, binding = 2) uniform sampler2D PassOutput4;
// For debugging
#define BLOOM_ONLY 0
#define BLOOM_STRENGTH 0.45
#define OUTPUT_GAMMA 2.2
#define CRT_PASS PassOutput4
void main()
{
vec2 tex = floor(global.PassOutputSize4.xy * vTexCoord);
tex = (tex + 0.5) * global.PassOutputSize4.zw;
#if BLOOM_ONLY
vec3 source = BLOOM_STRENGTH * texture(Source, tex).rgb;
#else
/* TODO/FIXME - In slang, how do I get the equivalent of PASSPREV4.tex_coord? */
vec3 source = 1.15 * texture(CRT_PASS, tex).rgb;
vec3 bloom = texture(Source, tex).rgb;
source += BLOOM_STRENGTH * bloom;
#endif
FragColor = vec4(pow(clamp(source, 0.0, 1.0), vec3(1.0 / OUTPUT_GAMMA)), 1.0);
}

View File

@ -0,0 +1,36 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
} global;
#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;
#define GLOW_WHITEPOINT 1.0
#define GLOW_ROLLOFF 3.0
void main()
{
vec3 color = 1.15 * texture(Source, vTexCoord).rgb;
vec3 factor = clamp(color / GLOW_WHITEPOINT, 0.0, 1.0);
FragColor = vec4(pow(factor, vec3(GLOW_ROLLOFF)), 1.0);
}