shaderlib: Add rotateUV function to common.gdshader
This commit is contained in:
parent
4d0f7ca538
commit
c9c5428dbc
1 changed files with 12 additions and 0 deletions
|
@ -13,3 +13,15 @@ vec4 alpha_blend(vec4 b, vec4 a) {
|
|||
vec3 col = ((a.rgb*a.a) + ((b.rgb*b.a) * (1.0 - a.a)) / alpha);
|
||||
return vec4(col.r, col.g, col.b, alpha);
|
||||
}
|
||||
|
||||
/*
|
||||
Rotate UV
|
||||
*/
|
||||
|
||||
vec2 rotateUV(vec2 uv, float rotation, vec2 center) {
|
||||
float cosRot = cos(rotation);
|
||||
float sinRot = sin(rotation);
|
||||
return vec2(
|
||||
cosRot * (uv.x - center.x) + sinRot * (uv.y - center.y) + center.x,
|
||||
cosRot * (uv.y - center.y) - sinRot * (uv.x - center.x) + center.y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue