mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-29 19:01:31 +11:00
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:
parent
7f264bcc4a
commit
59e6aa174a
|
@ -80,7 +80,7 @@ filter_linear10 = true
|
||||||
scale_type10 = viewport
|
scale_type10 = viewport
|
||||||
scale10 = 1.0
|
scale10 = 1.0
|
||||||
float_framebuffer10 = true
|
float_framebuffer10 = true
|
||||||
mipmap_input10 = true
|
wrap_mode10 = mirrored_repeat
|
||||||
|
|
||||||
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
||||||
filter_linear11 = true
|
filter_linear11 = true
|
||||||
|
|
|
@ -80,7 +80,7 @@ filter_linear10 = true
|
||||||
scale_type10 = viewport
|
scale_type10 = viewport
|
||||||
scale10 = 1.0
|
scale10 = 1.0
|
||||||
float_framebuffer10 = true
|
float_framebuffer10 = true
|
||||||
mipmap_input10 = true
|
wrap_mode10 = mirrored_repeat
|
||||||
|
|
||||||
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
||||||
filter_linear11 = true
|
filter_linear11 = true
|
||||||
|
|
|
@ -80,7 +80,7 @@ filter_linear10 = true
|
||||||
scale_type10 = viewport
|
scale_type10 = viewport
|
||||||
scale10 = 1.0
|
scale10 = 1.0
|
||||||
float_framebuffer10 = true
|
float_framebuffer10 = true
|
||||||
mipmap_input10 = true
|
wrap_mode10 = mirrored_repeat
|
||||||
|
|
||||||
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
shader11 = ../blurs/shaders/kawase/delinearize.slang
|
||||||
filter_linear11 = true
|
filter_linear11 = true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Average fill v1.2 by fishku
|
Average fill v1.3 by fishku
|
||||||
Copyright (C) 2023
|
Copyright (C) 2023
|
||||||
Public domain license (CC0)
|
Public domain license (CC0)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
3 = Smooth angle-based blending
|
3 = Smooth angle-based blending
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
v1.3: Fix scaling bugs.
|
||||||
v1.2: Fix scaling bugs.
|
v1.2: Fix scaling bugs.
|
||||||
v1.1: Add extension modes from blur fill; Add average gamma adjustment.
|
v1.1: Add extension modes from blur fill; Add average gamma adjustment.
|
||||||
v1.0: Initial release.
|
v1.0: Initial release.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// See compose.slang for copyright and other information.
|
// See compose.slang for copyright and other information.
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#pragma parameter AVERAGE_FILL_SETTINGS "=== Average fill v1.2 settings ===" 0.0 0.0 1.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" 8.0 0.0 1024.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" 8.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_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
|
#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 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 FORCE_ASPECT_RATIO "Force aspect ratio" 1.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_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" 3.0 1.0 100.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 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
|
#pragma parameter FILL_GAMMA "Background fill gamma adjustment" 1.0 0.5 2.0 0.1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Blur fill v1.3 by fishku
|
Blur fill v1.4 by fishku
|
||||||
Copyright (C) 2023
|
Copyright (C) 2023
|
||||||
Public domain license (CC0)
|
Public domain license (CC0)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
strength of the blur.
|
strength of the blur.
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
v1.4: Fix scaling bugs.
|
||||||
v1.3: Reduce shimmering artifacts.
|
v1.3: Reduce shimmering artifacts.
|
||||||
v1.2: Fix scaling bugs.
|
v1.2: Fix scaling bugs.
|
||||||
v1.1: Fix bug with glcore driver.
|
v1.1: Fix bug with glcore driver.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// See compose.slang for copyright and other information.
|
// See compose.slang for copyright and other information.
|
||||||
|
|
||||||
// clang-format off
|
// 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_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_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_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 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 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 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 FORCE_ASPECT_RATIO "Force aspect ratio" 1.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_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" 3.0 1.0 100.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 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
|
#pragma parameter FILL_GAMMA "Background fill gamma adjustment" 1.4 0.5 2.0 0.1
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
// See compose.slang for copyright and other information.
|
// 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.
|
// Scaling from unit output to pixel input space.
|
||||||
vec2 scale_o2i() {
|
vec2 scale_o2i() {
|
||||||
// Pixels in input coord. space, after cropping.
|
// Pixels in input coord. space, after cropping.
|
||||||
|
@ -10,58 +16,43 @@ vec2 scale_o2i() {
|
||||||
param.OS_CROP_TOP + param.OS_CROP_BOTTOM)
|
param.OS_CROP_TOP + param.OS_CROP_BOTTOM)
|
||||||
: 2 * vec2(min(param.OS_CROP_LEFT, param.OS_CROP_RIGHT),
|
: 2 * vec2(min(param.OS_CROP_LEFT, param.OS_CROP_RIGHT),
|
||||||
min(param.OS_CROP_TOP, param.OS_CROP_BOTTOM)));
|
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,
|
// lambda_1 * input_pixels.x, lambda_2 * input_pixels.y,
|
||||||
// possibly corrected for forced aspect ratio
|
// possibly corrected for forced aspect ratio
|
||||||
const vec2 eff_aspect = param.FORCE_ASPECT_RATIO < 0.5
|
const vec2 eff_aspect =
|
||||||
? eff_input_res
|
(param.FORCE_ASPECT_RATIO < 0.5
|
||||||
: vec2(eff_input_res.x * param.ASPECT_H,
|
? param.FinalViewportSize.xy * param.InputSize.yx
|
||||||
eff_input_res.y * param.ASPECT_V);
|
: (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;
|
float scale_x, scale_y;
|
||||||
if (param.FinalViewportSize.x * eff_aspect.y <
|
if (param.FinalViewportSize.x / (eff_input_res.x * eff_aspect.x) <
|
||||||
param.FinalViewportSize.y * 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
|
// Scale will be limited by width. Calc x scale, then derive y scale
|
||||||
// using aspect ratio.
|
// using aspect ratio.
|
||||||
scale_x = param.FinalViewportSize.x / eff_input_res.x;
|
scale_x = param.FinalViewportSize.x / eff_input_res.x;
|
||||||
if (param.FORCE_INTEGER_SCALING > 0.5) {
|
apply_integer_scaling(scale_x);
|
||||||
scale_x = max(1.0, floor(scale_x));
|
scale_y = scale_x * eff_aspect.y / eff_aspect.x;
|
||||||
}
|
apply_integer_scaling(scale_y);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Scale will be limited by height.
|
// Scale will be limited by height.
|
||||||
scale_y = param.FinalViewportSize.y / eff_input_res.y;
|
scale_y = param.FinalViewportSize.y / eff_input_res.y;
|
||||||
if (param.FORCE_INTEGER_SCALING > 0.5) {
|
apply_integer_scaling(scale_y);
|
||||||
scale_y = max(1.0, floor(scale_y));
|
scale_x = scale_y * eff_aspect.x / eff_aspect.y;
|
||||||
}
|
apply_integer_scaling(scale_x);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return param.FinalViewportSize.xy / vec2(scale_x, scale_y);
|
return param.FinalViewportSize.xy / vec2(scale_x, scale_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get adjusted center in input pixel coordinate system.
|
// 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() {
|
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 -
|
? 0.5 * vec2(param.OS_CROP_LEFT + param.InputSize.x -
|
||||||
param.OS_CROP_RIGHT,
|
param.OS_CROP_RIGHT,
|
||||||
param.OS_CROP_TOP + param.InputSize.y -
|
param.OS_CROP_TOP + param.InputSize.y -
|
||||||
param.OS_CROP_BOTTOM)
|
param.OS_CROP_BOTTOM)
|
||||||
: vec2(0.49999) * param.InputSize.xy);
|
: vec2(0.49999) * param.InputSize.xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From unit output to pixel input space.
|
// From unit output to pixel input space.
|
||||||
|
|
Loading…
Reference in a new issue