Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. #version 330 core
  4. layout (location = 0) in vec3 aPos;
  5. layout (location = 1) in vec2 aTexCoord;
  6.  
  7. out vec2 TexCoord;
  8.  
  9. uniform mat4 view;
  10. uniform mat4 projection;
  11. uniform vec3 pos;
  12. uniform float aspectRatio;
  13. uniform float yrot;
  14. uniform int sheetInvert;
  15.  
  16. void main()
  17. {
  18.     vec3 right = vec3(view[0][0], view[1][0], view[2][0]);
  19.     vec3 up = vec3(view[0][1], view[1][1], view[2][1]);
  20.     vec3 forward = vec3(view[0][2], view[1][2], view[2][2]);
  21.  
  22.     vec3 upt = aPos.y * up;
  23.     //upt = vec3(0.0, aPos.y, 0.0);
  24.    
  25.     float angle = yrot;
  26.     float l = sqrt(0.5 - (cos(radians(abs(angle))) / 2)) * -sign(angle);
  27.    
  28.     vec3 center = pos + (normalize(vec3(forward) * vec3(1.0, 0.0, 1.0)) * -l);
  29.     vec3 vertexPosition = center + (right * aPos.x * aspectRatio) + (upt);
  30.     gl_Position = projection * view * vec4(vertexPosition, 1.0f);
  31.  
  32.     TexCoord = vec2(abs(aTexCoord.x - sheetInvert), aTexCoord.y);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement