blob: d5af4be675d78365bf190d90e2e37642cfee2b94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include "sun_frag.h"
const char* shader_sun_frag = "varying lowp vec4 VertexColor; \n"
" \n"
"#ifdef GL_ES \n"
"precision mediump float; \n"
"#endif \n"
" \n"
"uniform vec2 u_resolution; \n"
" \n"
"vec2 skew (vec2 st) { \n"
" vec2 r = vec2(0.0); \n"
" r.x = 1.1547*st.x; \n"
" r.y = st.y+0.5*r.x; \n"
" return r; \n"
"} \n"
" \n"
"vec3 simplexGrid (vec2 st) { \n"
" vec3 xyz = vec3(0.0); \n"
" \n"
" vec2 p = fract(skew(st)); \n"
" if (p.x > p.y) { \n"
" xyz.xy = 1.0-vec2(p.x,p.y-p.x); \n"
" xyz.z = p.y; \n"
" } else { \n"
" xyz.yz = 1.0-vec2(p.x-p.y,p.y); \n"
" xyz.x = p.x; \n"
" } \n"
" \n"
" return fract(xyz); \n"
"} \n"
" \n"
"void main() { \n"
" vec2 st = gl_FragCoord.xy/u_resolution.xy; \n"
" vec3 color = VertexColor.xyz \n"
" \n"
" // Scale the space to see the grid \n"
" st *= 10.; \n"
" \n"
" // Show the 2D grid \n"
" color.rg = fract(st); \n"
" \n"
" // Skew the 2D grid \n"
" // color.rg = fract(skew(st)); \n"
" \n"
" // Subdivide the grid into to equilateral triangles \n"
" // color = simplexGrid(st); \n"
" \n"
" gl_FragColor = vec4(color,1.0); \n"
"} \n"
" \n";
|