aboutsummaryrefslogtreecommitdiff
path: root/src/shaders/land.vert
diff options
context:
space:
mode:
authorAlex Pickering <alex@cogarr.net>2026-02-01 13:14:32 -0600
committerAlexander M Pickering <alex@cogarr.net>2026-02-01 13:14:32 -0600
commit3a975db66a3711f34e8b64bb27a8eaca79fdeca9 (patch)
treefcc12f8f9d638ff575c1963796de76b7628854b4 /src/shaders/land.vert
downloadggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.tar.gz
ggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.tar.bz2
ggj26-3a975db66a3711f34e8b64bb27a8eaca79fdeca9.zip
Initial commitHEADmaster
Diffstat (limited to 'src/shaders/land.vert')
-rw-r--r--src/shaders/land.vert26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/shaders/land.vert b/src/shaders/land.vert
new file mode 100644
index 0000000..1c9b9f3
--- /dev/null
+++ b/src/shaders/land.vert
@@ -0,0 +1,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);
+}