diff options
Diffstat (limited to 'themes/src/_shaders')
-rw-r--r-- | themes/src/_shaders/sun.frag | 48 | ||||
-rw-r--r-- | themes/src/_shaders/sun.vert | 13 |
2 files changed, 61 insertions, 0 deletions
diff --git a/themes/src/_shaders/sun.frag b/themes/src/_shaders/sun.frag new file mode 100644 index 0000000..dabd7ea --- /dev/null +++ b/themes/src/_shaders/sun.frag @@ -0,0 +1,48 @@ +varying lowp vec4 VertexColor; + +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; + +vec2 skew (vec2 st) { + vec2 r = vec2(0.0); + r.x = 1.1547*st.x; + r.y = st.y+0.5*r.x; + return r; +} + +vec3 simplexGrid (vec2 st) { + vec3 xyz = vec3(0.0); + + vec2 p = fract(skew(st)); + if (p.x > p.y) { + xyz.xy = 1.0-vec2(p.x,p.y-p.x); + xyz.z = p.y; + } else { + xyz.yz = 1.0-vec2(p.x-p.y,p.y); + xyz.x = p.x; + } + + return fract(xyz); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution.xy; + vec3 color = VertexColor.xyz + + // Scale the space to see the grid + st *= 10.; + + // Show the 2D grid + color.rg = fract(st); + + // Skew the 2D grid + // color.rg = fract(skew(st)); + + // Subdivide the grid into to equilateral triangles + // color = simplexGrid(st); + + gl_FragColor = vec4(color,1.0); +} diff --git a/themes/src/_shaders/sun.vert b/themes/src/_shaders/sun.vert index e69de29..76150f0 100644 --- a/themes/src/_shaders/sun.vert +++ b/themes/src/_shaders/sun.vert @@ -0,0 +1,13 @@ + +attribute vec2 position; +attribute vec4 color; +attribute mat4 vMatrix; +uniform mat4 projection; +uniform mat4 model; +varying lowp vec4 VertexColor; + +void main() { + vec4 fragmentPosition = projection * model * vMatrix * vec4(position.x, position.y, 0, 1); + gl_Position = fragmentPosition; + VertexColor = color; +} |