Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. attribute vec3 aVertexPosition;
  2. attribute vec4 aVertexColor;
  3.  
  4. uniform mat4 uMVMatrix;
  5. uniform mat4 uPMatrix;
  6.  
  7. varying vec4 vColor;
  8.  
  9. uniform float f; // this is incremented every frame
  10. uniform float t; // this is time in milliseconds since epoch
  11.  
  12. #define M_PI 3.1415926535897932384626433832795
  13.  
  14.  
  15. mat3 rotateX(float rad) {
  16.     float c = cos(rad);
  17.     float s = sin(rad);
  18.     return mat3(
  19.         1.0, 0.0, 0.0,
  20.         0.0, c, s,
  21.         0.0, -s, c
  22.     );
  23. }
  24.  
  25.  
  26. mat3 rotateY(float rad) {
  27.     float c = cos(rad);
  28.     float s = sin(rad);
  29.     return mat3(
  30.         c, 0.0, -s,
  31.         0.0, 1.0, 0.0,
  32.         s, 0.0, c
  33.     );
  34. }
  35.  
  36.  
  37. mat3 rotateZ(float rad) {
  38.     float c = cos(rad);
  39.     float s = sin(rad);
  40.     return mat3(
  41.         c, s, 0.0,
  42.         -s, c, 0.0,
  43.         0.0, 0.0, 1.0
  44.     );
  45. }
  46.  
  47.  
  48.  
  49. void main(void) {
  50.     gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1);
  51.     vec3 oColor = vec3(1.0,1.0,1.0);
  52.  
  53.     float min = 0.0;
  54.     vec3 vertexPosition = aVertexPosition.xyz * rotateX(sin(f/30.0)) * rotateY(cos(f/25.0)) * rotateZ(tan(f/100.0)) / 5.0;
  55.  
  56.     if(vertexPosition.x > min && vertexPosition.y > min && vertexPosition.z > min) {
  57.        oColor = vec3(1.0,0.0,0.0);
  58.     }
  59.  
  60.     vColor = vec4(oColor,1.0);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement