summaryrefslogtreecommitdiff
path: root/themes/src/shaders/sun_vert.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'themes/src/shaders/sun_vert.cpp')
-rw-r--r--themes/src/shaders/sun_vert.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/themes/src/shaders/sun_vert.cpp b/themes/src/shaders/sun_vert.cpp
index ca617c0..bacf3a6 100644
--- a/themes/src/shaders/sun_vert.cpp
+++ b/themes/src/shaders/sun_vert.cpp
@@ -1,16 +1,25 @@
#include "sun_vert.h"
const char* shader_sun_vert = " \n"
-"attribute vec2 position; \n"
-"attribute vec4 color; \n"
-"attribute mat4 vMatrix; \n"
-"uniform mat4 projection; \n"
-"uniform mat4 model; \n"
+"attribute vec2 position; \n"
+"attribute vec4 color; \n"
+"attribute mat4 vMatrix; \n"
+"uniform mat4 projection; \n"
+"uniform mat4 model; \n"
"varying lowp vec4 VertexColor; \n"
+"varying lowp vec2 TexCoord; \n"
" \n"
-"void main() { \n"
-" vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); \n"
-" gl_Position = fragmentPosition; \n"
-" VertexColor = color; \n"
+"void main() { \n"
+" vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); \n"
+" gl_Position = fragmentPosition; \n"
+" VertexColor = color; \n"
+" // Normalize the position - the center is at (0,0) and edge vertices are at distance 'radius' \n"
+" // We want TexCoord to be in the range roughly [-1, 1] at the edges \n"
+" lowp float maxDist = length(position); \n"
+" if (maxDist > 0.1) { \n"
+" TexCoord = position / maxDist; \n"
+" } else { \n"
+" TexCoord = vec2(0.0, 0.0); \n"
+" } \n"
"} \n"
" \n";