From a24fd351db5303479a35b743c86ab7f879edca2a Mon Sep 17 00:00:00 2001 From: hunterk Date: Mon, 17 Feb 2020 11:44:18 -0600 Subject: [PATCH] update phase in main function --- ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang | 21 +++++++++------------ ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang | 5 ++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang b/ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang index 2b4b0975..a28e5cd6 100644 --- a/ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang +++ b/ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang @@ -37,18 +37,9 @@ layout(set = 0, binding = 2) uniform sampler2D Source; #define PI 3.14159265 float phase = (global.OriginalSize.x > 300.0) ? 2.0 : 3.0; -float CHROMA_MOD_FREQ = (phase < 2.5) ? (4.0 * PI / 15.0) : (PI / 3.0); -float ARTIFACTING = 1.0 - global.quality; -float FRINGING = 1.0 - global.quality; -float SATURATION = 1.0 - global.bw; -// prevent some very slight clipping that happens at 1.0 -const float BRIGHTNESS = 0.95; -mat3 mix_mat = mat3( - BRIGHTNESS, FRINGING, FRINGING, - ARTIFACTING, 2.0 * SATURATION, 0.0, - ARTIFACTING, 0.0, 2.0 * SATURATION -); + +#define mix_mat mat3(BRIGHTNESS, FRINGING, FRINGING, ARTIFACTING, 2.0 * SATURATION, 0.0, ARTIFACTING, 0.0, 2.0 * SATURATION) const mat3 yiq2rgb_mat = mat3( 1.0, 0.956, 0.6210, @@ -73,6 +64,12 @@ vec3 rgb2yiq(vec3 col) void main() { + float CHROMA_MOD_FREQ = (phase < 2.5) ? (4.0 * PI / 15.0) : (PI / 3.0); + float ARTIFACTING = 1.0 - global.quality; + float FRINGING = 1.0 - global.quality; + float SATURATION = 1.0 - global.bw; + // prevent some very slight clipping that happens at 1.0 + const float BRIGHTNESS = 0.95; vec3 col = texture(Source, vTexCoord).rgb; vec3 yiq = rgb2yiq(col); @@ -87,4 +84,4 @@ void main() yiq *= mix_mat; // Cross-talk. yiq.yz *= vec2(i_mod, q_mod); // Demodulate. FragColor = vec4(yiq, 1.0); -} +} diff --git a/ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang b/ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang index 458ae3a3..928da6fe 100644 --- a/ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang +++ b/ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang @@ -33,8 +33,6 @@ layout(location = 0) in vec2 vTexCoord; layout(location = 0) out vec4 FragColor; layout(set = 0, binding = 2) uniform sampler2D Source; -float phase = (global.OriginalSize.x > 300.0) ? 2.0 : 3.0; - const mat3 yiq2rgb_mat = mat3( 1.0, 0.956, 0.6210, 1.0, -0.2720, -0.6474, @@ -184,6 +182,7 @@ const float chroma_filter_3_phase[25] = float[25]( void main() { + float phase = (global.OriginalSize.x > 300.0) ? 2.0 : 3.0; float one_x = global.SourceSize.z; vec3 signal = vec3(0.0); @@ -218,4 +217,4 @@ void main() FragColor = vec4(rgb, 1.0); if(global.linearize < 0.5) return; else FragColor = pow(FragColor, vec4(2.2)); -} +}