blob: 1c9b9f3fcf1f8a5011dda943a25d4589cc0c0ecc (
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
|
precision highp float;
attribute vec3 land;
attribute vec2 landnormal;
uniform float rot;
uniform float world_x;
uniform float world_y;
uniform mat4 MV;
uniform mat4 P;
varying vec2 worldxy;
varying mat4 pre;
varying vec2 norm;
void main() {
norm = landnormal;
mat2 rotate = mat2(
cos(rot), -sin(rot),
sin(rot), cos(rot)
);
worldxy = vec2(world_x, world_y);
pre = P * MV;
vec2 local = (land.xy - worldxy) * rotate;
float z_scale = 0.5;
// clamp so that everything becomes orthographic once we move away
float xoff = clamp(land.z * local.x * z_scale, -0.5, 0.5);
float yoff = clamp(land.z * local.y * z_scale, -0.5, 0.5);
gl_Position = P * MV * vec4(local.xy - vec2(xoff, yoff), land.z, 1.0);
}
|