summaryrefslogtreecommitdiffstats
path: root/glow/src/shader/compatibility
diff options
context:
space:
mode:
Diffstat (limited to 'glow/src/shader/compatibility')
-rw-r--r--glow/src/shader/compatibility/quad.frag83
-rw-r--r--glow/src/shader/compatibility/quad.vert46
2 files changed, 0 insertions, 129 deletions
diff --git a/glow/src/shader/compatibility/quad.frag b/glow/src/shader/compatibility/quad.frag
deleted file mode 100644
index bb9d8122..00000000
--- a/glow/src/shader/compatibility/quad.frag
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-
-uniform float u_ScreenHeight;
-
-varying vec4 v_Color;
-varying vec4 v_BorderColor;
-varying vec2 v_Pos;
-varying vec2 v_Scale;
-varying vec4 v_BorderRadius;
-varying float v_BorderWidth;
-
-float _distance(vec2 frag_coord, vec2 position, vec2 size, float radius)
-{
- // TODO: Try SDF approach: https://www.shadertoy.com/view/wd3XRN
- vec2 inner_size = size - vec2(radius, radius) * 2.0;
- vec2 top_left = position + vec2(radius, radius);
- vec2 bottom_right = top_left + inner_size;
-
- vec2 top_left_distance = top_left - frag_coord;
- vec2 bottom_right_distance = frag_coord - bottom_right;
-
- vec2 distance = vec2(
- max(max(top_left_distance.x, bottom_right_distance.x), 0.0),
- max(max(top_left_distance.y, bottom_right_distance.y), 0.0)
- );
-
- return sqrt(distance.x * distance.x + distance.y * distance.y);
-}
-
-float selectBorderRadius(vec4 radi, vec2 position, vec2 center)
-{
- float rx = radi.x;
- float ry = radi.y;
- rx = position.x > center.x ? radi.y : radi.x;
- ry = position.x > center.x ? radi.z : radi.w;
- rx = position.y > center.y ? ry : rx;
- return rx;
-}
-
-void main() {
- vec2 fragCoord = vec2(gl_FragCoord.x, u_ScreenHeight - gl_FragCoord.y);
-
- float border_radius = selectBorderRadius(
- v_BorderRadius,
- fragCoord,
- (v_Pos + v_Scale * 0.5).xy
- );
-
- float internal_border = max(border_radius - v_BorderWidth, 0.0);
-
- float internal_distance = _distance(
- fragCoord,
- v_Pos + vec2(v_BorderWidth),
- v_Scale - vec2(v_BorderWidth * 2.0),
- internal_border
- );
-
- float border_mix = smoothstep(
- max(internal_border - 0.5, 0.0),
- internal_border + 0.5,
- internal_distance
- );
-
- vec4 mixed_color = mix(v_Color, v_BorderColor, border_mix);
-
- float d = _distance(
- fragCoord,
- v_Pos,
- v_Scale,
- border_radius
- );
-
- float radius_alpha =
- 1.0 - smoothstep(max(border_radius - 0.5, 0.0), border_radius + 0.5, d);
-
- gl_FragColor = vec4(mixed_color.xyz, mixed_color.w * radius_alpha);
-}
diff --git a/glow/src/shader/compatibility/quad.vert b/glow/src/shader/compatibility/quad.vert
deleted file mode 100644
index 89931f06..00000000
--- a/glow/src/shader/compatibility/quad.vert
+++ /dev/null
@@ -1,46 +0,0 @@
-uniform mat4 u_Transform;
-uniform float u_Scale;
-
-attribute vec2 i_Pos;
-attribute vec2 i_Scale;
-attribute vec4 i_Color;
-attribute vec4 i_BorderColor;
-attribute vec4 i_BorderRadius;
-attribute float i_BorderWidth;
-attribute vec2 q_Pos;
-
-varying vec4 v_Color;
-varying vec4 v_BorderColor;
-varying vec2 v_Pos;
-varying vec2 v_Scale;
-varying vec4 v_BorderRadius;
-varying float v_BorderWidth;
-
-
-void main() {
- vec2 p_Pos = i_Pos * u_Scale;
- vec2 p_Scale = i_Scale * u_Scale;
-
- vec4 i_BorderRadius = vec4(
- min(i_BorderRadius.x, min(i_Scale.x, i_Scale.y) / 2.0),
- min(i_BorderRadius.y, min(i_Scale.x, i_Scale.y) / 2.0),
- min(i_BorderRadius.z, min(i_Scale.x, i_Scale.y) / 2.0),
- min(i_BorderRadius.w, min(i_Scale.x, i_Scale.y) / 2.0)
- );
-
- mat4 i_Transform = mat4(
- vec4(p_Scale.x + 1.0, 0.0, 0.0, 0.0),
- vec4(0.0, p_Scale.y + 1.0, 0.0, 0.0),
- vec4(0.0, 0.0, 1.0, 0.0),
- vec4(p_Pos - vec2(0.5, 0.5), 0.0, 1.0)
- );
-
- v_Color = i_Color;
- v_BorderColor = i_BorderColor;
- v_Pos = p_Pos;
- v_Scale = p_Scale;
- v_BorderRadius = i_BorderRadius * u_Scale;
- v_BorderWidth = i_BorderWidth * u_Scale;
-
- gl_Position = u_Transform * i_Transform * vec4(q_Pos, 0.0, 1.0);
-}