Advertisement
Guest User

Pixel Utility

a guest
Apr 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.     public static float deformationRatio = 1.414214f;
  2.     public static float pixelStepX = 0.03125f;
  3.     public static float pixelStepZ = 0.0441941875f;
  4.  
  5.     public static float GetDeformationRatio(Vector3 direction)
  6.     {
  7.         float angle = (Mathf.Atan2(direction.z, direction.x) / Mathf.PI) * 180;
  8.         if (angle < 0) angle += 360f;
  9.  
  10.         int adjustment = Mathf.FloorToInt(angle / 90);
  11.  
  12.         float percentage;
  13.         if (adjustment % 2 != 0) percentage = 1 - ((angle - (adjustment * 90)) / 90);
  14.         else percentage = ((angle - (adjustment * 90)) / 90);
  15.  
  16.         float ratio = 1 + ((deformationRatio - 1) * percentage);
  17.  
  18.         return ratio;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement