Created
October 26, 2018 10:35
-
-
Save unitycoder/5305b83de5cc7e4bbace1ef29ce6516b to your computer and use it in GitHub Desktop.
Vertex Rotations in Shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://forum.unity.com/threads/how-to-compute-vertex-rotation.470676/ | |
| inline float3x3 xRotation3dRadians(float rad) { | |
| float s = sin(rad); | |
| float c = cos(rad); | |
| return float3x3( | |
| 1, 0, 0, | |
| 0, c, s, | |
| 0, -s, c); | |
| } | |
| inline float3x3 yRotation3dRadians(float rad) { | |
| float s = sin(rad); | |
| float c = cos(rad); | |
| return float3x3( | |
| c, 0, -s, | |
| 0, 1, 0, | |
| s, 0, c); | |
| } | |
| inline float3x3 zRotation3dRadians(float rad) { | |
| float s = sin(rad); | |
| float c = cos(rad); | |
| return float3x3( | |
| c, s, 0, | |
| -s, c, 0, | |
| 0, 0, 1); | |
| } | |
| // usage | |
| // degree is the variable with the degrees you want to rotate your vertex | |
| float3 rotatedVertex = mul(yRotation3dRadians(radians(degree)), v.vertex); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment