mirror of
https://github.com/cemu-project/cemu_graphic_packs.git
synced 2024-11-22 01:29:18 +01:00
[TPHD] Add bicubic (sharpen) filter
Add : bicubic (sharpen) filter. @NAVras-Z Thnx Fix : LOD description makes sense for regular users.
This commit is contained in:
parent
c58d2f707c
commit
661ba94aca
97
Enhancements/TwilightPrincessHD_Bicubic/output.glsl
Normal file
97
Enhancements/TwilightPrincessHD_Bicubic/output.glsl
Normal file
@ -0,0 +1,97 @@
|
||||
// https://github.com/obsproject/obs-studio/blob/master/libobs/data/bicubic_scale.effect // added customizable polynomials back
|
||||
|
||||
#version 420
|
||||
|
||||
in vec2 passUV;
|
||||
layout(binding=0) uniform sampler2D textureSrc;
|
||||
uniform vec2 textureSrcResolution;
|
||||
layout(location = 0) out vec4 colorOut0;
|
||||
|
||||
float weight(float x)
|
||||
{
|
||||
float ax = abs(x);
|
||||
|
||||
const float B = $b;
|
||||
const float C = $c;
|
||||
|
||||
if (ax < 2.0) {
|
||||
float x_squared = x * x;
|
||||
if (ax < 1.0) {
|
||||
return (x_squared *
|
||||
((12.0 - 9.0 * B - 6.0 * C) * ax +
|
||||
(-18.0 + 12.0 * B + 6.0 * C)) +
|
||||
(6.0 - 2.0 * B))
|
||||
/ 6.0;
|
||||
}
|
||||
|
||||
return (x_squared *
|
||||
((-B - 6.0 * C) * ax + (6.0 * B + 30.0 * C)) +
|
||||
(-12.0 * B - 48.0 * C) * ax +
|
||||
(8.0 * B + 24.0 * C))
|
||||
/ 6.0;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
vec4 weight4(float x)
|
||||
{
|
||||
return vec4(
|
||||
weight(x - 2.0),
|
||||
weight(x - 1.0),
|
||||
weight(x),
|
||||
weight(x + 1.0));
|
||||
}
|
||||
|
||||
vec4 DrawBicubic(vec2 f_in)
|
||||
{
|
||||
vec2 stepxy = 1.0/textureSrcResolution;
|
||||
vec2 pos = f_in.st + stepxy * 0.5;
|
||||
vec2 f = fract(pos * textureSrcResolution);
|
||||
|
||||
vec4 rowtaps = weight4(1.0 - f.x);
|
||||
vec4 coltaps = weight4(1.0 - f.y);
|
||||
|
||||
vec2 uv0 = (-1.5 - f) * stepxy + pos;
|
||||
vec2 uv1 = uv0 + stepxy;
|
||||
vec2 uv2 = uv1 + stepxy;
|
||||
vec2 uv3 = uv2 + stepxy;
|
||||
|
||||
float u_weight_sum = rowtaps.y + rowtaps.z;
|
||||
float u_middle_offset = rowtaps.z * stepxy.x / u_weight_sum;
|
||||
float u_middle = uv1.x + u_middle_offset;
|
||||
|
||||
float v_weight_sum = coltaps.y + coltaps.z;
|
||||
float v_middle_offset = coltaps.z * stepxy.y / v_weight_sum;
|
||||
float v_middle = uv1.y + v_middle_offset;
|
||||
|
||||
// wrap doesn't apply to texelFetch
|
||||
// clamp
|
||||
// ivec2 coord_top_left = ivec2(max(uv0 * textureSrcResolution, 0.5));
|
||||
// ivec2 coord_bottom_right = ivec2(min(uv3 * textureSrcResolution, textureSrcResolution - 0.5));
|
||||
// mirror
|
||||
ivec2 coord_top_left = ivec2(abs(uv0 * textureSrcResolution));
|
||||
ivec2 coord_bottom_right = ivec2(textureSrcResolution - abs(uv3 * textureSrcResolution - textureSrcResolution));
|
||||
|
||||
vec4 top = texelFetch(textureSrc, ivec2(coord_top_left), 0) * rowtaps.x;
|
||||
top += texture(textureSrc, vec2(u_middle, uv0.y)) * u_weight_sum;
|
||||
top += texelFetch(textureSrc, ivec2(coord_bottom_right.x, coord_top_left.y), 0) * rowtaps.w;
|
||||
vec4 total = top * coltaps.x;
|
||||
|
||||
vec4 middle = texture(textureSrc, vec2(uv0.x, v_middle)) * rowtaps.x;
|
||||
middle += texture(textureSrc, vec2(u_middle, v_middle)) * u_weight_sum;
|
||||
middle += texture(textureSrc, vec2(uv3.x, v_middle)) * rowtaps.w;
|
||||
total += middle * v_weight_sum;
|
||||
|
||||
vec4 bottom = texelFetch(textureSrc, ivec2(coord_top_left.x, coord_bottom_right.y), 0) * rowtaps.x;
|
||||
bottom += texture(textureSrc, vec2(u_middle, uv3.y)) * u_weight_sum;
|
||||
bottom += texelFetch(textureSrc, ivec2(coord_bottom_right), 0) * rowtaps.w;
|
||||
total += bottom * coltaps.w;
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
colorOut0 = vec4(DrawBicubic(passUV).rgb,1.0);
|
||||
}
|
39
Enhancements/TwilightPrincessHD_Bicubic/rules.txt
Normal file
39
Enhancements/TwilightPrincessHD_Bicubic/rules.txt
Normal file
@ -0,0 +1,39 @@
|
||||
[Definition]
|
||||
name = Optimized Bicubic spline resampler
|
||||
titleIds = titleIds = 000500001019C800,000500001019E600,000500001019E500
|
||||
path = "The Legend of Zelda: Twilight Princess HD/Sharpen Filters/Bicubic"
|
||||
description = The b and c can adjust the properties of the cubic; sometimes referred to as "blurring" and "ringing" respectively.
|
||||
version = 3
|
||||
|
||||
[OutputShader]
|
||||
upscaleMagFilter = Linear
|
||||
downscaleMagFilter = Linear
|
||||
|
||||
[Preset]
|
||||
name = Catmull-Rom
|
||||
$b = 0.0
|
||||
$c = 0.5
|
||||
|
||||
[Preset]
|
||||
name = Mitchell-Netravali
|
||||
$b = 1/3
|
||||
$c = 1/3
|
||||
|
||||
[Preset]
|
||||
name = B-spline
|
||||
$b = 1.0
|
||||
$c = 0.0
|
||||
|
||||
[Preset]
|
||||
name = Photoshop
|
||||
$b = 0.0
|
||||
$c = 0.75
|
||||
|
||||
[Preset]
|
||||
name = Oversharp, w ringing artifact
|
||||
$b = 0.1
|
||||
$c = 0.9
|
||||
|
||||
# Generally b,c >= 0. the shader can't produce negative weight at 0-1 because of bilinear optimization
|
||||
# But some combinations of negative b,c might have non-negative weight
|
||||
# Optionally [b + 2c = 1] for numerically accurate filter
|
@ -1,8 +1,7 @@
|
||||
[Definition]
|
||||
titleIds = 000500001019C800,000500001019E600,000500001019E500
|
||||
name = Resolution
|
||||
name = Level of detail
|
||||
path = "The Legend of Zelda: Twilight Princess HD/Enhancements/Negative Texture LOD"
|
||||
description = Changes the resolution of the game.
|
||||
version = 3
|
||||
|
||||
[Preset]
|
||||
@ -36,6 +35,14 @@ $0x034 = -4
|
||||
$0x035 = -4
|
||||
$0x01a = -4
|
||||
|
||||
[Preset]
|
||||
name = LOD +2 (Simulate WiiU LOD on higher resolution)
|
||||
$0x031 = +2
|
||||
$0x033 = +2
|
||||
$0x034 = +2
|
||||
$0x035 = +2
|
||||
$0x01a = 0
|
||||
|
||||
[TextureRedefine]
|
||||
formats = 0x031 #0x431,0x432,0x433,0x434,0x435 not used.
|
||||
overwriteRelativeLodBias = $0x031
|
||||
|
Loading…
Reference in New Issue
Block a user