Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static float deformationRatio = 1.414214f;
- public static float pixelStepX = 0.03125f;
- public static float pixelStepZ = 0.0441941875f;
- public static float GetDeformationRatio(Vector3 direction)
- {
- float angle = (Mathf.Atan2(direction.z, direction.x) / Mathf.PI) * 180;
- if (angle < 0) angle += 360f;
- int adjustment = Mathf.FloorToInt(angle / 90);
- float percentage;
- if (adjustment % 2 != 0) percentage = 1 - ((angle - (adjustment * 90)) / 90);
- else percentage = ((angle - (adjustment * 90)) / 90);
- float ratio = 1 + ((deformationRatio - 1) * percentage);
- return ratio;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement