|
1 | 1 | uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix. |
2 | 2 | uniform mat4 u_MVMatrix; // A constant representing the combined model/view matrix. |
3 | | -uniform float u_Time; |
4 | 3 | uniform float u_DeltaPos; |
5 | 4 |
|
6 | 5 | attribute vec4 a_Position; // Per-vertex position information we will pass in. |
7 | | -attribute vec3 a_Normal; // Per-vertex normal information we will pass in. |
8 | 6 | attribute vec2 a_TexCoordinate; // Per-vertex texture coordinate information we will pass in. |
9 | 7 |
|
10 | 8 | // Contains tile's x and y position + random value at .z |
11 | 9 | attribute vec3 a_TileXY; |
12 | 10 |
|
13 | | -varying vec3 v_Position; // This will be passed into the fragment shader. |
14 | | -varying vec3 v_Normal; // This will be passed into the fragment shader. |
15 | 11 | varying vec2 v_TexCoordinate; // This will be passed into the fragment shader. |
16 | | -varying vec3 v_Color; |
17 | | - |
18 | | -float rand( vec2 co ) |
19 | | -{ |
20 | | - return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); |
21 | | -} |
22 | 12 |
|
23 | 13 | void main() |
24 | 14 | { |
25 | | - // Transform the vertex into eye space. |
26 | | - v_Position = vec3(u_MVMatrix * a_Position); |
27 | | - |
28 | | - // Pass through the texture coordinate. |
29 | | - v_TexCoordinate = a_TexCoordinate; |
30 | | - |
31 | | - // Transform the normal's orientation into eye space. |
32 | | - v_Normal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); |
| 15 | + // Pass through the texture coordinate. |
| 16 | + v_TexCoordinate = a_TexCoordinate; |
33 | 17 |
|
34 | | - // Tiles' elevation |
35 | | - float z = - (a_TileXY.z - 0.5) * sin(u_DeltaPos/7.0) * 1.3; |
| 18 | + // Tiles' elevation |
| 19 | + float z = - (a_TileXY.z - 0.5) * sin(u_DeltaPos/7.0) * 1.3; |
36 | 20 |
|
37 | | - vec4 calcPos = a_Position; |
| 21 | + vec4 calcPos = a_Position; |
38 | 22 |
|
39 | | - calcPos.z = z; |
| 23 | + calcPos.z = z; |
40 | 24 |
|
41 | | - float randomShift = a_TileXY.z; |
| 25 | + float randomShift = a_TileXY.z; |
42 | 26 |
|
43 | | - // Just some random perturbations |
44 | | - calcPos.x += u_DeltaPos * (randomShift - 0.5) * 0.3; |
45 | | - calcPos.y += u_DeltaPos + randomShift * sin(u_DeltaPos / 30.0) * 3.3; |
46 | | - v_Color.rgb = vec3(rand(a_TileXY.xy)); |
| 27 | + // Just some random perturbations |
| 28 | + calcPos.x += u_DeltaPos * (randomShift - 0.5) * 0.3; |
| 29 | + calcPos.y += u_DeltaPos + randomShift * sin(u_DeltaPos / 30.0) * 3.3; |
47 | 30 |
|
48 | | - gl_Position = u_MVPMatrix * calcPos; |
| 31 | + gl_Position = u_MVPMatrix * calcPos; |
49 | 32 | } |
0 commit comments