Comments and answers for "Calculate camera frustum intersection with plane"
http://answers.unity.com/questions/1064390/calculate-camera-frustum-intersection-with-plane.html
The latest comments and answers for the question "Calculate camera frustum intersection with plane"Answer by troien
http://answers.unity.com/answers/1064488/view.html
As for the :
> How do you get the corner rays of the camera frustum?
To get the ray of each corner you can simply use camera.[ViewportPointToRay][1].
Ray bottomLeft = camera.ViewportPointToRay(new Vector3(0, 0, 0));
Ray topLeft = camera.ViewportPointToRay(new Vector3(0, 1, 0));
Ray topRight = camera.ViewportPointToRay(new Vector3(1, 1, 0));
Ray bottomRight = camera.ViewportPointToRay(new Vector3(1, 0, 0));
If your plane is on a fixed height you perhaps don't even have to raycast. As a method like this should return the rays intersection on a given y position. (I used this method because I needed a similar thing, but I didn't have a collider to raycast against as I used Graphics.DrawMesh).
public static Vector3 GetPointAtHeight(Ray ray, float height)
{
return ray.origin + (((ray.origin.y - height) / -ray.direction.y) * ray.direction);
}
Note that this method can thow a division by zero if ray.direction.y is 0.
[1]: http://docs.unity3d.com/ScriptReference/Camera.ViewportPointToRay.htmlThu, 10 Sep 2015 08:20:07 GMTtroienAnswer by musaranya
http://answers.unity.com/answers/1064485/view.html
I think Unity performs its frustum culling by default so you should not worry about it. Also keep in mind that if the objects are very large culling is less efective because when a vertex gets into the frustum the entire object is rendered.
If you still want to get dirt with frustum culling, this couple of functions may interest you:
[GeometryUtility.CalculateFrustumPlanes][1]
[GeometryUtility.TestPlanesAABB][2]
[1]: http://docs.unity3d.com/ScriptReference/GeometryUtility.CalculateFrustumPlanes.html
[2]: http://docs.unity3d.com/ScriptReference/GeometryUtility.TestPlanesAABB.html
regardsThu, 10 Sep 2015 08:07:23 GMTmusaranya