diff --git a/cubic/b-spline-fast.slangp b/cubic/b-spline-fast.slangp index 2a49308..de95534 100755 --- a/cubic/b-spline-fast.slangp +++ b/cubic/b-spline-fast.slangp @@ -1,4 +1,12 @@ -shaders = 1 - -shader0 = shaders/b-spline-fast.slang -filter_linear0 = true \ No newline at end of file +shaders = 2 + +shader0 = shaders/b-spline-x.slang +filter_linear0 = false +scale_type_x0 = viewport +scale_type_y0 = source +scale0 = 1.0 +wrap_mode0 = "clamp_to_edge" + +shader1 = shaders/b-spline-y.slang +filter_linear1 = false +wrap_mode1 = "clamp_to_edge" diff --git a/cubic/catmull-rom-fast.slangp b/cubic/catmull-rom-fast.slangp index 8dfe003..dda028c 100755 --- a/cubic/catmull-rom-fast.slangp +++ b/cubic/catmull-rom-fast.slangp @@ -1,4 +1,12 @@ -shaders = 1 - -shader0 = shaders/catmull-rom-fast.slang -filter_linear0 = true \ No newline at end of file +shaders = 2 + +shader0 = shaders/catmull-rom-x.slang +filter_linear0 = false +scale_type_x0 = viewport +scale_type_y0 = source +scale0 = 1.0 +wrap_mode0 = "clamp_to_edge" + +shader1 = shaders/catmull-rom-y.slang +filter_linear1 = false +wrap_mode1 = "clamp_to_edge" diff --git a/cubic/catmull-rom.slangp b/cubic/catmull-rom.slangp new file mode 100644 index 0000000..31352e6 --- /dev/null +++ b/cubic/catmull-rom.slangp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/catmull-rom.slang +filter_linear0 = true diff --git a/cubic/shaders/b-spline-fast.slang b/cubic/shaders/b-spline-fast.slang deleted file mode 100755 index f3cf77f..0000000 --- a/cubic/shaders/b-spline-fast.slang +++ /dev/null @@ -1,87 +0,0 @@ -#version 450 - -/* - Bicubic B-Spline 4-taps (Fast) - ported by Hyllian - 2020 - - The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae - - Samples a texture with B-Spline filtering, using only 4 texture fetches instead of 16. - See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details - - ATENTION: This code only work using LINEAR filter sampling set on Retroarch! - -*/ - -layout(push_constant) uniform Push -{ - vec4 SourceSize; - vec4 OriginalSize; - vec4 OutputSize; - uint FrameCount; -} params; - -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; - -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; - -void main() -{ - // We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding - // down the sample location to get the exact center of our "starting" texel. The starting texel will be at - // location [1, 1] in the grid, where [0, 0] is the top left corner. - vec2 samplePos = vTexCoord * params.SourceSize.xy; - vec2 tc = floor(samplePos - 0.5) + 0.5; - - // Compute the fractional offset from our starting texel to our original sample location, which we'll - // feed into the B-Spline function to get our filter weights. - vec2 f = samplePos - tc; - vec2 f2 = f * f; - vec2 f3 = f2 * f; - - // Compute the B-Spline weights using the fractional offset that we calculated earlier. - // These equations are pre-expanded based on our knowledge of where the texels will be located, - // which lets us avoid having to evaluate a piece-wise function. - vec2 w0 = f2 - 0.5 * (f3 + f); - vec2 w1 = 1.5 * f3 - 2.5 * f2 + 1.0; - vec2 w2 = -1.5 * f3 + 2. * f2 + 0.5 * f; - // vec2 w3 = 0.5 * (f3 - f2); - vec2 w3 = 1.0 - w0 - w1 - w2; // The sum of weights must be one. - - // Work out weighting factors and sampling offsets that will let us use bilinear filtering to - // simultaneously evaluate the 2 samples each from the 4x4 grid. - vec2 s0 = w0 + w1; - vec2 s1 = w2 + w3; - vec2 f0 = w1 / s0; - vec2 f1 = w3 / s1; - - // Compute the final UV coordinates we'll use for sampling the texture - vec2 t0 = tc - 1. + f0; - vec2 t1 = tc + 1. + f1; - - t0 *= params.SourceSize.zw; - t1 *= params.SourceSize.zw; - - vec4 c0 = texture(Source, vec2(t0.x, t0.y)); - vec4 c1 = texture(Source, vec2(t1.x, t0.y)); - vec4 c2 = texture(Source, vec2(t0.x, t1.y)); - vec4 c3 = texture(Source, vec2(t1.x, t1.y)); - - FragColor = (c0 * s0.x + c1 * s1.x) * s0.y + (c2 * s0.x + c3 * s1.x) * s1.y; -} \ No newline at end of file diff --git a/cubic/shaders/b-spline-x.slang b/cubic/shaders/b-spline-x.slang new file mode 100644 index 0000000..5fb4c98 --- /dev/null +++ b/cubic/shaders/b-spline-x.slang @@ -0,0 +1,92 @@ +#version 450 + +/* + b-spline-x Shader + + Copyright (C) 2011-2022 Hyllian - sergiogdb@gmail.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +// B-Spline bicubic parameters +const float B = 1.0; +const float C = 0.0; + +const mat4 INV = mat4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0, + (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0, + -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0, + (B + 6.0*C)/6.0, -C, 0.0, 0.0); + +#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 vec4 t1; +layout(location = 2) out vec4 t2; + +void main() +{ + gl_Position = global.MVP * Position; + + vec2 ps = vec2(params.SourceSize.z, params.SourceSize.w); + float dx = ps.x; + float dy = ps.y; + + vTexCoord = TexCoord * 1.0001 - vec2(0.5, 0.0)*ps; + + t1 = vTexCoord.xyxy + vec4( -dx, 0.0, 0.0, 0.0); + t2 = vTexCoord.xyxy + vec4( dx, 0.0, 2.0*dx, 0.0); + +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec4 t1; +layout(location = 2) in vec4 t2; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec2 fp = fract(vTexCoord*params.SourceSize.xy); + + vec3 C0 = texture(Source, t1.xy).xyz; + vec3 C1 = texture(Source, t1.zw).xyz; + vec3 C2 = texture(Source, t2.xy).xyz; + vec3 C3 = texture(Source, t2.zw).xyz; + + vec4 Px = vec4(fp.x*fp.x*fp.x, fp.x*fp.x, fp.x, 1.0) * INV; + vec3 color = mat4x3(C0, C1, C2, C3) * Px; + + FragColor = vec4(color, 1.0); +} diff --git a/cubic/shaders/b-spline-y.slang b/cubic/shaders/b-spline-y.slang new file mode 100644 index 0000000..af92fa9 --- /dev/null +++ b/cubic/shaders/b-spline-y.slang @@ -0,0 +1,92 @@ +#version 450 + +/* + b-spline-y Shader + + Copyright (C) 2011-2022 Hyllian - sergiogdb@gmail.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +// B-Spline bicubic parameters +const float B = 1.0; +const float C = 0.0; + +const mat4 INV = mat4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0, + (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0, + -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0, + (B + 6.0*C)/6.0, -C, 0.0, 0.0); + +#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 vec4 t1; +layout(location = 2) out vec4 t2; + +void main() +{ + gl_Position = global.MVP * Position; + + vec2 ps = vec2(params.SourceSize.z, params.SourceSize.w); + float dx = ps.x; + float dy = ps.y; + + vTexCoord = TexCoord * 1.0001 - vec2(0.0, 0.5)*ps; + + t1 = vTexCoord.xyxy + vec4( 0.0, -dy, 0.0, 0.0); + t2 = vTexCoord.xyxy + vec4( 0.0, dy, 0.0, 2.0*dy); + +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec4 t1; +layout(location = 2) in vec4 t2; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec2 fp = fract(vTexCoord*params.SourceSize.xy); + + vec3 C0 = texture(Source, t1.xy).xyz; + vec3 C1 = texture(Source, t1.zw).xyz; + vec3 C2 = texture(Source, t2.xy).xyz; + vec3 C3 = texture(Source, t2.zw).xyz; + + vec4 Py = vec4(fp.y*fp.y*fp.y, fp.y*fp.y, fp.y, 1.0) * INV; + vec3 color = mat4x3(C0, C1, C2, C3) * Py; + + FragColor = vec4(color, 1.0); +} diff --git a/cubic/shaders/bicubic-x.slang b/cubic/shaders/bicubic-x.slang index de22ee5..3cd71ca 100644 --- a/cubic/shaders/bicubic-x.slang +++ b/cubic/shaders/bicubic-x.slang @@ -31,13 +31,19 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float B_ANTI_RINGING; } params; +#pragma parameter B_ANTI_RINGING "Bicubic Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define B_ANTI_RINGING params.B_ANTI_RINGING + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; } global; +// Classic Mitchell-Netravali bicubic parameters const float B = 1.0/3.0; const float C = 1.0/3.0; @@ -87,5 +93,15 @@ void main() vec4 Px = vec4(fp.x*fp.x*fp.x, fp.x*fp.x, fp.x, 1.0) * INV; vec3 color = mat4x3(C0, C1, C2, C3) * Px; + // Anti-ringing + if (B_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/bicubic-y.slang b/cubic/shaders/bicubic-y.slang index b5d309c..b48e503 100644 --- a/cubic/shaders/bicubic-y.slang +++ b/cubic/shaders/bicubic-y.slang @@ -31,13 +31,19 @@ layout(push_constant) uniform Push vec4 OriginalSize; vec4 OutputSize; uint FrameCount; + float B_ANTI_RINGING; } params; +#pragma parameter B_ANTI_RINGING "Bicubic Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define B_ANTI_RINGING params.B_ANTI_RINGING + layout(std140, set = 0, binding = 0) uniform UBO { mat4 MVP; } global; +// Classic Mitchell-Netravali bicubic parameters const float B = 1.0/3.0; const float C = 1.0/3.0; @@ -87,5 +93,15 @@ void main() vec4 Py = vec4(fp.y*fp.y*fp.y, fp.y*fp.y, fp.y, 1.0) * INV; vec3 color = mat4x3(C0, C1, C2, C3) * Py; + // Anti-ringing + if (B_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/catmull-rom-x.slang b/cubic/shaders/catmull-rom-x.slang new file mode 100644 index 0000000..7c404b8 --- /dev/null +++ b/cubic/shaders/catmull-rom-x.slang @@ -0,0 +1,107 @@ +#version 450 + +/* + catmull-rom-x Shader + + Copyright (C) 2011-2022 Hyllian - sergiogdb@gmail.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float C_ANTI_RINGING; +} params; + +#pragma parameter C_ANTI_RINGING "Catmull-Rom Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define C_ANTI_RINGING params.C_ANTI_RINGING + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +// Catmull-Rom parameters +const float B = 0.0; +const float C = 0.5; + +const mat4 INV = mat4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0, + (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0, + -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0, + (B + 6.0*C)/6.0, -C, 0.0, 0.0); + +#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 vec4 t1; +layout(location = 2) out vec4 t2; + +void main() +{ + gl_Position = global.MVP * Position; + + vec2 ps = vec2(params.SourceSize.z, params.SourceSize.w); + float dx = ps.x; + float dy = ps.y; + + vTexCoord = TexCoord * 1.0001 - vec2(0.5, 0.0)*ps; + + t1 = vTexCoord.xyxy + vec4( -dx, 0.0, 0.0, 0.0); + t2 = vTexCoord.xyxy + vec4( dx, 0.0, 2.0*dx, 0.0); + +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec4 t1; +layout(location = 2) in vec4 t2; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec2 fp = fract(vTexCoord*params.SourceSize.xy); + + vec3 C0 = texture(Source, t1.xy).xyz; + vec3 C1 = texture(Source, t1.zw).xyz; + vec3 C2 = texture(Source, t2.xy).xyz; + vec3 C3 = texture(Source, t2.zw).xyz; + + vec4 Px = vec4(fp.x*fp.x*fp.x, fp.x*fp.x, fp.x, 1.0) * INV; + vec3 color = mat4x3(C0, C1, C2, C3) * Px; + + // Anti-ringing + if (C_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/catmull-rom-y.slang b/cubic/shaders/catmull-rom-y.slang new file mode 100644 index 0000000..899939f --- /dev/null +++ b/cubic/shaders/catmull-rom-y.slang @@ -0,0 +1,107 @@ +#version 450 + +/* + catmull-rom-y Shader + + Copyright (C) 2011-2022 Hyllian - sergiogdb@gmail.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float C_ANTI_RINGING; +} params; + +#pragma parameter C_ANTI_RINGING "Catmull-Rom Anti-Ringing [ OFF | ON ]" 1.0 0.0 1.0 1.0 + +#define C_ANTI_RINGING params.C_ANTI_RINGING + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +// Catmull-Rom parameters +const float B = 0.0; +const float C = 0.5; + +const mat4 INV = mat4( (-B - 6.0*C)/6.0, (3.0*B + 12.0*C)/6.0, (-3.0*B - 6.0*C)/6.0, B/6.0, + (12.0 - 9.0*B - 6.0*C)/6.0, (-18.0 + 12.0*B + 6.0*C)/6.0, 0.0, (6.0 - 2.0*B)/6.0, + -(12.0 - 9.0*B - 6.0*C)/6.0, (18.0 - 15.0*B - 12.0*C)/6.0, (3.0*B + 6.0*C)/6.0, B/6.0, + (B + 6.0*C)/6.0, -C, 0.0, 0.0); + +#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 vec4 t1; +layout(location = 2) out vec4 t2; + +void main() +{ + gl_Position = global.MVP * Position; + + vec2 ps = vec2(params.SourceSize.z, params.SourceSize.w); + float dx = ps.x; + float dy = ps.y; + + vTexCoord = TexCoord * 1.0001 - vec2(0.0, 0.5)*ps; + + t1 = vTexCoord.xyxy + vec4( 0.0, -dy, 0.0, 0.0); + t2 = vTexCoord.xyxy + vec4( 0.0, dy, 0.0, 2.0*dy); + +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec4 t1; +layout(location = 2) in vec4 t2; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec2 fp = fract(vTexCoord*params.SourceSize.xy); + + vec3 C0 = texture(Source, t1.xy).xyz; + vec3 C1 = texture(Source, t1.zw).xyz; + vec3 C2 = texture(Source, t2.xy).xyz; + vec3 C3 = texture(Source, t2.zw).xyz; + + vec4 Py = vec4(fp.y*fp.y*fp.y, fp.y*fp.y, fp.y, 1.0) * INV; + vec3 color = mat4x3(C0, C1, C2, C3) * Py; + + // Anti-ringing + if (C_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/catmull-rom-fast.slang b/cubic/shaders/catmull-rom.slang old mode 100755 new mode 100644 similarity index 100% rename from cubic/shaders/catmull-rom-fast.slang rename to cubic/shaders/catmull-rom.slang