diff options
Diffstat (limited to 'src/imports/shapes/shaders')
-rw-r--r-- | src/imports/shapes/shaders/conicalgradient.frag | 19 | ||||
-rw-r--r-- | src/imports/shapes/shaders/conicalgradient.vert | 13 | ||||
-rw-r--r-- | src/imports/shapes/shaders/conicalgradient_core.frag | 22 | ||||
-rw-r--r-- | src/imports/shapes/shaders/conicalgradient_core.vert | 15 |
4 files changed, 69 insertions, 0 deletions
diff --git a/src/imports/shapes/shaders/conicalgradient.frag b/src/imports/shapes/shaders/conicalgradient.frag new file mode 100644 index 0000000000..af5fdd5ee0 --- /dev/null +++ b/src/imports/shapes/shaders/conicalgradient.frag @@ -0,0 +1,19 @@ +#define INVERSE_2PI 0.1591549430918953358 + +uniform sampler2D gradTabTexture; +uniform lowp float opacity; + +uniform highp float angle; + +varying highp vec2 coord; + +void main() +{ + highp float t; + if (abs(coord.y) == abs(coord.x)) + t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI; + else + t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI; + gl_FragColor = texture2D(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity; + +} diff --git a/src/imports/shapes/shaders/conicalgradient.vert b/src/imports/shapes/shaders/conicalgradient.vert new file mode 100644 index 0000000000..3350b0675a --- /dev/null +++ b/src/imports/shapes/shaders/conicalgradient.vert @@ -0,0 +1,13 @@ +attribute vec4 vertexCoord; +attribute vec4 vertexColor; + +uniform mat4 matrix; +uniform vec2 translationPoint; + +varying vec2 coord; + +void main() +{ + coord = vertexCoord.xy - translationPoint; + gl_Position = matrix * vertexCoord; +} diff --git a/src/imports/shapes/shaders/conicalgradient_core.frag b/src/imports/shapes/shaders/conicalgradient_core.frag new file mode 100644 index 0000000000..e18b80159a --- /dev/null +++ b/src/imports/shapes/shaders/conicalgradient_core.frag @@ -0,0 +1,22 @@ +#version 150 core + +#define INVERSE_2PI 0.1591549430918953358 + +uniform sampler2D gradTabTexture; +uniform float opacity; + +uniform float angle; + +in vec2 coord; + +out vec4 fragColor; + +void main() +{ + float t; + if (abs(coord.y) == abs(coord.x)) + t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI; + else + t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI; + fragColor = texture(gradTabTexture, vec2(t - floor(t), 0.5)) * opacity; +} diff --git a/src/imports/shapes/shaders/conicalgradient_core.vert b/src/imports/shapes/shaders/conicalgradient_core.vert new file mode 100644 index 0000000000..f94a56401b --- /dev/null +++ b/src/imports/shapes/shaders/conicalgradient_core.vert @@ -0,0 +1,15 @@ +#version 150 core + +in vec4 vertexCoord; +in vec4 vertexColor; + +uniform mat4 matrix; +uniform vec2 translationPoint; + +out vec2 coord; + +void main() +{ + coord = vertexCoord.xy - translationPoint; + gl_Position = matrix * vertexCoord; +} |