Skip to content

Commit

Permalink
smootherstep fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizzie841 authored Jan 26, 2025
1 parent 18bb2ed commit 2dd0aa6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion assets/shaders/glsl/ui_f_shader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,21 @@ vec4 border_filter(vec2 tc) {
return vec4(vec3(1.0, 1.0, 1.0) - inner_color, sm_val);
}
}
// Smootherstep function
// https://en.wikipedia.org/wiki/Smoothstep
float smootherstep(float edge0, float edge1, float x) {
// Scale, and clamp x to 0..1 range
x = clamp((x - edge0) / (edge1 - edge0), 0.f, 1.f);
return x * x * x * (x * (6.0f * x - 15.0f) + 10.0f);
}
//layout(index = 1) subroutine(font_function_class)
vec4 color_filter(vec2 tc) {
vec4 color_in = texture(texture_sampler, tc);
float sm_val = smoothstep(0.5 - border_size / 2.0, 0.5 + border_size / 2.0, color_in.r);
float sm_val = smootherstep(
0.5f - border_size * 0.5f,
0.5f + border_size * 0.5f,
color_in.r
);
return vec4(inner_color, sm_val);
}
//layout(index = 2) subroutine(font_function_class)
Expand Down

0 comments on commit 2dd0aa6

Please sign in to comment.