mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-29 19:01:31 +11:00
(sharp-bilinear) Add parameters
This commit is contained in:
parent
6a8527a94e
commit
e410ff0886
|
@ -1,5 +1,10 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
float SHARP_BILINEAR_PRE_SCALE;
|
||||||
|
} param;
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
|
@ -9,7 +14,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sharp-bilinear.cg
|
* sharp-bilinear.slang
|
||||||
* Author: Themaister
|
* Author: Themaister
|
||||||
* License: Public domain
|
* License: Public domain
|
||||||
*
|
*
|
||||||
|
@ -17,7 +22,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
* sharper image than plain bilinear.
|
* sharper image than plain bilinear.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SHARP_BILINEAR_PRE_SCALE 4.0
|
#pragma parameter SHARP_BILINEAR_PRE_SCALE "Sharp Bilinear Prescale" 4.0 1.0 10.0 1.0
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
|
@ -40,13 +45,13 @@ void main()
|
||||||
vec2 texel = vTexCoord * global.SourceSize.xy;
|
vec2 texel = vTexCoord * global.SourceSize.xy;
|
||||||
vec2 texel_floored = floor(texel);
|
vec2 texel_floored = floor(texel);
|
||||||
vec2 s = fract(texel);
|
vec2 s = fract(texel);
|
||||||
float region_range = 0.5 - 0.5 / SHARP_BILINEAR_PRE_SCALE;
|
float region_range = 0.5 - 0.5 / param.SHARP_BILINEAR_PRE_SCALE;
|
||||||
|
|
||||||
// Figure out where in the texel to sample to get correct pre-scaled bilinear.
|
// Figure out where in the texel to sample to get correct pre-scaled bilinear.
|
||||||
// Uses the hardware bilinear interpolator to avoid having to sample 4 times manually.
|
// Uses the hardware bilinear interpolator to avoid having to sample 4 times manually.
|
||||||
|
|
||||||
vec2 center_dist = s - 0.5;
|
vec2 center_dist = s - 0.5;
|
||||||
vec2 f = (center_dist - clamp(center_dist, -region_range, region_range)) * SHARP_BILINEAR_PRE_SCALE + 0.5;
|
vec2 f = (center_dist - clamp(center_dist, -region_range, region_range)) * param.SHARP_BILINEAR_PRE_SCALE + 0.5;
|
||||||
|
|
||||||
vec2 mod_texel = texel_floored + f;
|
vec2 mod_texel = texel_floored + f;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue