mirror of
https://github.com/libretro/slang-shaders.git
synced 2024-11-23 08:19:54 +00:00
Merge pull request #570 from HyperspaceMadness/master
Added drez Downsampling and Updated Print Resolution
This commit is contained in:
commit
932d2a6304
9
downsample/drez/drez_3ds_x-400_y-480.slangp
Normal file
9
downsample/drez/drez_3ds_x-400_y-480.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 400
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 480
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_nds_x-256_y-384.slangp
Normal file
9
downsample/drez/drez_nds_x-256_y-384.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 256
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 384
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_psp_x-480_y-272.slangp
Normal file
9
downsample/drez/drez_psp_x-480_y-272.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 480
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 272
|
||||
wrap_mode0 = "clamp_to_edge"
|
10
downsample/drez/drez_psp_x-960_y-544.slangp
Normal file
10
downsample/drez/drez_psp_x-960_y-544.slangp
Normal file
@ -0,0 +1,10 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 960
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 544
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
|
9
downsample/drez/drez_psp_x-viewport_y-272.slangp
Normal file
9
downsample/drez/drez_psp_x-viewport_y-272.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 272
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_psp_x-viewport_y-544.slangp
Normal file
9
downsample/drez/drez_psp_x-viewport_y-544.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 544
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-1440_y-1080.slangp
Normal file
9
downsample/drez/drez_x-1440_y-1080.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 1440
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 1080
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-1920_y-1080.slangp
Normal file
9
downsample/drez/drez_x-1920_y-1080.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 1920
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 1080
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-320_y-224.slangp
Normal file
9
downsample/drez/drez_x-320_y-224.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 320
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 224
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-320_y-240.slangp
Normal file
9
downsample/drez/drez_x-320_y-240.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 320
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 240
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-640_y-480.slangp
Normal file
9
downsample/drez/drez_x-640_y-480.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = absolute
|
||||
scale_x0 = 640
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 480
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-viewport_y-224.slangp
Normal file
9
downsample/drez/drez_x-viewport_y-224.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 224
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-viewport_y-240.slangp
Normal file
9
downsample/drez/drez_x-viewport_y-240.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 240
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-viewport_y-320.slangp
Normal file
9
downsample/drez/drez_x-viewport_y-320.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 320
|
||||
wrap_mode0 = "clamp_to_edge"
|
9
downsample/drez/drez_x-viewport_y-480.slangp
Normal file
9
downsample/drez/drez_x-viewport_y-480.slangp
Normal file
@ -0,0 +1,9 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ../shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = viewport
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = absolute
|
||||
scale_y0 = 480
|
||||
wrap_mode0 = "clamp_to_edge"
|
11
downsample/drez_1x.slangp
Normal file
11
downsample/drez_1x.slangp
Normal file
@ -0,0 +1,11 @@
|
||||
shaders = 1
|
||||
|
||||
shader0 = ./shaders/drez-g-sharp_resampler.slang
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = source
|
||||
scale_x0 = 1.0
|
||||
scale_type_y0 = source
|
||||
scale_y0 = 1.0
|
||||
wrap_mode0 = "clamp_to_edge"
|
||||
|
||||
DREZ_THRESHOLD_RATIO = 1.0
|
160
downsample/shaders/drez-g-sharp_resampler.slang
Normal file
160
downsample/shaders/drez-g-sharp_resampler.slang
Normal file
@ -0,0 +1,160 @@
|
||||
#version 450
|
||||
|
||||
/*
|
||||
drez-g-sharp_resampler.slang
|
||||
DREZ Resolution Downsampler, This is really just a wrapper around Guest's great G-sharp resampler
|
||||
General usage is to add this as a pass with a reduced resolution
|
||||
|
||||
G-sharp resampler - dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 - 2021 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
Anti-Ringing inspired by Hyllian
|
||||
|
||||
*/
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float DREZ_GSHARP_ON;
|
||||
float DREZ_SIGMA_HV;
|
||||
float DREZ_HSHARP0;
|
||||
float DREZ_HAR;
|
||||
float DREZ_SHAR;
|
||||
float DREZ_THRESHOLD_RATIO;
|
||||
} global;
|
||||
|
||||
#pragma parameter GSHARP_DREZ_EMPTY_LINE " " 0 0 0.001 0.001
|
||||
#pragma parameter GSHARP_DREZ_TITLE "[ --- DREZ DOWNSAMPLE FILTER - GUEST.R G-SHARP RESAMPLER --- ]:" 0 0 0.01 0.01
|
||||
|
||||
#pragma parameter DREZ_GSHARP_ON " G-SHARP ON" 1 0 1 1
|
||||
#define DREZ_GSHARP_ON global.DREZ_GSHARP_ON
|
||||
|
||||
#pragma parameter DREZ_THRESHOLD_RATIO " Downsample Threshold (Original Res Vs Downsampled Res)" 1.5 1 4 0.1
|
||||
#define DREZ_THRESHOLD_RATIO global.DREZ_THRESHOLD_RATIO
|
||||
|
||||
|
||||
// Default was 1.2, now set to 2.3 to match smoothing in Hyllian b-spline
|
||||
#pragma parameter DREZ_HSHARP0 " Filter Range" 2.3 1.0 6.0 0.1
|
||||
#define DREZ_HSHARP0 global.DREZ_HSHARP0
|
||||
|
||||
// Default was 0.75
|
||||
#pragma parameter DREZ_SIGMA_HV " Gaussian Blur Sigma" 0.75 0.1 7.0 0.05
|
||||
#define DREZ_SIGMA_HV global.DREZ_SIGMA_HV
|
||||
|
||||
// Default was 0.5
|
||||
#pragma parameter DREZ_SHAR " Sharpness Definition" 0.5 0.0 2.0 0.05
|
||||
#define DREZ_SHAR global.DREZ_SHAR
|
||||
|
||||
// Default was 0.5
|
||||
#pragma parameter DREZ_HAR " Anti-Ringing" 0.5 0.0 1.0 0.10
|
||||
#define DREZ_HAR global.DREZ_HAR
|
||||
|
||||
|
||||
#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 Original;
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define SourceSize global.OriginalSize
|
||||
#define OutputSize global.OutputSize
|
||||
#define Source Original
|
||||
|
||||
float invsqrsigma_h = 1.0/(2.0*DREZ_SIGMA_HV*DREZ_SIGMA_HV);
|
||||
|
||||
float gaussian(float x, float y)
|
||||
{
|
||||
return exp(-(x*x + y*y)*invsqrsigma_h);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// If the effext is disabled or the downsample ratio is below the threshold, just sample the texture
|
||||
if (DREZ_GSHARP_ON == 0 || SourceSize.y / OutputSize.y < DREZ_THRESHOLD_RATIO)
|
||||
{
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 f = fract(SourceSize.xy * vTexCoord.xy);
|
||||
f = 0.5 - f;
|
||||
vec2 tex = floor(SourceSize.xy * vTexCoord)*SourceSize.zw + 0.5*SourceSize.zw;
|
||||
vec2 dx = vec2(SourceSize.z, 0.0);
|
||||
vec2 dy = vec2(0.0, SourceSize.w);
|
||||
|
||||
vec3 colorx = 0.0.xxx;
|
||||
vec3 colory = 0.0.xxx;
|
||||
float wx, wy;
|
||||
float wsumx = 0.0;
|
||||
float wsumy = 0.0;
|
||||
vec3 pixel;
|
||||
float x;
|
||||
|
||||
vec3 xcmax = 0.0.xxx;
|
||||
vec3 xcmin = 1.0.xxx;
|
||||
|
||||
float sharp = gaussian(DREZ_HSHARP0, 0.0);
|
||||
float maxsharp = 0.07;
|
||||
float FPR = DREZ_HSHARP0;
|
||||
float fpx = 1.0;
|
||||
|
||||
float LOOPSIZE = ceil(2.0*FPR);
|
||||
float y = -LOOPSIZE;
|
||||
|
||||
do
|
||||
{
|
||||
x = -LOOPSIZE;
|
||||
|
||||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(Source, tex + x*dx + y*dy).rgb;
|
||||
|
||||
wx = gaussian(x+f.x, y+f.y) - sharp;
|
||||
fpx = (sqrt(dot(vec2(x+f.x,y+f.y),vec2(x+f.x,y+f.y)))-FPR)/FPR;
|
||||
if (((x*x) + (y*y)) < 1.25*FPR) { xcmax = max(xcmax, pixel); xcmin = min(xcmin, pixel); }
|
||||
if (wx < 0.0) wx = clamp(wx, mix(-maxsharp, 0.0, pow(abs(fpx), DREZ_SHAR)), 0.0);
|
||||
colorx = colorx + wx * pixel;
|
||||
wsumx = wsumx + wx;
|
||||
x = x + 1.0;
|
||||
|
||||
} while (x <= LOOPSIZE);
|
||||
|
||||
y = y + 1.0;
|
||||
|
||||
} while (y <= LOOPSIZE);
|
||||
|
||||
vec3 color = colorx/wsumx;
|
||||
|
||||
color = mix(clamp(color, 0.0, 1.0), clamp(color, xcmin, xcmax), DREZ_HAR);
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
@ -61,16 +61,20 @@ void main()
|
||||
if (PRINT_RESOLUTION_TEXT_ON == 1 && vTexCoord.x > params.OutputSize.z * 2 && vTexCoord.y > params.OutputSize.w * 2)
|
||||
{
|
||||
vec2 ps = params.OutputSize.zw;
|
||||
vec2 outline_offset_mult = ps;
|
||||
outline_offset_mult.x *= max(floor(params.OutputSize.x / 240 + 0.01), 1);
|
||||
outline_offset_mult.y *= max(floor(params.OutputSize.y / 200 + 0.01), 1);
|
||||
|
||||
vec4 text_rgba = vec4(FragColor.a);
|
||||
text_rgba.rgb *= vec3(1, 1, 0);
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(1, 0)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(0, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(1, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(-1, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(-1, 0)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(0, -1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(-1, -1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + ps * vec2(1, -1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(1, 0)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(0, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(1, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(-1, 1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(-1, 0)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(0, -1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(-1, -1)).a;
|
||||
text_rgba.a += texture(TextGeneratePass, vTexCoord + outline_offset_mult * vec2(1, -1)).a;
|
||||
text_rgba = clamp(text_rgba, 0, 1);
|
||||
FragColor.rgb = PreMultAlphaBlend(FragColor, text_rgba).rgb;
|
||||
}
|
||||
|
@ -497,16 +497,6 @@ float DrawResolutions(vec2 uv)
|
||||
_spc _x _spc
|
||||
TEXT_MASK += print_integer(params.OriginalSize.y, 0, uv);
|
||||
|
||||
// Empty Line ----------------------------------------------------------
|
||||
print_pos.x = margin;
|
||||
print_pos.y += STRHEIGHT(1);
|
||||
|
||||
// Resolution Debugging ----------------------------------------------------------
|
||||
print_pos.x = margin;
|
||||
print_pos.y += STRHEIGHT(1);
|
||||
|
||||
_P _r _i _n _t _spc _R _e _s _o _l _u _t _i _o _n _spc _T _e _x _t _spc
|
||||
|
||||
return TEXT_MASK;
|
||||
}
|
||||
|
||||
@ -515,9 +505,10 @@ float GetText(vec2 in_coord)
|
||||
vec2 canvas_size = params.OutputSize.xy;
|
||||
|
||||
in_coord = (in_coord - 0.5) * vec2(1, -1) + 0.5;
|
||||
float downscale = 1;
|
||||
if (canvas_size.y > 460) downscale = 2;
|
||||
if (canvas_size.y > 1000) downscale = 3;
|
||||
|
||||
vec2 downscale = vec2(1, 1);
|
||||
downscale.x = max(max(floor(canvas_size.x / 240), 1), 1);
|
||||
downscale.y = max(max(ceil(canvas_size.y / 200), 1), 1);
|
||||
|
||||
vec2 uv = params.OutputSize.xy * in_coord;
|
||||
vec2 downscaled_uv = floor(params.OutputSize.xy * in_coord / downscale);
|
||||
|
Loading…
Reference in New Issue
Block a user