Skip to content

Commit 51623dc

Browse files
author
Artem Kholodnyi
committed
Clean up
1 parent 085c5b7 commit 51623dc

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

library/src/main/res/raw/tiles_frag.glsl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
precision mediump float; // Set the default precision to medium. We don't need as high of a
2-
// precision in the fragment shader.
1+
precision mediump float; // Set the default precision to medium. We don't need as high of a precision in the fragment shader.
32
uniform sampler2D u_Texture; // The input texture.
43

54
varying vec2 v_TexCoordinate; // Interpolated texture coordinate per fragment.
65

7-
float rand( vec2 co )
8-
{
9-
return step(0.9, fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453));
10-
}
11-
12-
// The entry point for our fragment shader.
136
void main()
147
{
158
gl_FragColor = texture2D(u_Texture, v_TexCoordinate);
Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,32 @@
11
uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix.
22
uniform mat4 u_MVMatrix; // A constant representing the combined model/view matrix.
3-
uniform float u_Time;
43
uniform float u_DeltaPos;
54

65
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.
86
attribute vec2 a_TexCoordinate; // Per-vertex texture coordinate information we will pass in.
97

108
// Contains tile's x and y position + random value at .z
119
attribute vec3 a_TileXY;
1210

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.
1511
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-
}
2212

2313
void main()
2414
{
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;
3317

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;
3620

37-
vec4 calcPos = a_Position;
21+
vec4 calcPos = a_Position;
3822

39-
calcPos.z = z;
23+
calcPos.z = z;
4024

41-
float randomShift = a_TileXY.z;
25+
float randomShift = a_TileXY.z;
4226

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;
4730

48-
gl_Position = u_MVPMatrix * calcPos;
31+
gl_Position = u_MVPMatrix * calcPos;
4932
}

0 commit comments

Comments
 (0)