Update Chroma Scaling.

This commit is contained in:
Hyllian 2024-01-23 18:41:16 -03:00 committed by GitHub
parent fba7bb8410
commit c6f9c6316c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,7 +17,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
float chroma_scale;
} global;
#pragma parameter chroma_scale "NTSC Chroma Scaling" 1.0 1.0 4.0 0.2
#pragma parameter chroma_scale "NTSC Chroma Scaling" 1.0 0.2 4.0 0.2
#pragma parameter ntsc_scale "NTSC Resolution Scaling" 1.0 0.20 3.0 0.05
#pragma parameter ntsc_phase "NTSC Phase: Auto | 2 phase | 3 phase" 1.0 1.0 3.0 1.0
#pragma parameter linearize "NTSC Linearize Output Gamma" 0.0 0.0 1.0 1.0
@ -39,13 +39,14 @@ layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
//layout(set = 0, binding = 3) uniform sampler2D orig;
vec3 fetch_offset(float offset, float one_x)
vec3 fetch_offset(float offset, vec2 one_x)
{
/* A hack to insert chroma scaling. ;) (Hyllian, 2024) */
/* Insert chroma scaling. Thanks to guest.r ideas. */
vec3 yiq;
yiq.x = texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).x;
yiq.yz = texture(Source, vTexCoord + vec2((offset) * (one_x / global.chroma_scale), 0.0)).yz;
yiq.x = texture(Source, vTexCoord + vec2((offset) * (one_x.x), 0.0)).x;
yiq.yz = texture(Source, vTexCoord + vec2((offset) * (one_x.y), 0.0)).yz;
return yiq;
@ -204,11 +205,14 @@ const float chroma_filter_3_phase[25] = float[25](
void main()
{
float res = global.ntsc_scale;
float OriginalSize = global.OriginalSize.x;
float one_x = global.SourceSize.z / res;
float OriginalSize = global.OriginalSize.x;
vec3 signal = vec3(0.0);
float phase = (global.ntsc_phase < 1.5) ? ((OriginalSize > 300.0) ? 2.0 : 3.0) : ((global.ntsc_phase > 2.5) ? 3.0 : 2.0);
float chroma_scale = phase > 2.5 ? min(global.chroma_scale, 2.2) : global.chroma_scale;
vec2 one_x = (global.SourceSize.z / res) * vec2(1.0, 1.0 / chroma_scale);
if(phase < 2.5)
{
vec3 sums = fetch_offset(0.0 - 32.0, one_x) + fetch_offset(32.0 - 0.0, one_x);