diff --git a/cubic/shaders/spline16-x.slang b/cubic/shaders/spline16-x.slang index 8b28c72..5aca762 100644 --- a/cubic/shaders/spline16-x.slang +++ b/cubic/shaders/spline16-x.slang @@ -39,8 +39,13 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float S16_ANTI_RINGING; } params; +#pragma parameter S16_ANTI_RINGING "Spline16 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define S16_ANTI_RINGING params.S16_ANTI_RINGING + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; @@ -121,5 +126,15 @@ void main() vec3 color = mat4x3( C0, C1, C2, C3 ) * w; + // Anti-ringing + if (S16_ANTI_RINGING == 1.0) + { + vec3 aux = color; + vec3 min_sample = min(min(C0, C1), min(C2, C3)); + vec3 max_sample = max(max(C0, C1), max(C2, C3)); + color = clamp(color, min_sample, max_sample); + color = mix(aux, color, step(0.0, (C0-C1)*(C2-C3))); + } + FragColor = vec4(color, 1.0); } diff --git a/cubic/shaders/spline16-y.slang b/cubic/shaders/spline16-y.slang index ab18e8c..2547608 100644 --- a/cubic/shaders/spline16-y.slang +++ b/cubic/shaders/spline16-y.slang @@ -39,8 +39,13 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float S16_ANTI_RINGING; } params; +#pragma parameter S16_ANTI_RINGING "Spline16 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define S16_ANTI_RINGING params.S16_ANTI_RINGING + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; @@ -121,5 +126,15 @@ void main() vec3 color = mat4x3( C0, C1, C2, C3 ) * w; + // Anti-ringing + if (S16_ANTI_RINGING == 1.0) + { + vec3 aux = color; + vec3 min_sample = min(min(C0, C1), min(C2, C3)); + vec3 max_sample = max(max(C0, C1), max(C2, C3)); + color = clamp(color, min_sample, max_sample); + color = mix(aux, color, step(0.0, (C0-C1)*(C2-C3))); + } + FragColor = vec4(color, 1.0); } diff --git a/cubic/shaders/spline36-x.slang b/cubic/shaders/spline36-x.slang index 3ebc665..926fb76 100644 --- a/cubic/shaders/spline36-x.slang +++ b/cubic/shaders/spline36-x.slang @@ -39,8 +39,15 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float S36_ANTI_RINGING; } params; +#pragma parameter S36_ANTI_RINGING "Spline36 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define S36_ANTI_RINGING params.S36_ANTI_RINGING + +#define AR_STRENGTH 0.8 + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; @@ -131,5 +138,15 @@ void main() vec3 color = mat3( C0, C1, C2 ) * w1 + mat3( C3, C4, C5) * w2; + // Anti-ringing + if (S36_ANTI_RINGING == 1.0) + { + vec3 aux = color; + vec3 min_sample = min(min(C1, C2), min(C3, C4)); + vec3 max_sample = max(max(C1, C2), max(C3, C4)); + color = clamp(color, min_sample, max_sample); + color = mix(aux, color, AR_STRENGTH*step(0.0, (C1-C2)*(C3-C4))); + } + FragColor = vec4(color, 1.0); } diff --git a/cubic/shaders/spline36-y.slang b/cubic/shaders/spline36-y.slang index 4790b17..2377c26 100644 --- a/cubic/shaders/spline36-y.slang +++ b/cubic/shaders/spline36-y.slang @@ -39,8 +39,15 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float S36_ANTI_RINGING; } params; +#pragma parameter S36_ANTI_RINGING "Spline36 Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define S36_ANTI_RINGING params.S36_ANTI_RINGING + +#define AR_STRENGTH 0.8 + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; @@ -131,5 +138,16 @@ void main() vec3 color = mat3( C0, C1, C2 ) * w1 + mat3( C3, C4, C5) * w2; + // Anti-ringing + if (S36_ANTI_RINGING == 1.0) + { + vec3 aux = color; + vec3 min_sample = min(min(C1, C2), min(C3, C4)); + vec3 max_sample = max(max(C1, C2), max(C3, C4)); + color = clamp(color, min_sample, max_sample); + color = mix(aux, color, AR_STRENGTH*step(0.0, (C1-C2)*(C3-C4))); + + } + FragColor = vec4(color, 1.0); }