Created
June 2, 2017 18:13
-
-
Save badcc/3c55742057ed2c62509b9c8705fbca7f to your computer and use it in GitHub Desktop.
This file contains 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
-- How many pixels (width) is 1 stud at depth d from camera | |
local function DepthToPixels(Depth) | |
local Camera = workspace.CurrentCamera | |
local Viewport = Camera.ViewportSize | |
local Ratio = Viewport.X/Viewport.Y | |
local h = math.tan(math.rad(Camera.FieldOfView)*0.5) | |
return Viewport.X/(2*Depth*h*Ratio) | |
end | |
print(DepthToPixels(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment