diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2025-01-25 20:40:09 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2025-01-25 20:40:09 -0600 |
| commit | b174b8c00026253fd40ec262e430b0bb764e31ea (patch) | |
| tree | 173d294b98fe14727aef9cd42542f41a940f5ffa /src/shaders/land.vert | |
| parent | 89a8f94ac0206412c1a2d7b8766d97dbdbd36253 (diff) | |
| download | ggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.tar.gz ggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.tar.bz2 ggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.zip | |
work
Diffstat (limited to 'src/shaders/land.vert')
| -rw-r--r-- | src/shaders/land.vert | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/shaders/land.vert b/src/shaders/land.vert index 2004ab3..1c9b9f3 100644 --- a/src/shaders/land.vert +++ b/src/shaders/land.vert @@ -1,14 +1,26 @@ precision highp float; attribute vec3 land; -uniform float time; //used for noise +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; - gl_Position = P * MV * vec4(land.x - world_x, land.y - world_y, 0., 1.0); + 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); } |
