0
\$\begingroup\$

Imagine I render to an FBO some arbitrary geometry. Geometry can be rendered via single or multiple draw calls. For the sake of the question, assume I know nothing about geometry or transformation matrices.

I need to efficiently read back the minimal screen-space bounding box of all drawn geometry after the rendering to FBO is finished.

I imagine this can be done with via use of atomics on an image (imageLoad/imageStore) or SSBO, sadly these are not available to me. Is there any other mechanism I can try?

\$\endgroup\$
0
\$\begingroup\$

I would ask for some elaboration. I will though assume that you want the minimal bounding box of each individual item.

  • Assume that the objects can be rotated in arbitrary direction, scaled and positioned.
  • You have obtained the 3d minimum bounding box of the geometric objects.

Basically, the process I have taken in place is following:

  1. Obtain the 3d bounding box (all 8 points) of each geometric object you are going to draw.
  2. World View Projection Matrix to obtain your screenspace coordinates. Still a 3d vector, but you don't care about the Z depth so you now have 8 2d Vector points.
  3. For these 8 points, find the min and max values of x and y. These will be your screenspace bounding box values.
  4. These values will use the screenspace coords between -1 to 1. You should convert these to whatever coordinate system you need.
  5. Go to 1 for each object.

Hope this helps.

\$\endgroup\$
  • \$\begingroup\$ Sorry for being ambiguous. I need a bounding box of "everything" (not per individual item) being rendered into FBO. I don't have access to geometry and only limited access to world and view matrices. Basically threat geometry submission as black box. What I have under my control is shader, FBO and maybe some other OpenGL capabilities. \$\endgroup\$ – lhog Mar 4 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.