Merge branch 'master' into non-uniform-border-radius-for-quads
This commit is contained in:
commit
4029a1cdaa
147 changed files with 4828 additions and 2184 deletions
|
|
@ -1,20 +1,20 @@
|
|||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#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
|
||||
layout (location = 0) out vec4 fragColor;
|
||||
#define gl_FragColor fragColor
|
||||
#endif
|
||||
|
||||
in vec2 raw_position;
|
||||
|
||||
uniform vec4 gradient_direction;
|
||||
uniform uint color_stops_size;
|
||||
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];
|
||||
|
|
@ -28,23 +28,23 @@ void main() {
|
|||
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
|
||||
fragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
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 - 1u].x;
|
||||
float max_offset = color_stops[color_stops_size - 1].x;
|
||||
|
||||
for (uint i = 0u; i < color_stops_size - 2u; i += 2u) {
|
||||
float curr_offset = color_stops[i+1u].x;
|
||||
float next_offset = color_stops[i+3u].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
|
||||
fragColor = color_stops[0];
|
||||
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
|
||||
fragColor = mix(color_stops[i], color_stops[i+2u], smoothstep(
|
||||
gl_FragColor = mix(color_stops[i], color_stops[i+2], smoothstep(
|
||||
curr_offset,
|
||||
next_offset,
|
||||
coord_offset
|
||||
|
|
@ -53,7 +53,7 @@ void main() {
|
|||
|
||||
if (coord_offset >= max_offset) {
|
||||
//current coordinate is before the last defined offset, set it to the last color
|
||||
fragColor = color_stops[color_stops_size - 2u];
|
||||
gl_FragColor = color_stops[color_stops_size - 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
glow/src/shader/common/image.frag
Normal file
22
glow/src/shader/common/image.frag
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#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);
|
||||
}
|
||||
9
glow/src/shader/common/image.vert
Normal file
9
glow/src/shader/common/image.vert
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ out vec4 fragColor;
|
|||
#define gl_FragColor fragColor
|
||||
#endif
|
||||
|
||||
uniform vec4 color;
|
||||
in vec4 v_Color;
|
||||
|
||||
void main() {
|
||||
fragColor = color;
|
||||
gl_FragColor = v_Color;
|
||||
}
|
||||
11
glow/src/shader/common/solid.vert
Normal file
11
glow/src/shader/common/solid.vert
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue