How to measure frustum at a given distance from camera?

Old question, but this is how I did it in blueprint. I’m sure this could be done basically the same way in C++, too.

I’ve broken my solution into macros to make the graph cleaner and easier to read, plus these are each useful macros on their own:

  1. Get the Viewport bounds with a simple macro. All this does is get a set of Vector2D corner coordinates in screen-space.

  1. Convert those viewport points into world space coordinates and use the direction vector to construct a line from the camera to some arbitrarily large distance.

  1. Feed the camera position and an origin+normal plane in along with those frustum endpoints we just got to find the intersection of the plane with the Line Plane Intersection (Origin & Normals) node. I added optional debug draw functionality to this for visualization purposes (see final image).

With those macros defined, wire it up like so:

And the resulting debug draw in-scene. Red is the line edges of the frustum, the orange dots are where they intersect the plane defined by my blueprint’s actor (a plane at the center of the frustum):

Disclaimer: No guarantees this works in all situations, I’m pretty new to Viewports, but it did the job in my case. If anyone has a better way I’ll happily adjust and re-post the answer. Also, I’m doing this in UE5 Early Access, just because that’s where I was playing around. Should work the same in UE4.x, though.

4 Likes