Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type spatial;
  2.  
  3.  
  4. float height_at(float x, float z, float time) {
  5.     float height = sin(0.25*x-time*0.75);
  6.     return height + 1.0;
  7. }
  8.  
  9. vec3 normal_at(float x, float z, float time) {
  10.     float u = 0.01;
  11.     float left = height_at(x - u, z, time);
  12.     float right = height_at(x + u, z, time);
  13.     float back = height_at(x, z - u, time);
  14.     float fore = height_at(x, z + u, time);
  15.     vec3 n = normalize(vec3(left - right, 2.0, back - fore));
  16.     return n;
  17. }
  18.  
  19. void vertex() {
  20.     NORMAL = normal_at(VERTEX.x, VERTEX.z, TIME);
  21.     VERTEX.y = height_at(VERTEX.x, VERTEX.z, TIME);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement