So I am making a rasterizing rendering engine in Roblox and right now this is basically just a prototype of how the ray tracing will be done. This framework casts rays from a reference point to parts in the workspace. I feel as if I should be accounting for the arc angle of the camera relative to the parts. For all of you not familiar to trigonometry let me explain.
In a for loop I would loop through all objects in the workspace, then get the difference between it and the camera (viewport). That vector generated from those vectors would be our hypotenuse. The Adjacent is our cameras look vector. We normalize those vectors (vector.Unit) to make it not infinite to avoid infinite elliptical cone messes. That 0 between the angle of B and C is known as the theta of cosine. It is a radian which basically determines the angle difference between them. If the angle is more than 35 or less than -35 degrees we wouldn’t render it. The problem with this theory is I fear it may cause lag, but then again I am already doing pretty heavy vector math with not much lag. The formula I would use to be specific is not the law of cosines but rather this;
In code it is pretty much this
local difference = (playerHead.Position - enemy.Position).Unit --I suppose you can derive enemy from a for loop
local lVecPlr = playerHead.CFrame.LookVector --both have a magnitude of 1 now
local degreeDifference = math.deg(math.acos(difference:Dot(lVecPlr) / (difference.Magnitude + lVecPlr))) -- The second part is kind of arbtrary but neccesary for 3d space
while wait() do
print(degreeDifference)
end
I also have logging in place so I can track the vertices and the rays and faces, etc.
devforumPostRenderEngine.rbxl (25.3 KB)
https://github.com/EppersonJoshua/rasterizer-roblox


