title: rotate Z axis on 2d image's matrix in shader
body: <p>I'm trying to rotate a 2d image's matrix inside the vertex shader.</p>
  
  <p><a href="https://i.stack.imgur.com/0KLpO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KLpO.png" alt="enter image description here"></a></p>
  
  <p>I want the 2d image to rotate around what I think would be the z axis. </p>
  
  <p>However The closes I've ever gotten is:</p>
  
  <p><a href="https://i.stack.imgur.com/v5S54.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v5S54.png" alt="enter image description here"></a></p>
  
  <p>Here is my matrix inside my shader that I apply translation and scaling on:</p>
  
  <pre><code>mat4 worldPosTrans = mat4(vec4(scale.x * cos(rotateZ), 0, 0, 0),
                            vec4(0, scale.y, 0, 0),
                            vec4(0, 0, scale.z, 0),
                            vec4(translation, 1));
  </code></pre>
  
  <p>This is a slightly changed version from something that was supposed to rotate everything:</p>
  
  <pre><code>mat4 worldPosTrans = mat4(vec4(scale.x * cos(rotateZ), -sin(rotateZ), 0, 0),
                            vec4(sin(rotateZ), scale.y * cos(rotateZ), 0, 0),
                            vec4(0, 0, scale.z, 0),
                            vec4(translation, 1));
  </code></pre>
  
  <p>This is my full vertex shader:</p>
  
  <pre><code>precision mediump float;
  
  attribute vec3 vertPosition;
  attribute vec3 vertColor;
  attribute vec2 aTextureCoord;
  varying vec3 fragColor;
  varying highp vec2 vTextureCoord;
  
  varying highp vec2 vTextureCoordBg;
  uniform vec2 uvOffsetBg;
  uniform vec2 uvScaleBg;
  
  uniform mat4 uPMatrix;
  uniform mat4 uMVMatrix;
  
  uniform vec2 uvOffset;
  uniform vec2 uvScale;
  
  uniform vec3 translation;
  uniform vec3 scale;
  uniform float rotateZ;
  
  void main()
  {
      fragColor = vertColor;
  
      vTextureCoord =  (vec4(aTextureCoord, 0, 1)).xy * uvScale + uvOffset;
      vTextureCoordBg = (vec4(aTextureCoord, 0, 1)).xy * uvScaleBg + uvOffsetBg;
  
      mat4 worldPosTrans = mat4(
          vec4(scale.x * cos(rotateZ), 0, 0, 0),
          vec4(0, scale.y, 0, 0),
          vec4(0, 0, scale.z, 0),
          vec4(translation, 1));
  
      gl_Position = (uPMatrix * worldPosTrans) * vec4(vertPosition.x, vertPosition.y, vertPosition.z, 1.0);
  }
  </code></pre>
  
  <p><strong>edit:</strong></p>
  
  <p>My problem was solved by Rabbid76 in the comments.</p>