in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D texture0;
uniform vec4 color;
uniform float time;
uniform float sScrollSpeed;
uniform float tScrollSpeed;
uniform float sScrollScale;
uniform float tiling;
uniform float kolor;
uniform float rotation;

void main()
{
    vec2 coord=texCoord;
    // Center the tiling around 0.5
    coord = (coord - 0.5) * tiling + 0.5;
    
    vec2 tileCoord = fract(coord);
    
    vec2 centered = tileCoord - 0.5;
    float cosR = cos(rotation);
    float sinR = sin(rotation);
    vec2 rotated;
    rotated.x = centered.x * cosR - centered.y * sinR;
    rotated.y = centered.x * sinR + centered.y * cosR;
    tileCoord = rotated + 0.5;
    
    tileCoord += floor(coord);
    tileCoord.s = tileCoord.s + sScrollSpeed*(0.1*time);
    tileCoord.t = tileCoord.t + tScrollSpeed*(0.1*time);
    
    fragColor = color*texture2D(texture0, tileCoord);


}
