# Check if a mesh is *fully* visible to camera

I could simplify this check to a BoxCollider if it becomes easier, but: I need to check if the entirety of a mesh/collider is visible to the camera. Most checks see if part is visible (by raycasting once). Is there a ‘best practice’ to getting this info for an entire mesh?

To test if a certain point is inside the camera frustum, you can use GeometryUtility.CalculateFrustumPlanes and test every point of the mesh if the distance from each of the 6 planes is positive. At the point where one test returns a negative number you can stop testing.

Plane.GetDistanceToPoint can be used to calculate the distance from the given plane.

I’m not sure if this would be accurate enough for your needs in this case, but I’ll add this for anyone who sees this post afterwards anyway –

An approximation you could do is with the mesh renderer’s bounding box (testing only 8 points instead of all the vertices). Similarly to Bunny83’s answer, you could implement something like:

``````public static bool IsFullyVisible(Renderer renderer, Camera camera) {
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);

Bounds bounds = renderer.bounds;
Vector3 size = bounds.size;
Vector3 min = bounds.min;

//Calculate the 8 points on the corners of the bounding box
List<Vector3> boundsCorners = new List<Vector3>(8) {
min,
min + new Vector3(0, 0, size.z),
min + new Vector3(size.x, 0, size.z),
min + new Vector3(size.x, 0, 0),
};
for (int i = 0; i < 4; i++)
``````
• `````` //Check each plane on every one of the 8 bounds' corners*
``````
• `````` for (int p = 0; p < planes.Length; p++) {*
``````
• `````` 	for (int i = 0; i < boundsCorners.Count; i++) {*
``````

_ if (planes[p].GetSide(boundsCorners*) == false)_
_
return false;_
_
}_
_
}_
_
return true;_
_
}_
Note that I used the type [Renderer][1], which will work for generally any kind of renderer including MeshRenderers, SkinnedMeshRenderers, BillboardRenderers, etc.
And of course you could always, for this calculation, scale the bounds a bit if you want to tweak it a bit. To do that, you can multiply the size variable that represented the size of the bounds – since I use that size to calculate the 8 points.
_
[1]: https://docs.unity3d.com/ScriptReference/Renderer.html*_