summaryrefslogtreecommitdiffstats
path: root/glow/src/shader
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-01-06 23:29:38 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-24 13:17:58 +0100
commitb9a9576207ddfc7afd89da30b7cfc7ca0d7e335c (patch)
treec0b4489f1e547fc335e6b82025891cefdc671274 /glow/src/shader
parent573d27eb52bbfacf1b06983b4282f00eb5265bdc (diff)
downloadiced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.tar.gz
iced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.tar.bz2
iced-b9a9576207ddfc7afd89da30b7cfc7ca0d7e335c.zip
Remove `iced_glow`, `glyph-brush`, and `wgpu_glyph` dependencies
Diffstat (limited to 'glow/src/shader')
-rw-r--r--glow/src/shader/common/gradient.frag59
-rw-r--r--glow/src/shader/common/gradient.vert9
-rw-r--r--glow/src/shader/common/image.frag22
-rw-r--r--glow/src/shader/common/image.vert9
-rw-r--r--glow/src/shader/common/solid.frag18
-rw-r--r--glow/src/shader/common/solid.vert11
-rw-r--r--glow/src/shader/compatibility/quad.frag83
-rw-r--r--glow/src/shader/compatibility/quad.vert46
-rw-r--r--glow/src/shader/core/quad.frag95
-rw-r--r--glow/src/shader/core/quad.vert52
10 files changed, 0 insertions, 404 deletions
diff --git a/glow/src/shader/common/gradient.frag b/glow/src/shader/common/gradient.frag
deleted file mode 100644
index 9af0cb6e..00000000
--- a/glow/src/shader/common/gradient.frag
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-
-#ifdef HIGHER_THAN_300
-layout (location = 0) out vec4 fragColor;
-#define gl_FragColor fragColor
-#endif
-
-in vec2 raw_position;
-
-uniform vec4 gradient_direction;
-uniform int color_stops_size;
-// GLSL does not support dynamically sized arrays without SSBOs so this is capped to 16 stops
-//stored as color(vec4) -> offset(vec4) sequentially;
-uniform vec4 color_stops[32];
-
-//TODO: rewrite without branching to make ALUs happy
-void main() {
- vec2 start = gradient_direction.xy;
- vec2 end = gradient_direction.zw;
- vec2 gradient_vec = vec2(end - start);
- vec2 current_vec = vec2(raw_position.xy - start);
- vec2 unit = normalize(gradient_vec);
- float coord_offset = dot(unit, current_vec) / length(gradient_vec);
- //if a gradient has a start/end stop that is identical, the mesh will have a transparent fill
- gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
-
- float min_offset = color_stops[1].x;
- float max_offset = color_stops[color_stops_size - 1].x;
-
- for (int i = 0; i < color_stops_size - 2; i += 2) {
- float curr_offset = color_stops[i+1].x;
- float next_offset = color_stops[i+3].x;
-
- if (coord_offset <= min_offset) {
- //current coordinate is before the first defined offset, set it to the start color
- gl_FragColor = color_stops[0];
- }
-
- if (curr_offset <= coord_offset && coord_offset <= next_offset) {
- //current fragment is between the current offset processing & the next one, interpolate colors
- gl_FragColor = mix(color_stops[i], color_stops[i+2], smoothstep(
- curr_offset,
- next_offset,
- coord_offset
- ));
- }
-
- if (coord_offset >= max_offset) {
- //current coordinate is before the last defined offset, set it to the last color
- gl_FragColor = color_stops[color_stops_size - 2];
- }
- }
-}
diff --git a/glow/src/shader/common/gradient.vert b/glow/src/shader/common/gradient.vert
deleted file mode 100644
index fe505997..00000000
--- a/glow/src/shader/common/gradient.vert
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform mat4 u_Transform;
-
-in vec2 i_Position;
-out vec2 raw_position;
-
-void main() {
- gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0);
- raw_position = i_Position;
-}
diff --git a/glow/src/shader/common/image.frag b/glow/src/shader/common/image.frag
deleted file mode 100644
index 5e05abdf..00000000
--- a/glow/src/shader/common/image.frag
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-
-uniform sampler2D tex;
-in vec2 tex_pos;
-
-#ifdef HIGHER_THAN_300
-out vec4 fragColor;
-#define gl_FragColor fragColor
-#endif
-#ifdef GL_ES
-#define texture texture2D
-#endif
-
-void main() {
- gl_FragColor = texture(tex, tex_pos);
-}
diff --git a/glow/src/shader/common/image.vert b/glow/src/shader/common/image.vert
deleted file mode 100644
index 93e541f2..00000000
--- a/glow/src/shader/common/image.vert
+++ /dev/null
@@ -1,9 +0,0 @@
-uniform mat4 u_Transform;
-
-in vec2 i_Position;
-out vec2 tex_pos;
-
-void main() {
- gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0);
- tex_pos = i_Position;
-}
diff --git a/glow/src/shader/common/solid.frag b/glow/src/shader/common/solid.frag
deleted file mode 100644
index 174ffdd3..00000000
--- a/glow/src/shader/common/solid.frag
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-
-#ifdef HIGHER_THAN_300
-out vec4 fragColor;
-#define gl_FragColor fragColor
-#endif
-
-in vec4 v_Color;
-
-void main() {
- gl_FragColor = v_Color;
-}
diff --git a/glow/src/shader/common/solid.vert b/glow/src/shader/common/solid.vert
deleted file mode 100644
index 59ed88e5..00000000
--- a/glow/src/shader/common/solid.vert
+++ /dev/null
@@ -1,11 +0,0 @@
-uniform mat4 u_Transform;
-
-in vec2 i_Position;
-in vec4 i_Color;
-
-out vec4 v_Color;
-
-void main() {
- gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0);
- v_Color = i_Color;
-}
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);
-}
diff --git a/glow/src/shader/core/quad.frag b/glow/src/shader/core/quad.frag
deleted file mode 100644
index 71147aa5..00000000
--- a/glow/src/shader/core/quad.frag
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifdef GL_ES
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-precision highp float;
-#else
-precision mediump float;
-#endif
-#endif
-
-#ifdef HIGHER_THAN_300
-out vec4 fragColor;
-#define gl_FragColor fragColor
-#endif
-
-uniform float u_ScreenHeight;
-
-in vec4 v_Color;
-in vec4 v_BorderColor;
-in vec2 v_Pos;
-in vec2 v_Scale;
-in vec4 v_BorderRadius;
-in float v_BorderWidth;
-
-float fDistance(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() {
- vec4 mixed_color;
-
- 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
- );
-
- // TODO: Remove branching (?)
- if(v_BorderWidth > 0.0) {
- float internal_border = max(border_radius - v_BorderWidth, 0.0);
-
- float internal_distance = fDistance(
- 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
- );
-
- mixed_color = mix(v_Color, v_BorderColor, border_mix);
- } else {
- mixed_color = v_Color;
- }
-
- float d = fDistance(
- 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/core/quad.vert b/glow/src/shader/core/quad.vert
deleted file mode 100644
index 17c3e641..00000000
--- a/glow/src/shader/core/quad.vert
+++ /dev/null
@@ -1,52 +0,0 @@
-uniform mat4 u_Transform;
-uniform float u_Scale;
-
-in vec2 i_Pos;
-in vec2 i_Scale;
-in vec4 i_Color;
-in vec4 i_BorderColor;
-in vec4 i_BorderRadius;
-in float i_BorderWidth;
-
-out vec4 v_Color;
-out vec4 v_BorderColor;
-out vec2 v_Pos;
-out vec2 v_Scale;
-out vec4 v_BorderRadius;
-out float v_BorderWidth;
-
-vec2 positions[4] = vec2[](
- vec2(0.0, 0.0),
- vec2(0.0, 1.0),
- vec2(1.0, 0.0),
- vec2(1.0, 1.0)
-);
-
-void main() {
- vec2 q_Pos = positions[gl_VertexID];
- 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);
-}