I’m looking for a function that allows you to project a 3D position onto the near clipping plane as a Vector3.
To be specific:
Vector3 Camera:ToNearClippingPlane(Vector3 pos)
It’s hard to explain why I need this, but the method I’m using currently to do this is costly, and I’m wondering if a C++ implementation would make it faster.
I’m using it to create very small holograms that project themselves close to the camera to give an X-Ray illusion.
It works really well. However, it gets expensive with several holograms at once.
Here’s a place that demonstrates exactly what I’m doing:
local function ToNearClippingPlane(pos)
local Camera = workspace.CurrentCamera
local clip = Camera:WorldToViewportPoint(pos)
return Camera:ViewportPointToRay(clip.X,clip.Y,0.001)
end
I’m using depth 0.001, but using 0 (the default) you would get the actual plane.
(You might be using this and thinking/knowing it’s expensive. could be, idk)
Can’t you calculate 2 (or 4?) corners of the plane, and use math to position all stuff on there?
I assume that ToNearClippingPlane is the expensive part if used for every part/model.
If you only have to use it a few times and then can use math… might be better?
Hmm, weird stuff happens when I tilt my head, and they don’t line up right. Not entirely sure if it’s your side or not, but I guess it’s something you’d just have to see yourself.
EDIT: Discovered it’s a side-effect of not having a real “2D” in VR