30 lines
615 B
GLSL
30 lines
615 B
GLSL
#version 330
|
|
|
|
in vec2 fragTexCoord;
|
|
|
|
uniform sampler2D texture0;
|
|
uniform vec2 resolution;
|
|
uniform float angle;
|
|
|
|
out vec4 rotOut;
|
|
|
|
void main()
|
|
{
|
|
vec2 uv_space = fragTexCoord - 0.5;
|
|
uv_space.x *= resolution.x / resolution.y;
|
|
|
|
float i = cos(-angle);
|
|
float j = sin(-angle);
|
|
|
|
vec2 rot = vec2((uv_space.x * i) - (uv_space.y * j), (uv_space.x * j) + (uv_space.y * i));
|
|
|
|
rot.x /= resolution.x / resolution.y;
|
|
rot += 0.5;
|
|
|
|
if (rot.x < 0.0 || rot.x > 1.0 || rot.y < 0.0 || rot.y > 1.0) {
|
|
rotOut = vec4(0.0, 0.0, 0.0, 1.0);
|
|
} else {
|
|
rotOut = texture(texture0, rot);
|
|
}
|
|
}
|