Initial commit
This commit is contained in:
68
extracted/assets/minecraft/shaders/core/blur.fsh
Normal file
68
extracted/assets/minecraft/shaders/core/blur.fsh
Normal file
@@ -0,0 +1,68 @@
|
||||
#version 150
|
||||
|
||||
uniform vec2 size;
|
||||
uniform vec2 location;
|
||||
uniform vec4 radius;
|
||||
uniform float thickness;
|
||||
uniform float softness;
|
||||
|
||||
uniform sampler2D InputSampler;
|
||||
uniform vec2 InputResolution;
|
||||
uniform float Quality;
|
||||
|
||||
uniform vec4 color1;
|
||||
uniform vec4 color2;
|
||||
uniform vec4 color3;
|
||||
uniform vec4 color4;
|
||||
uniform vec4 outlineColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
float roundedBoxSDF(vec2 center, vec2 size, vec4 radius) {
|
||||
radius.xy = (center.x > 0.0) ? radius.xy : radius.zw;
|
||||
radius.x = (center.y > 0.0) ? radius.x : radius.y;
|
||||
|
||||
vec2 q = abs(center) - size + radius.x;
|
||||
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius.x;
|
||||
}
|
||||
|
||||
vec4 createGradient(vec2 coords, vec4 color1, vec4 color2, vec4 color3, vec4 color4){
|
||||
vec4 color = mix(mix(color1, color2, coords.y), mix(color3, color4, coords.y), coords.x);
|
||||
color += mix(0.0019607843, -0.0019607843, fract(sin(dot(coords.xy, vec2(12.9898, 78.233))) * 43758.5453));
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 blur() {
|
||||
#define TAU 6.28318530718
|
||||
vec4 rectColor = createGradient((gl_FragCoord.xy - location) / size, color1, color2, color3, color4);
|
||||
vec2 Radius = Quality / InputResolution.xy;
|
||||
vec2 uv = gl_FragCoord.xy / InputResolution.xy;
|
||||
vec4 blur = texture(InputSampler, uv);
|
||||
|
||||
float step = TAU / 16;
|
||||
|
||||
for (float d = 0.0; d < TAU; d += step) {
|
||||
for (float i = 0.2; i <= 1.0; i += 0.2) {
|
||||
blur += texture(InputSampler, uv + vec2(cos(d), sin(d)) * Radius * i);
|
||||
}
|
||||
}
|
||||
|
||||
blur /= 60;
|
||||
return vec4((blur * (1 - rectColor.a)).rgb, rectColor.a) + rectColor;
|
||||
}
|
||||
|
||||
void main() {
|
||||
float distance = roundedBoxSDF(gl_FragCoord.xy - location - (size / 2.0), size / 2.0, radius);
|
||||
float smoothedAlpha = 1.0 - smoothstep(-1.0, thickness > 0. ? 1. : softness + 1., distance);
|
||||
|
||||
if(smoothedAlpha < 0.49 && thickness > 0.) {
|
||||
float smoothedborderAlpha = (1.0 - smoothstep(-softness, softness, distance));
|
||||
fragColor = vec4(outlineColor.rgb, smoothedborderAlpha * outlineColor.a);
|
||||
} else {
|
||||
float borderAlpha = 1.0 - smoothstep(thickness - 2.0, thickness, abs(distance));
|
||||
vec4 blur = blur();
|
||||
vec4 basicColor = vec4(blur.rgb, blur.a * smoothedAlpha);
|
||||
fragColor = mix(vec4(blur.rgb, 0.), mix(basicColor, thickness > 0. ? outlineColor : basicColor, borderAlpha), smoothedAlpha);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user