mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 07:41:31 +11:00
Scaling: Add overscale option (#482)
* Scaling: Add overscale option * Bump versions
This commit is contained in:
parent
3118737ff4
commit
c1488579ee
|
@ -1,7 +1,7 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Average fill v1.6 by fishku
|
Average fill v1.7 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.7: Add overscale option from crop and scale library.
|
||||||
v1.6: Refactor for new scaling library. Add rotation support.
|
v1.6: Refactor for new scaling library. Add rotation support.
|
||||||
v1.5: Optimize. Update to new Pixel AA version.
|
v1.5: Optimize. Update to new Pixel AA version.
|
||||||
v1.4: Add anti-aliased interpolation for non-integer scaling.
|
v1.4: Add anti-aliased interpolation for non-integer scaling.
|
||||||
|
@ -41,28 +42,32 @@
|
||||||
#include "../../../pixel-art-scaling/shaders/pixel_aa/parameters.slang"
|
#include "../../../pixel-art-scaling/shaders/pixel_aa/parameters.slang"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#include "../../../misc/shaders/scaling.slang"
|
#include "../../../misc/shaders/crop_and_scale/crop_and_scale.slang"
|
||||||
#include "../../../pixel-art-scaling/shaders/pixel_aa/shared.slang"
|
#include "../../../pixel-art-scaling/shaders/pixel_aa/shared.slang"
|
||||||
|
|
||||||
layout(push_constant) uniform Push {
|
layout(push_constant) uniform Push {
|
||||||
vec4 InputSize;
|
vec4 InputSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint Rotation;
|
uint Rotation;
|
||||||
float OS_CROP_TOP;
|
// Own settings
|
||||||
float OS_CROP_BOTTOM;
|
|
||||||
float OS_CROP_LEFT;
|
|
||||||
float OS_CROP_RIGHT;
|
|
||||||
float CENTER_AFTER_CROPPING;
|
|
||||||
float SAMPLE_SIZE;
|
|
||||||
float EXTEND_H;
|
float EXTEND_H;
|
||||||
float EXTEND_V;
|
float EXTEND_V;
|
||||||
float CORNER_BLEND_MODE;
|
float CORNER_BLEND_MODE;
|
||||||
|
float FILL_GAMMA;
|
||||||
|
float SAMPLE_SIZE;
|
||||||
|
// From crop and scale, scaling section
|
||||||
float FORCE_ASPECT_RATIO;
|
float FORCE_ASPECT_RATIO;
|
||||||
float ASPECT_H;
|
float ASPECT_H;
|
||||||
float ASPECT_V;
|
float ASPECT_V;
|
||||||
float FORCE_INTEGER_SCALING_H;
|
float FORCE_INTEGER_SCALING_H;
|
||||||
float FORCE_INTEGER_SCALING_V;
|
float FORCE_INTEGER_SCALING_V;
|
||||||
float FILL_GAMMA;
|
float OVERSCALE;
|
||||||
|
// From crop and scale, cropping section
|
||||||
|
float OS_CROP_TOP;
|
||||||
|
float OS_CROP_BOTTOM;
|
||||||
|
float OS_CROP_LEFT;
|
||||||
|
float OS_CROP_RIGHT;
|
||||||
|
float CENTER_AFTER_CROPPING;
|
||||||
// From pixel AA
|
// From pixel AA
|
||||||
float PIX_AA_SHARP;
|
float PIX_AA_SHARP;
|
||||||
float PIX_AA_SUBPX;
|
float PIX_AA_SUBPX;
|
||||||
|
@ -95,6 +100,7 @@ void main() {
|
||||||
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
||||||
vec2(param.ASPECT_H, param.ASPECT_V),
|
vec2(param.ASPECT_H, param.ASPECT_V),
|
||||||
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V),
|
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V),
|
||||||
|
param.OVERSCALE,
|
||||||
/* output_size_is_final_viewport_size = */ false);
|
/* output_size_is_final_viewport_size = */ false);
|
||||||
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
||||||
param.CENTER_AFTER_CROPPING, scale_o2i);
|
param.CENTER_AFTER_CROPPING, scale_o2i);
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
// See compose.slang for copyright and other information.
|
// See compose.slang for copyright and other information.
|
||||||
|
|
||||||
#include "../../../misc/shaders/scaling.slang"
|
#include "../../../misc/shaders/crop_and_scale/crop_and_scale.slang"
|
||||||
#include "parameters.slang"
|
#include "parameters.slang"
|
||||||
|
|
||||||
layout(push_constant) uniform Push {
|
layout(push_constant) uniform Push {
|
||||||
vec4 InputSize;
|
vec4 InputSize;
|
||||||
uint Rotation;
|
uint Rotation;
|
||||||
|
// Own settings
|
||||||
|
float SAMPLE_SIZE;
|
||||||
|
// From crop and scale, cropping section
|
||||||
float OS_CROP_TOP;
|
float OS_CROP_TOP;
|
||||||
float OS_CROP_BOTTOM;
|
float OS_CROP_BOTTOM;
|
||||||
float OS_CROP_LEFT;
|
float OS_CROP_LEFT;
|
||||||
float OS_CROP_RIGHT;
|
float OS_CROP_RIGHT;
|
||||||
float SAMPLE_SIZE;
|
|
||||||
}
|
}
|
||||||
param;
|
param;
|
||||||
|
|
||||||
|
|
|
@ -1,22 +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.6 settings ===" 0.0 0.0 1.0 1.0
|
#pragma parameter AVERAGE_FILL_SETTINGS "=== Average fill v1.7 settings ===" 0.0 0.0 1.0 1.0
|
||||||
|
|
||||||
#pragma parameter SCALING_SETTINGS "= Scaling parameters =" 0.0 0.0 1.0 1.0
|
#include "../../../misc/shaders/crop_and_scale/parameters.slang"
|
||||||
#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 = unchanged)" 0.0 0.0 256.0 1.0
|
|
||||||
#pragma parameter ASPECT_V "Vertical aspect ratio before crop (0 = unchanged)" 0.0 0.0 256.0 1.0
|
|
||||||
#pragma parameter FORCE_INTEGER_SCALING_H "Force integer scaling horizontally" 0.0 0.0 1.0 1.0
|
|
||||||
#pragma parameter FORCE_INTEGER_SCALING_V "Force integer scaling vertically" 1.0 0.0 1.0 1.0
|
|
||||||
|
|
||||||
#pragma parameter CROPPING_SETTINGS "= Cropping parameters =" 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
|
|
||||||
|
|
||||||
#pragma parameter CENTER_AFTER_CROPPING "Center cropped area" 1.0 0.0 1.0 1.0
|
|
||||||
|
|
||||||
#pragma parameter OTHER_SETTINGS "= Other parameters =" 0.0 0.0 1.0 1.0
|
#pragma parameter OTHER_SETTINGS "= Other parameters =" 0.0 0.0 1.0 1.0
|
||||||
#pragma parameter EXTEND_H "Extend the fill horizontally" 1.0 0.0 1.0 1.0
|
#pragma parameter EXTEND_H "Extend the fill horizontally" 1.0 0.0 1.0 1.0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Blur fill v1.7 by fishku
|
Blur fill v1.8 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.8: Add overscale option from crop and scale library.
|
||||||
v1.7: Refactor for new scaling library. Add rotation support.
|
v1.7: Refactor for new scaling library. Add rotation support.
|
||||||
v1.6: Optimize. Update to new Pixel AA version. Tune default blur strength.
|
v1.6: Optimize. Update to new Pixel AA version. Tune default blur strength.
|
||||||
v1.5: Add anti-aliased interpolation for non-integer scaling.
|
v1.5: Add anti-aliased interpolation for non-integer scaling.
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
#include "../../../pixel-art-scaling/shaders/pixel_aa/parameters.slang"
|
#include "../../../pixel-art-scaling/shaders/pixel_aa/parameters.slang"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#include "../../../misc/shaders/scaling.slang"
|
#include "../../../misc/shaders/crop_and_scale/crop_and_scale.slang"
|
||||||
#include "../../../pixel-art-scaling/shaders/pixel_aa/shared.slang"
|
#include "../../../pixel-art-scaling/shaders/pixel_aa/shared.slang"
|
||||||
|
|
||||||
layout(push_constant) uniform Push {
|
layout(push_constant) uniform Push {
|
||||||
|
@ -51,18 +52,22 @@ layout(push_constant) uniform Push {
|
||||||
vec4 TiledSize;
|
vec4 TiledSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint Rotation;
|
uint Rotation;
|
||||||
float OS_CROP_TOP;
|
// Own settings
|
||||||
float OS_CROP_BOTTOM;
|
float FILL_GAMMA;
|
||||||
float OS_CROP_LEFT;
|
|
||||||
float OS_CROP_RIGHT;
|
|
||||||
float CENTER_AFTER_CROPPING;
|
|
||||||
float SAMPLE_SIZE;
|
float SAMPLE_SIZE;
|
||||||
|
// From crop and scale, scaling section
|
||||||
float FORCE_ASPECT_RATIO;
|
float FORCE_ASPECT_RATIO;
|
||||||
float ASPECT_H;
|
float ASPECT_H;
|
||||||
float ASPECT_V;
|
float ASPECT_V;
|
||||||
float FORCE_INTEGER_SCALING_H;
|
float FORCE_INTEGER_SCALING_H;
|
||||||
float FORCE_INTEGER_SCALING_V;
|
float FORCE_INTEGER_SCALING_V;
|
||||||
float FILL_GAMMA;
|
float OVERSCALE;
|
||||||
|
// From crop and scale, cropping section
|
||||||
|
float OS_CROP_TOP;
|
||||||
|
float OS_CROP_BOTTOM;
|
||||||
|
float OS_CROP_LEFT;
|
||||||
|
float OS_CROP_RIGHT;
|
||||||
|
float CENTER_AFTER_CROPPING;
|
||||||
// From dual filter blur
|
// From dual filter blur
|
||||||
float BLUR_RADIUS;
|
float BLUR_RADIUS;
|
||||||
// From pixel AA
|
// From pixel AA
|
||||||
|
@ -94,6 +99,7 @@ void main() {
|
||||||
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
||||||
vec2(param.ASPECT_H, param.ASPECT_V),
|
vec2(param.ASPECT_H, param.ASPECT_V),
|
||||||
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V),
|
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V),
|
||||||
|
param.OVERSCALE,
|
||||||
/* output_size_is_final_viewport_size = */ false);
|
/* output_size_is_final_viewport_size = */ false);
|
||||||
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
||||||
param.CENTER_AFTER_CROPPING, scale_o2i);
|
param.CENTER_AFTER_CROPPING, scale_o2i);
|
||||||
|
|
|
@ -1,22 +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 BLUR_FILL_SETTINGS "=== Blur fill v1.7 settings ===" 0.0 0.0 1.0 1.0
|
#pragma parameter BLUR_FILL_SETTINGS "=== Blur fill v1.8 settings ===" 0.0 0.0 1.0 1.0
|
||||||
|
|
||||||
#pragma parameter SCALING_SETTINGS "= Scaling parameters =" 0.0 0.0 1.0 1.0
|
#include "../../../misc/shaders/crop_and_scale/parameters.slang"
|
||||||
#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 = unchanged)" 0.0 0.0 256.0 1.0
|
|
||||||
#pragma parameter ASPECT_V "Vertical aspect ratio before crop (0 = unchanged)" 0.0 0.0 256.0 1.0
|
|
||||||
#pragma parameter FORCE_INTEGER_SCALING_H "Force integer scaling horizontally" 0.0 0.0 1.0 1.0
|
|
||||||
#pragma parameter FORCE_INTEGER_SCALING_V "Force integer scaling vertically" 1.0 0.0 1.0 1.0
|
|
||||||
|
|
||||||
#pragma parameter CROPPING_SETTINGS "= Cropping parameters =" 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
|
|
||||||
|
|
||||||
#pragma parameter CENTER_AFTER_CROPPING "Center cropped area" 1.0 0.0 1.0 1.0
|
|
||||||
|
|
||||||
#pragma parameter OTHER_SETTINGS "= Other parameters =" 0.0 0.0 1.0 1.0
|
#pragma parameter OTHER_SETTINGS "= Other parameters =" 0.0 0.0 1.0 1.0
|
||||||
#pragma parameter EXTEND_H "Extend the fill horizontally" 0.0 0.0 1.0 1.0
|
#pragma parameter EXTEND_H "Extend the fill horizontally" 0.0 0.0 1.0 1.0
|
||||||
|
|
|
@ -2,27 +2,31 @@
|
||||||
|
|
||||||
// See compose.slang for copyright and other information.
|
// See compose.slang for copyright and other information.
|
||||||
|
|
||||||
#include "../../../misc/shaders/scaling.slang"
|
#include "../../../misc/shaders/crop_and_scale/crop_and_scale.slang"
|
||||||
#include "parameters.slang"
|
#include "parameters.slang"
|
||||||
|
|
||||||
layout(push_constant) uniform Push {
|
layout(push_constant) uniform Push {
|
||||||
vec4 InputSize;
|
vec4 InputSize;
|
||||||
vec4 FinalViewportSize;
|
vec4 FinalViewportSize;
|
||||||
uint Rotation;
|
uint Rotation;
|
||||||
float OS_CROP_TOP;
|
// Own settings
|
||||||
float OS_CROP_BOTTOM;
|
|
||||||
float OS_CROP_LEFT;
|
|
||||||
float OS_CROP_RIGHT;
|
|
||||||
float CENTER_AFTER_CROPPING;
|
|
||||||
float SAMPLE_SIZE;
|
|
||||||
float EXTEND_H;
|
float EXTEND_H;
|
||||||
float EXTEND_V;
|
float EXTEND_V;
|
||||||
float MIRROR_BLUR;
|
float MIRROR_BLUR;
|
||||||
|
float SAMPLE_SIZE;
|
||||||
|
// From crop and scale, scaling section
|
||||||
float FORCE_ASPECT_RATIO;
|
float FORCE_ASPECT_RATIO;
|
||||||
float ASPECT_H;
|
float ASPECT_H;
|
||||||
float ASPECT_V;
|
float ASPECT_V;
|
||||||
float FORCE_INTEGER_SCALING_H;
|
float FORCE_INTEGER_SCALING_H;
|
||||||
float FORCE_INTEGER_SCALING_V;
|
float FORCE_INTEGER_SCALING_V;
|
||||||
|
float OVERSCALE;
|
||||||
|
// From crop and scale, cropping section
|
||||||
|
float OS_CROP_TOP;
|
||||||
|
float OS_CROP_BOTTOM;
|
||||||
|
float OS_CROP_LEFT;
|
||||||
|
float OS_CROP_RIGHT;
|
||||||
|
float CENTER_AFTER_CROPPING;
|
||||||
}
|
}
|
||||||
param;
|
param;
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ void main() {
|
||||||
param.InputSize.xy, param.FinalViewportSize.xy, crop, param.Rotation,
|
param.InputSize.xy, param.FinalViewportSize.xy, crop, param.Rotation,
|
||||||
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
param.CENTER_AFTER_CROPPING, param.FORCE_ASPECT_RATIO,
|
||||||
vec2(param.ASPECT_H, param.ASPECT_V),
|
vec2(param.ASPECT_H, param.ASPECT_V),
|
||||||
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V),
|
vec2(param.FORCE_INTEGER_SCALING_H, param.FORCE_INTEGER_SCALING_V), param.OVERSCALE,
|
||||||
/* output_size_is_final_viewport_size = */ true);
|
/* output_size_is_final_viewport_size = */ true);
|
||||||
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
tx_coord = o2i(vTexCoord, param.InputSize.xy, crop, param.Rotation,
|
||||||
param.CENTER_AFTER_CROPPING, scale_o2i);
|
param.CENTER_AFTER_CROPPING, scale_o2i);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Scaling library v1.0 by fishku
|
Cropping and scaling library v1.1 by fishku
|
||||||
Copyright (C) 2023
|
Copyright (C) 2023
|
||||||
Public domain license (CC0)
|
Public domain license (CC0)
|
||||||
|
|
||||||
|
@ -15,10 +15,12 @@
|
||||||
- Forcing of a certain aspect ratio
|
- Forcing of a certain aspect ratio
|
||||||
- Forcing of either vert. or horiz. integer scaling, or both
|
- Forcing of either vert. or horiz. integer scaling, or both
|
||||||
- Rotation support (0, 90, 180, 270 degrees).
|
- Rotation support (0, 90, 180, 270 degrees).
|
||||||
|
- Overscaling
|
||||||
|
|
||||||
Refactored from the version that used to be in the blur_fill shader.
|
Refactored from the version that used to be in the blur_fill shader.
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
v1.1: Add overscaling option. Unify parameters.
|
||||||
v1.0: Initial conversion from blur_fill release. Add rotation support.
|
v1.0: Initial conversion from blur_fill release. Add rotation support.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ vec2 get_input_center(vec2 input_size, vec4 crop, uint rotation,
|
||||||
// Scaling from unit output to pixel input space.
|
// Scaling from unit output to pixel input space.
|
||||||
vec2 get_scale_o2i(vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
vec2 get_scale_o2i(vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
||||||
float center_after_cropping, float force_aspect_ratio,
|
float center_after_cropping, float force_aspect_ratio,
|
||||||
vec2 aspect, vec2 force_integer_scaling,
|
vec2 aspect, vec2 force_integer_scaling, float overscale,
|
||||||
bool output_size_is_final_viewport_size) {
|
bool output_size_is_final_viewport_size) {
|
||||||
crop = get_rotated_crop(crop, rotation);
|
crop = get_rotated_crop(crop, rotation);
|
||||||
if (output_size_is_final_viewport_size) {
|
if (output_size_is_final_viewport_size) {
|
||||||
|
@ -96,7 +98,9 @@ vec2 get_scale_o2i(vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
||||||
output_size.y / (input_size.y * aspect.y)) {
|
output_size.y / (input_size.y * 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 = output_size.x / input_size.x;
|
scale_x = mix(output_size.x / input_size.x,
|
||||||
|
output_size.y * aspect.x / (input_size.y * aspect.y),
|
||||||
|
overscale);
|
||||||
if (force_integer_scaling.x > 0.5 && scale_x > 1.0) {
|
if (force_integer_scaling.x > 0.5 && scale_x > 1.0) {
|
||||||
scale_x = floor(scale_x);
|
scale_x = floor(scale_x);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +110,9 @@ vec2 get_scale_o2i(vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Scale will be limited by height.
|
// Scale will be limited by height.
|
||||||
scale_y = output_size.y / input_size.y;
|
scale_y = mix(output_size.y / input_size.y,
|
||||||
|
output_size.x * aspect.y / (input_size.x * aspect.x),
|
||||||
|
overscale);
|
||||||
if (force_integer_scaling.y > 0.5 && scale_y > 1.0) {
|
if (force_integer_scaling.y > 0.5 && scale_y > 1.0) {
|
||||||
scale_y = floor(scale_y);
|
scale_y = floor(scale_y);
|
||||||
}
|
}
|
||||||
|
@ -131,11 +137,12 @@ vec2 o2i(vec2 x, vec2 input_size, vec4 crop, uint rotation,
|
||||||
// Version that computes scale.
|
// Version that computes scale.
|
||||||
vec2 o2i(vec2 x, vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
vec2 o2i(vec2 x, vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
||||||
float center_after_cropping, float force_aspect_ratio, vec2 aspect,
|
float center_after_cropping, float force_aspect_ratio, vec2 aspect,
|
||||||
vec2 force_integer_scaling, bool output_size_is_final_viewport_size) {
|
vec2 force_integer_scaling, float overscale,
|
||||||
|
bool output_size_is_final_viewport_size) {
|
||||||
return o2i(x, input_size, crop, rotation, center_after_cropping,
|
return o2i(x, input_size, crop, rotation, center_after_cropping,
|
||||||
get_scale_o2i(input_size, output_size, crop, rotation,
|
get_scale_o2i(input_size, output_size, crop, rotation,
|
||||||
center_after_cropping, force_aspect_ratio, aspect,
|
center_after_cropping, force_aspect_ratio, aspect,
|
||||||
force_integer_scaling,
|
force_integer_scaling, overscale,
|
||||||
output_size_is_final_viewport_size));
|
output_size_is_final_viewport_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,12 +159,13 @@ vec2 i2o(vec2 x, vec2 input_size, vec4 crop, uint rotation,
|
||||||
// Version that computes scale.
|
// Version that computes scale.
|
||||||
vec2 i2o(vec2 x, vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
vec2 i2o(vec2 x, vec2 input_size, vec2 output_size, vec4 crop, uint rotation,
|
||||||
float center_after_cropping, float force_aspect_ratio, vec2 aspect,
|
float center_after_cropping, float force_aspect_ratio, vec2 aspect,
|
||||||
vec2 force_integer_scaling, bool output_size_is_final_viewport_size) {
|
vec2 force_integer_scaling, float overscale,
|
||||||
|
bool output_size_is_final_viewport_size) {
|
||||||
return (x - get_input_center(input_size, crop, rotation,
|
return (x - get_input_center(input_size, crop, rotation,
|
||||||
center_after_cropping)) /
|
center_after_cropping)) /
|
||||||
get_scale_o2i(input_size, output_size, crop, rotation,
|
get_scale_o2i(input_size, output_size, crop, rotation,
|
||||||
center_after_cropping, force_aspect_ratio, aspect,
|
center_after_cropping, force_aspect_ratio, aspect,
|
||||||
force_integer_scaling,
|
force_integer_scaling, overscale,
|
||||||
output_size_is_final_viewport_size) +
|
output_size_is_final_viewport_size) +
|
||||||
0.49999;
|
0.49999;
|
||||||
}
|
}
|
18
misc/shaders/crop_and_scale/parameters.slang
Normal file
18
misc/shaders/crop_and_scale/parameters.slang
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// clang-format off
|
||||||
|
#pragma parameter SCALING_SETTINGS "= Scaling parameters =" 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 (0 = unchanged)" 0.0 0.0 256.0 1.0
|
||||||
|
#pragma parameter ASPECT_V "Vertical aspect ratio before crop (0 = unchanged)" 0.0 0.0 256.0 1.0
|
||||||
|
#pragma parameter FORCE_INTEGER_SCALING_H "Force integer scaling horizontally" 0.0 0.0 1.0 1.0
|
||||||
|
#pragma parameter FORCE_INTEGER_SCALING_V "Force integer scaling vertically" 0.0 0.0 1.0 1.0
|
||||||
|
|
||||||
|
#pragma parameter OVERSCALE "Overscale (0 = full image, 1 = full screen)" 0.0 0.0 1.0 0.01
|
||||||
|
|
||||||
|
#pragma parameter CROPPING_SETTINGS "= Cropping parameters =" 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
|
||||||
|
|
||||||
|
#pragma parameter CENTER_AFTER_CROPPING "Center cropped area" 1.0 0.0 1.0 1.0
|
||||||
|
// clang-format on
|
Loading…
Reference in a new issue