Advertisement
Guest User

texRotShader.vert

a guest
Oct 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Uniform vars */
  2. uniform float uniformAngle; /* Rotation angle */
  3. uniform vec2 rotationCenter; /* Rotation centre */
  4.  
  5. /* Attribute vars */
  6. attribute vec2 position; /* Position */
  7. attribute vec2 texCoordIn; /* Texture coordinates */
  8.  
  9. /* Texture coordinate, used by pixel shader */
  10. varying vec2 texCoord;
  11.  
  12. /* Main shader function */
  13. void main()
  14. {
  15.     /* Translate UVs to rotation origin, rotate, translate back */
  16.     position = position - rotationCenter;
  17.     position = mat2(cos(uniformAngle), sin(uniformAngle), -sin(uniformAngle), cos(uniformAngle)) * position;
  18.     position = position + rotationCenter;
  19.  
  20.     /* Set position */
  21.     gl_Position = vec4(position, 0.0, 1.0);
  22.  
  23.     /* Pass texCoord */
  24.     texCoord = texCoordIn;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement