1
0
mirror of https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git synced 2025-01-09 02:43:25 +08:00
Godot-Shader-Lib/addons/ShaderLib/UV/RotateUV.gdshaderinc
Digvijaysinh Gohil aef7f401af RotateUV node added
^ Code refactored for various nodes
2023-10-12 18:31:51 +05:30

16 lines
451 B
Plaintext

vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
if(use_degrees){
rotation = rotation * (3.1415926/180.0);
}
vec2 _uv = uv;
_uv -= center;
float _s = sin(rotation);
float _c = cos(rotation);
mat2 _rotation_matrix = mat2(vec2(_c, -_s), vec2(_s, _c));
_rotation_matrix *= 0.5;
_rotation_matrix += 0.5;
_rotation_matrix = _rotation_matrix * 2.0 - 1.0;
_uv.xy = _uv.xy * _rotation_matrix;
_uv += center;
return _uv;
}