diff options
Diffstat (limited to 'themes/src/_shaders/sun.vert')
| -rw-r--r-- | themes/src/_shaders/sun.vert | 27 |
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); + } } |
