Fix some further scaling bugs in border fill shaders (#458)

* Fix more scaling bugs in border fill shaders

* Fix numerical issues; Remove useless mipmap
This commit is contained in:
fishcu 2023-06-25 05:40:26 +02:00 committed by GitHub
parent 7f264bcc4a
commit 59e6aa174a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 53 deletions

View file

@ -80,7 +80,7 @@ filter_linear10 = true
scale_type10 = viewport
scale10 = 1.0
float_framebuffer10 = true
mipmap_input10 = true
wrap_mode10 = mirrored_repeat
shader11 = ../blurs/shaders/kawase/delinearize.slang
filter_linear11 = true

View file

@ -80,7 +80,7 @@ filter_linear10 = true
scale_type10 = viewport
scale10 = 1.0
float_framebuffer10 = true
mipmap_input10 = true
wrap_mode10 = mirrored_repeat
shader11 = ../blurs/shaders/kawase/delinearize.slang
filter_linear11 = true

View file

@ -80,7 +80,7 @@ filter_linear10 = true
scale_type10 = viewport
scale10 = 1.0
float_framebuffer10 = true
mipmap_input10 = true
wrap_mode10 = mirrored_repeat
shader11 = ../blurs/shaders/kawase/delinearize.slang
filter_linear11 = true

View file

@ -1,7 +1,7 @@
#version 450
/*
Average fill v1.2 by fishku
Average fill v1.3 by fishku
Copyright (C) 2023
Public domain license (CC0)
@ -27,6 +27,7 @@
3 = Smooth angle-based blending
Changelog:
v1.3: Fix scaling bugs.
v1.2: Fix scaling bugs.
v1.1: Add extension modes from blur fill; Add average gamma adjustment.
v1.0: Initial release.

View file

@ -1,9 +1,9 @@
// See compose.slang for copyright and other information.
// clang-format off
#pragma parameter AVERAGE_FILL_SETTINGS "=== Average fill v1.2 settings ===" 0.0 0.0 1.0 1.0
#pragma parameter OS_CROP_TOP "Overscan crop top" 8.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_BOTTOM "Overscan crop bottom" 8.0 0.0 1024.0 1.0
#pragma parameter AVERAGE_FILL_SETTINGS "=== Average fill v1.3 settings ===" 0.0 0.0 1.0 1.0
#pragma parameter OS_CROP_TOP "Overscan crop top" 0.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_BOTTOM "Overscan crop bottom" 0.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_LEFT "Overscan crop left" 0.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_RIGHT "Overscan crop right" 0.0 0.0 1024.0 1.0
@ -16,9 +16,9 @@
#pragma parameter CORNER_BLEND_MODE "Cropped corner blend mode" 0.0 0.0 3.0 1.0
#pragma parameter FORCE_ASPECT_RATIO "Force aspect ratio" 0.0 0.0 1.0 1.0
#pragma parameter ASPECT_H "Horizontal aspect ratio before crop" 4.0 1.0 100.0 1.0
#pragma parameter ASPECT_V "Vertical aspect ratio before crop" 3.0 1.0 100.0 1.0
#pragma parameter FORCE_ASPECT_RATIO "Force aspect ratio" 1.0 0.0 1.0 1.0
#pragma parameter ASPECT_H "Horizontal aspect ratio before crop (0 = original)" 0.0 0.0 256.0 1.0
#pragma parameter ASPECT_V "Vertical aspect ratio before crop (0 = original)" 0.0 0.0 256.0 1.0
#pragma parameter FORCE_INTEGER_SCALING "Force integer scaling" 1.0 0.0 1.0 1.0
#pragma parameter FILL_GAMMA "Background fill gamma adjustment" 1.0 0.5 2.0 0.1

View file

@ -1,7 +1,7 @@
#version 450
/*
Blur fill v1.3 by fishku
Blur fill v1.4 by fishku
Copyright (C) 2023
Public domain license (CC0)
@ -27,6 +27,7 @@
strength of the blur.
Changelog:
v1.4: Fix scaling bugs.
v1.3: Reduce shimmering artifacts.
v1.2: Fix scaling bugs.
v1.1: Fix bug with glcore driver.

View file

@ -1,7 +1,7 @@
// See compose.slang for copyright and other information.
// clang-format off
#pragma parameter BLUR_FILL_SETTINGS "=== Blur fill v1.3 settings ===" 0.0 0.0 1.0 1.0
#pragma parameter BLUR_FILL_SETTINGS "=== Blur fill v1.4 settings ===" 0.0 0.0 1.0 1.0
#pragma parameter OS_CROP_TOP "Overscan crop top" 0.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_BOTTOM "Overscan crop bottom" 0.0 0.0 1024.0 1.0
#pragma parameter OS_CROP_LEFT "Overscan crop left" 0.0 0.0 1024.0 1.0
@ -11,13 +11,13 @@
#pragma parameter SAMPLE_SIZE "No. of lines for rendering the blur" 16.0 1.0 1024.0 1.0
#pragma parameter BLUR_EXTEND_H "Extend the blur horizontally" 0.0 0.0 1.0 1.0
#pragma parameter BLUR_EXTEND_H "Extend the blur horizontally" 1.0 0.0 1.0 1.0
#pragma parameter BLUR_EXTEND_V "Extend the blur vertically" 1.0 0.0 1.0 1.0
#pragma parameter MIRROR_BLUR "Mirror the blur" 0.0 0.0 1.0 1.0
#pragma parameter FORCE_ASPECT_RATIO "Force aspect ratio" 0.0 0.0 1.0 1.0
#pragma parameter ASPECT_H "Horizontal aspect ratio before crop" 4.0 1.0 100.0 1.0
#pragma parameter ASPECT_V "Vertical aspect ratio before crop" 3.0 1.0 100.0 1.0
#pragma parameter FORCE_ASPECT_RATIO "Force aspect ratio" 1.0 0.0 1.0 1.0
#pragma parameter ASPECT_H "Horizontal aspect ratio before crop (0 = original)" 0.0 0.0 256.0 1.0
#pragma parameter ASPECT_V "Vertical aspect ratio before crop (0 = original)" 0.0 0.0 256.0 1.0
#pragma parameter FORCE_INTEGER_SCALING "Force integer scaling" 1.0 0.0 1.0 1.0
#pragma parameter FILL_GAMMA "Background fill gamma adjustment" 1.4 0.5 2.0 0.1

View file

@ -1,5 +1,11 @@
// See compose.slang for copyright and other information.
void apply_integer_scaling(inout float x) {
if (param.FORCE_INTEGER_SCALING > 0.5 && x > 1.0) {
x = floor(x);
}
}
// Scaling from unit output to pixel input space.
vec2 scale_o2i() {
// Pixels in input coord. space, after cropping.
@ -10,58 +16,43 @@ vec2 scale_o2i() {
param.OS_CROP_TOP + param.OS_CROP_BOTTOM)
: 2 * vec2(min(param.OS_CROP_LEFT, param.OS_CROP_RIGHT),
min(param.OS_CROP_TOP, param.OS_CROP_BOTTOM)));
// Integer aspect ratio after cropping.
// Aspect ratio before cropping.
// lambda_1 * input_pixels.x, lambda_2 * input_pixels.y,
// possibly corrected for forced aspect ratio
const vec2 eff_aspect = param.FORCE_ASPECT_RATIO < 0.5
? eff_input_res
: vec2(eff_input_res.x * param.ASPECT_H,
eff_input_res.y * param.ASPECT_V);
const vec2 eff_aspect =
(param.FORCE_ASPECT_RATIO < 0.5
? param.FinalViewportSize.xy * param.InputSize.yx
: (param.ASPECT_H < 0.5 || param.ASPECT_V < 0.5
? vec2(1.0)
: vec2(param.ASPECT_H, param.ASPECT_V) *
param.InputSize.yx));
float scale_x, scale_y;
if (param.FinalViewportSize.x * eff_aspect.y <
param.FinalViewportSize.y * eff_aspect.x) {
if (param.FinalViewportSize.x / (eff_input_res.x * eff_aspect.x) <
param.FinalViewportSize.y / (eff_input_res.y * eff_aspect.y)) {
// Scale will be limited by width. Calc x scale, then derive y scale
// using aspect ratio.
scale_x = param.FinalViewportSize.x / eff_input_res.x;
if (param.FORCE_INTEGER_SCALING > 0.5) {
scale_x = max(1.0, floor(scale_x));
}
if (param.FORCE_ASPECT_RATIO < 0.5) {
scale_y = scale_x;
} else {
scale_y = scale_x * param.ASPECT_V / param.ASPECT_H;
if (param.FORCE_INTEGER_SCALING > 0.5) {
scale_y = max(1.0, floor(scale_y));
}
}
apply_integer_scaling(scale_x);
scale_y = scale_x * eff_aspect.y / eff_aspect.x;
apply_integer_scaling(scale_y);
} else {
// Scale will be limited by height.
scale_y = param.FinalViewportSize.y / eff_input_res.y;
if (param.FORCE_INTEGER_SCALING > 0.5) {
scale_y = max(1.0, floor(scale_y));
}
if (param.FORCE_ASPECT_RATIO < 0.5) {
scale_x = scale_y;
} else {
scale_x = scale_y * param.ASPECT_H / param.ASPECT_V;
if (param.FORCE_INTEGER_SCALING > 0.5) {
scale_x = max(1.0, floor(scale_x));
}
}
apply_integer_scaling(scale_y);
scale_x = scale_y * eff_aspect.x / eff_aspect.y;
apply_integer_scaling(scale_x);
}
return param.FinalViewportSize.xy / vec2(scale_x, scale_y);
}
// Get adjusted center in input pixel coordinate system.
// Round to whole pixels to avoid issues on low-res output resolutions, e.g.,
// when using a 10x by 1x horizontal superresolution.
vec2 get_input_center() {
return floor(param.CENTER_CROP > 0.5
return param.CENTER_CROP > 0.5
? 0.5 * vec2(param.OS_CROP_LEFT + param.InputSize.x -
param.OS_CROP_RIGHT,
param.OS_CROP_TOP + param.InputSize.y -
param.OS_CROP_BOTTOM)
: vec2(0.49999) * param.InputSize.xy);
: vec2(0.49999) * param.InputSize.xy;
}
// From unit output to pixel input space.