mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-01-07 01:43:35 +08:00
Update RotateUV.gdshaderinc
RotateUV node shader logic simplified.
This commit is contained in:
parent
e6e36ec6c6
commit
4628159c6e
@ -1,16 +1,10 @@
|
||||
vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
|
||||
float _angle = rotation;
|
||||
if(use_degrees){
|
||||
rotation = rotation * (3.1415926/180.0);
|
||||
_angle = 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;
|
||||
vec2 _delta = uv - center;
|
||||
float _x = cos(_angle) * _delta.x - sin(_angle) * _delta.y;
|
||||
float _y = sin(_angle) * _delta.x + cos(_angle) * _delta.y;
|
||||
return vec2(_x + center.x, _y + center.y);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user