summaryrefslogtreecommitdiff
path: root/themes/src/_shaders/sun.vert
diff options
context:
space:
mode:
authorMatt Kosarek <matt.kosarek@canonical.com>2025-12-29 10:02:38 -0500
committerMatt Kosarek <matt.kosarek@canonical.com>2025-12-29 10:02:38 -0500
commitfbc5d7dd1a9192c29daccdf12a7a067037ff2c2a (patch)
tree399ade27d2e76a40956aa45a789db98841e5ae62 /themes/src/_shaders/sun.vert
parent301d0aa4d61b21d4daf703672aa4b1d438651296 (diff)
Improve the sun shader with the help of AI
Diffstat (limited to 'themes/src/_shaders/sun.vert')
-rw-r--r--themes/src/_shaders/sun.vert27
1 files changed, 18 insertions, 9 deletions
diff --git a/themes/src/_shaders/sun.vert b/themes/src/_shaders/sun.vert
index 76150f0..5ed77d7 100644
--- a/themes/src/_shaders/sun.vert
+++ b/themes/src/_shaders/sun.vert
@@ -1,13 +1,22 @@
-attribute vec2 position;
-attribute vec4 color;
-attribute mat4 vMatrix;
-uniform mat4 projection;
-uniform mat4 model;
+attribute vec2 position;
+attribute vec4 color;
+attribute mat4 vMatrix;
+uniform mat4 projection;
+uniform mat4 model;
varying lowp vec4 VertexColor;
+varying lowp vec2 TexCoord;
-void main() {
- vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1);
- gl_Position = fragmentPosition;
- VertexColor = color;
+void main() {
+ vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1);
+ gl_Position = fragmentPosition;
+ VertexColor = color;
+ // Normalize the position - the center is at (0,0) and edge vertices are at distance 'radius'
+ // We want TexCoord to be in the range roughly [-1, 1] at the edges
+ lowp float maxDist = length(position);
+ if (maxDist > 0.1) {
+ TexCoord = position / maxDist;
+ } else {
+ TexCoord = vec2(0.0, 0.0);
+ }
}