1{
2    "shaders": {
3		////////////////////////////////////////////////////////////////
4		// vertex shaders
5        "vertex": {
6            "sun_test": "shaders/sun_test.vert",
7            "inline_test_v": "
8                uniform mat4 u_mvp_matrix;
9                attribute vec4 a_position;
10                attribute vec2 a_texcoord;
11                varying vec2 v_texcoord;
12                void main()
13                {
14                    v_texcoord = a_texcoord;
15                    gl_Position = u_mvp_matrix * a_position;
16                }",
17
18            "hex_shader_v": "
19                uniform mat4 u_mvp_matrix;
20                attribute vec4 a_position;
21                attribute vec2 a_texcoord;
22                varying vec2 v_texcoord;
23                void main()
24                {
25                    v_texcoord = a_texcoord;
26                    gl_Position = u_mvp_matrix * a_position;
27                }",
28
29			"particle1_v": "
30				uniform mat4 u_mvp_matrix;
31				uniform float u_time;
32				uniform vec3 u_centerPosition;
33				uniform float u_lifetime;
34				attribute float a_start_time;
35				attribute vec3 a_startPosition;
36				attribute vec3 a_endPosition;
37				varying float v_lifetime;
38				void main()
39				{
40					if(u_time >= a_start_time) {
41						vec4 vector;
42						vector.xyz = a_startPosition + ((u_time-a_start_time) * a_endPosition) + u_centerPosition;
43						vector.w = 1.0;
44						gl_Position = u_mvp_matrix * vector;
45						v_lifetime = 1.0 - ((u_time - a_start_time) / u_lifetime);
46						v_lifetime = clamp(v_lifetime, 0.0, 1.0);
47					} else {
48						//gl_Position = vec4(-3000, -3000, 0, 0);
49						vec4 vector;
50						vector.xyz = a_startPosition + ((u_lifetime-a_start_time+u_time) * a_endPosition) + u_centerPosition;
51						vector.w = 1.0;
52						gl_Position = u_mvp_matrix * vector;
53						v_lifetime = 1.0 - ((u_lifetime-a_start_time+u_time) / u_lifetime);
54						v_lifetime = clamp(v_lifetime, 0.0, 1.0);
55					}
56					gl_PointSize = (v_lifetime * v_lifetime) * 10.0;
57				}",
58        },
59
60		////////////////////////////////////////////////////////////////
61		// fragment shaders
62        "fragment": {
63            "sun_test": "shaders/sun_test.frag",
64
65            "inline_test_f": "
66                uniform sampler2D u_tex_map;
67				uniform vec4 u_color;
68				varying vec2 v_texcoord;
69                void main()
70                {
71                    gl_FragColor = texture2D(u_tex_map, v_texcoord) * u_color;
72                }",
73
74            "hex_shader_f": "
75                uniform sampler2D u_tex_map;
76				uniform vec4 u_color;
77				uniform bool do_grayscale;
78                uniform bool do_highlight;
79				varying vec2 v_texcoord;
80                void main()
81                {
82					vec4 col;
83					if(do_grayscale) {
84						col = texture2D(u_tex_map, v_texcoord) * u_color;
85						float gray = sqrt(pow(col.r,2.2) * 0.2126 + pow(col.g,2.2) * 0.7152 + pow(col.b,2.2) * 0.0722);
86						col.r = col.g = col.b = gray * 0.8;
87						gl_FragColor = col;
88                    } else if(do_highlight) {
89                        gl_FragColor = texture2D(u_tex_map, v_texcoord) * u_color;
90                        gl_FragColor = clamp(gl_FragColor * 1.2, 0.0, 1.0);
91					} else {
92						gl_FragColor = texture2D(u_tex_map, v_texcoord) * u_color;
93					}
94                }",
95
96			"particle1_f": "
97				#ifdef GL_ES
98				precision mediump float;
99				#endif
100				uniform vec4 u_color;
101				uniform sampler2D s_texture;
102				varying float v_lifetime;
103				void main()
104				{
105					vec4 texColor;
106					texColor = texture2D(s_texture, gl_PointCoord);
107					gl_FragColor = vec4(u_color) * texColor;
108					gl_FragColor.a *= v_lifetime;
109				}",
110
111            "water1_f": "
112				#ifdef GL_ES
113				precision highp float;
114				#endif
115
116				uniform float time;
117				uniform vec2 resolution;
118				uniform sampler2D tex;
119
120				void main(void) {
121					vec2 cPos = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
122					float cLength = length(cPos);
123
124					vec2 uv = gl_FragCoord.xy/resolution.xy+(cPos/cLength)*cos(cLength*12.0-time*4.0)*0.03;
125					vec3 col = texture2D(tex,uv).xyz;
126
127					gl_FragColor = vec4(col,1.0);
128				}",
129		},
130	},
131
132    "programs": [
133        {
134            "name": "sun_test",
135            "vertex": "sun_test",
136            "fragment": "sun_test",
137        },
138        {
139            "name": "inline_test",
140            "vertex": "inline_test_v",
141            "fragment": "inline_test_f",
142            "attributes": {
143                "vertex": "a_position",
144                "texcoord": "a_texcoord",
145            },
146        },
147        {
148            "name": "hex_shader",
149            "vertex": "hex_shader_v",
150            "fragment": "hex_shader_f",
151            "attributes": {
152                "vertex": "a_position",
153                "texcoord": "a_texcoord",
154            },
155        },
156		{
157			"name": "particle1",
158			"vertex": "particle1_v",
159			"fragment": "particle1_f",
160		},
161    ],
162}