title: GODOT: What is an efficient calculation for the AABB of a simple 3D model from a camera's view
body: <p>I am attempting to come up with a quick and efficient means of translating a 3d mesh into a projected AABB. In the end, I would like to accomplish something similar to figure 1 wherein only the area of the screen covered by the cube is located inside the bounding box highlighted in red. ((if it is at all possible, getting the area as small as possible, highlighted in blue, would increase efficiency down the road.))</p>
  <p>Figure 1. <a href="https://i.imgur.com/pd0E20C.png" rel="nofollow noreferrer">https://i.imgur.com/pd0E20C.png</a></p>
  <p>Currently, I have tried:</p>
  <ul>
  <li>Calculating the point position on the screen using <code>camera.unproject_position()</code>. this failed largely due to my inability to wrap my head around the pixel positions trending towards infinity. I understand it has something to do with Tan, but frankly, it is too late for my brain to function anymore.</li>
  <li>Getting the area of collision between the view frustum and the AABB of the mesh instance. This method seems convoluted, and to get it in a usable format I would need to project the result into 2d coordinates again.</li>
  <li>Using the <code>MeshInstance</code> <code>VisualInstance</code> to create a texture wherein a pixel is white if it contains the mesh instance, and black otherwise. Visual instances in general just baffle me, and I did not think it would be efficient to have another viewport just to output this texture.</li>
  </ul>
  <p>What I am looking for:</p>
  <ul>
  <li>An output that can be passed to a shader informing where to complete certain calculations. Right now this is set up to use a bounding box, but it could easily be rewritten to also use a texture. It also <em>could</em> be rewritten to use polygons, but I am trying to keep calculations to a minimum in the shader.</li>
  </ul>
  <p>Certain solutions I have tried before have worked, slightly, but this must be robust. The camera interfacing with the 3d object will be able to move completely around and through it, meaning at times the view will be completely surrounded by the 3d model with points both in front, and behind.</p>
  <p>Thank you for any help you can provide.
  I will try my best to update this post with information if needed.</p>